bind the console to /dev/null if the real console fails to come up
authorJohn Crispin <blogic@openwrt.org>
Sat, 9 Nov 2013 19:20:55 +0000 (20:20 +0100)
committerJohn Crispin <blogic@openwrt.org>
Sat, 9 Nov 2013 19:20:55 +0000 (20:20 +0100)
this was reported on irc by oc80z

Signed-off-by: John Crispin <blogic@openwrt.org>
early.c

diff --git a/early.c b/early.c
index e86e4dd1ad368907b63705e1e68be60c53d67f9a..7da1e4b02ac7992cbf5a3e8ffbffb47e8e95ae7b 100644 (file)
--- a/early.c
+++ b/early.c
@@ -42,6 +42,7 @@ static void early_mounts(void)
 static void early_dev(void)
 {
        mkdev("*", 0600);
+       mknod("/dev/null", 0666, makedev(1, 3));
 }
 
 static void early_console(const char *dev)
@@ -55,10 +56,8 @@ static void early_console(const char *dev)
        }
 
        dd = open(dev, O_RDWR);
-       if (dd < 0) {
-               ERROR("Failed to open %s\n", dev);
-               return;
-       }
+       if (dd < 0)
+               dd = open("/dev/null", O_RDWR);
 
        dup2(dd, STDIN_FILENO);
        dup2(dd, STDOUT_FILENO);