[syslinux] [PATCH 10/12] ldlinux: Record "default" and "ui" command lines
Matt Fleming
matt at console-pimps.org
Wed Mar 9 08:00:21 PST 2011
From: Matt Fleming <matt.fleming at linux.intel.com>
The command line following the "default" and "ui" options may be a
kernel or com32 module to load and execute, so we need to record it
for later processing.
Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>
---
com32/elflink/ldlinux/config.h | 9 +++++++++
com32/elflink/ldlinux/readconfig.c | 22 +++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index 3125b27..17c7b28 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -12,6 +12,13 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
+/*
+ * These values correspond to the "default" and "ui" commands
+ * respectively. "ui" takes precendence over "default".
+ */
+#define LEVEL_DEFAULT 1
+#define LEVEL_UI 2
+
extern short uappendlen; //bytes in append= command
extern short ontimeoutlen; //bytes in ontimeout command
extern short onerrorlen; //bytes in onerror command
@@ -26,4 +33,6 @@ extern short vkernel; //have we seen any "label" statements?
extern short displaycon; //conio.inc
extern short nohalt; //idle.inc
+extern char *default_cmd; //"default" command line
+
#endif /* __CONFIG_H__ */
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index f365b6f..ed498ff 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -59,6 +59,7 @@ short vkernel = 0; //have we seen any "label" statements?
short displaycon = 1; //conio.inc
short nohalt = 1; //idle.inc
+char *default_cmd = NULL; //"default" command line
/* Empty refstring */
const char *empty_string;
@@ -978,11 +979,26 @@ do_include:
else
ipappend = atoi(skipspace(p + 8));
} else if (looking_at(p, "default")) {
- /* default could be a kernel image or another label */
- refstr_put(globaldefault);
- globaldefault = refstrdup(skipspace(p + 7));
+ /* default could be a kernel image or another label */
+ refstr_put(globaldefault);
+ globaldefault = refstrdup(skipspace(p + 7));
+
+ /*
+ * On the chance that "default" is actually a kernel image
+ * and not a label, store a copy of it, but only if we
+ * haven't seen a "ui" command. "ui" commands take
+ * precendence over "default" commands.
+ */
+ if (defaultlevel < LEVEL_UI) {
+ defaultlevel = LEVEL_DEFAULT;
+ refstr_put(default_cmd);
+ default_cmd = refstrdup(globaldefault);
+ }
} else if (looking_at(p, "ui")) {
has_ui = 1;
+ defaultlevel = LEVEL_UI;
+ refstr_put(default_cmd);
+ default_cmd = refstrdup(skipspace(p + 2));
}
/*
--
1.7.4
More information about the Syslinux
mailing list