[syslinux] [PATCH 3/9] ldlinux: Fix logic if no DEFAULT or UI directive is found
Matt Fleming
matt at console-pimps.org
Fri Nov 2 07:13:12 PDT 2012
From: Matt Fleming <matt.fleming at intel.com>
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 at intel.com>
---
com32/elflink/ldlinux/config.h | 2 +-
com32/elflink/ldlinux/execute.c | 2 +-
com32/elflink/ldlinux/ldlinux.c | 56 ++++++++++++++++++++---------------------
3 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index ea4736e..63e33b6 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -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__ */
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index e7969c2..6ccde49 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -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 };
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index d963595..59c5598 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -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;
}
--
1.7.11.7
More information about the Syslinux
mailing list