ldlinux: Record "default" and "ui" command lines
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 8 Mar 2011 17:07:13 +0000 (17:07 +0000)
committerMatt Fleming <matt.fleming@linux.intel.com>
Wed, 9 Mar 2011 14:32:36 +0000 (14:32 +0000)
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@linux.intel.com>
com32/elflink/ldlinux/config.h
com32/elflink/ldlinux/readconfig.c

index 3125b27..17c7b28 100644 (file)
 #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__ */
index f365b6f..ed498ff 100644 (file)
@@ -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));
        }
        
        /*