inittab: detect active console from kernel if no console= specified
[project/procd.git] / inittab.c
index 45118f4f1eaf05867e98040562131dc7df8e233e..2c2270cf68d367bcb882e0467d2bfd2456111daa 100644 (file)
--- a/inittab.c
+++ b/inittab.c
@@ -183,7 +183,15 @@ static void askconsole(struct init_action *a)
        char line[256], *tty, *split;
        int i;
 
+       /* First, try console= on the kernel command line,
+        * then fallback to /sys/class/tty/console/active,
+        * which should work when linux,stdout-path (or equivalent)
+        * is in the device tree
+        */
        tty = get_cmdline_val("console", line, sizeof(line));
+       if (tty == NULL) {
+               tty = get_active_console(line, sizeof(line));
+       }
        if (tty != NULL) {
                split = strchr(tty, ',');
                if (split != NULL)