[syslinux:elflink] ldlinux: Parse and store the "onerror" command line
syslinux-bot for Matt Fleming
matt.fleming at linux.intel.com
Mon Mar 14 15:33:58 PDT 2011
Commit-ID: 9ded45991b4fc83b40af963feb773ddca2589d74
Gitweb: http://syslinux.zytor.com/commit/9ded45991b4fc83b40af963feb773ddca2589d74
Author: Matt Fleming <matt.fleming at linux.intel.com>
AuthorDate: Wed, 9 Mar 2011 14:20:19 +0000
Committer: Matt Fleming <matt.fleming at linux.intel.com>
CommitDate: Wed, 9 Mar 2011 14:32:36 +0000
ldlinux: Parse and store the "onerror" command line
If we fail to load a kernel and the parser found an "onerror"
directive, execute the onerror command line.
Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>
---
com32/elflink/ldlinux/config.h | 1 +
com32/elflink/ldlinux/ldlinux.c | 10 ++++++++++
com32/elflink/ldlinux/readconfig.c | 9 +++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index 17c7b28..7765266 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -34,5 +34,6 @@ extern short displaycon; //conio.inc
extern short nohalt; //idle.inc
extern char *default_cmd; //"default" command line
+extern char *onerror; //"onerror" command line
#endif /* __CONFIG_H__ */
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index b94010e..b5a4409 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -29,6 +29,7 @@ static void enter_cmdline(void)
static void load_kernel(void)
{
enum kernel_type type;
+ const char *cmdline;
if (defaultlevel == LEVEL_UI)
type = KT_COM32;
@@ -36,6 +37,15 @@ static void load_kernel(void)
type = KT_KERNEL;
execute(default_cmd, type);
+
+ /*
+ * If we fail to boot the kernel execute the "onerror" command
+ * line.
+ */
+ if (onerrorlen) {
+ rsprintf(&cmdline, "%s %s", onerror, default_cmd);
+ execute(cmdline, KT_COM32);
+ }
}
static int ldlinux_main(int argc, char **argv)
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index ed498ff..898ee19 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -60,6 +60,7 @@ short displaycon = 1; //conio.inc
short nohalt = 1; //idle.inc
char *default_cmd = NULL; //"default" command line
+char *onerror = NULL; //"onerror" command line
/* Empty refstring */
const char *empty_string;
@@ -703,6 +704,8 @@ static void parse_config_file(FILE * f)
refstr_put(m->onerror);
m->onerror = refstrdup(skipspace(p + 7));
onerrorlen = strlen(m->onerror);
+ refstr_put(onerror);
+ onerror = refstrdup(m->onerror);
} else if (looking_at(p, "master")) {
p = skipspace(p + 6);
if (looking_at(p, "passwd")) {
@@ -1030,6 +1033,12 @@ do_include:
nocomplete = atoi(skipspace(p + 10));
} else if (looking_at(p, "nohalt")) {
nohalt = atoi(skipspace(p + 8));
+ } else if (looking_at(p, "onerror")) {
+ refstr_put(m->onerror);
+ m->onerror = refstrdup(skipspace(p + 7));
+ onerrorlen = strlen(m->onerror);
+ refstr_put(onerror);
+ onerror = refstrdup(m->onerror);
}
/* serial setting, bps, flow control */
More information about the Syslinux-commits
mailing list