ldlinux: Fix logic if no DEFAULT or UI directive is found
authorMatt Fleming <matt.fleming@intel.com>
Wed, 31 Oct 2012 12:42:25 +0000 (12:42 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 2 Nov 2012 11:55:41 +0000 (11:55 +0000)
Somewhere along the way the code that prints,

    No DEFAULT or UI configuration directive found!

was broken, and now no longer prints at all. While we're fixing this
it's a good opportunity to rework the logic to be clearer. Now we only
print the message if a config file was found, since these directives
are obviously missing if there is no config file (a warning will be
printed about the lack of config file anyway).

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/elflink/ldlinux/config.h
com32/elflink/ldlinux/execute.c
com32/elflink/ldlinux/ldlinux.c

index ea4736e..63e33b6 100644 (file)
@@ -47,6 +47,6 @@ extern int new_linux_kernel(char *okernel, char *ocmdline);
 
 extern void pm_load_high(com32sys_t *regs);
 
-extern void ldlinux_enter_command(bool prompt);
+extern void ldlinux_enter_command(void);
 
 #endif /* __CONFIG_H__ */
index e7969c2..6ccde49 100644 (file)
@@ -102,7 +102,7 @@ void execute(const char *cmdline, uint32_t type)
                 * e.g. from vesamenu.c32.
                 */
                unload_modules_since("ldlinux.c32");
-               ldlinux_enter_command(!noescape);
+               ldlinux_enter_command();
        } else if (type == IMAGE_TYPE_CONFIG) {
                char *argv[] = { "ldlinux.c32", NULL };
 
index d963595..59c5598 100644 (file)
@@ -216,41 +216,36 @@ static void enter_cmdline(void)
                printf("\n");
 
                /* return if user only press enter or we timed out */
-               if (!cmdline || cmdline[0] == '\0')
+               if (!cmdline || cmdline[0] == '\0') {
+                       if (ontimeoutlen)
+                               load_kernel(ontimeout);
                        return;
+               }
 
                load_kernel(cmdline);
        }
 }
 
-void ldlinux_enter_command(bool prompt)
+/*
+ * If this function returns you must call ldinux_enter_command() to
+ * preserve the 4.0x behaviour.
+ */
+void ldlinux_auto_boot(void)
 {
-       const char *cmdline = default_cmd;
-
-       if (prompt)
-               goto cmdline;
-auto_boot:
-       /*
-        * Auto boot
-        */
-       if (defaultlevel || noescape) {
-               if (defaultlevel) {
-                       load_kernel(cmdline); /* Shouldn't return */
-               } else {
+       if (!defaultlevel) {
+               if (strlen(ConfigName))
                        printf("No DEFAULT or UI configuration directive found!\n");
+               if (noescape)
+                       kaboom();
+       } else
+               load_kernel(default_cmd);
+}
 
-                       if (noescape)
-                               kaboom();
-               }
-       }
-
-cmdline:
-       /* Only returns if the user pressed enter or input timed out */
+void ldlinux_enter_command(void)
+{
+       if (noescape)
+               ldlinux_auto_boot();
        enter_cmdline();
-
-       cmdline = ontimeoutlen ? ontimeout : default_cmd;
-
-       goto auto_boot;
 }
 
 /*
@@ -291,7 +286,7 @@ int main(int argc __unused, char **argv __unused)
                cmdline = dst = malloc(count + 1);
                if (!dst) {
                        printf("Failed to allocate memory for ADV\n");
-                       ldlinux_enter_command(true);
+                       ldlinux_enter_command();
                }
 
                for (i = 0; i < count; i++)
@@ -303,11 +298,16 @@ int main(int argc __unused, char **argv __unused)
                        syslinux_adv_write();
 
                load_kernel(cmdline); /* Shouldn't return */
-               ldlinux_enter_command(true);
+               ldlinux_enter_command();
        }
 
        /* TODO: Check KbdFlags? */
+       if (!forceprompt)
+               ldlinux_auto_boot();
+
+       if (defaultlevel > 1)
+               ldlinux_auto_boot();
 
-       ldlinux_enter_command(forceprompt);
+       ldlinux_enter_command();
        return 0;
 }