aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/init/main.c b/init/main.c
index 51067e2db509..b4e9e79968a1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1040,6 +1040,7 @@ static int __ref kernel_init(void *unused)
static noinline void __init kernel_init_freeable(void)
{
+ struct stat console_stat;
/*
* Wait until kthreadd is all set-up.
*/
@@ -1073,6 +1074,12 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ /* Use /dev/console to infer if the rootfs is setup properly */
+ if (sys_newlstat((char __user *) "/dev/console", (struct stat __user *) &console_stat)
+ || !S_ISCHR(console_stat.st_mode)) {
+ panic("/dev/console is missing or not a character device!\nPlease ensure your rootfs is properly configured\n");
+ }
+
/* Open the /dev/console on the rootfs, this should never fail */
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");