blob: 13ae92af89f796292427d3d9729e97abdcfa6df1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
From 4ad8c12c9b21426166d55ef6e9e5aaad03df8c57 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Thu, 8 Apr 2010 23:44:21 -0700
Subject: [PATCH] check console device file on fs when booting
If a root filesystem is generated as non-root, one of
the tell tale signs is /dev/console not being a character
file. To save a whole class of questions, let's just test
for the condition and let the user know.
Signed-off-by: Richard Laroque <rlarocqu@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
init/main.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/init/main.c b/init/main.c
index 18f8f0140fa0..5b904bc78fa4 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1112,6 +1112,9 @@ static int __ref kernel_init(void *unused)
static noinline void __init kernel_init_freeable(void)
{
+#ifndef CONFIG_BLK_DEV_INITRD
+ struct kstat console_stat;
+#endif
/*
* Wait until kthreadd is all set-up.
*/
@@ -1143,6 +1146,18 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+#ifndef CONFIG_BLK_DEV_INITRD
+ /*
+ * Use /dev/console to infer if the rootfs is setup properly.
+ * In case of initrd or initramfs /dev/console might be instantiated
+ * later by /init so don't do this check for CONFIG_BLK_DEV_INITRD
+ */
+ 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");
+ }
+#endif
+
/* 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");
--
2.19.1
|