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 42199b6c6008..66dd87f4663d 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1102,6 +1102,7 @@ static int __ref kernel_init(void *unused)
static noinline void __init kernel_init_freeable(void)
{
+ struct kstat console_stat;
/*
* Wait until kthreadd is all set-up.
*/
@@ -1135,6 +1136,12 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ /* Use /dev/console to infer if the rootfs is setup properly */
+ if (vfs_lstat((char __user *) "/dev/console", (struct kstat __user *) &console_stat)
+ || !S_ISCHR(console_stat.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 (ksys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");