aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-02-19 21:11:55 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-02-20 10:13:10 +0000
commitaa7dd29db684d73f044b520e8c148f7ddb8c38d5 (patch)
tree0a50358fc068f075adc56fcfb42c553f9d02f9ad
parent69c09a88f6c46ff139cd5c0316d3eeae508e2b5c (diff)
downloadsyslinux-aa7dd29db684d73f044b520e8c148f7ddb8c38d5.tar.gz
syslinux-aa7dd29db684d73f044b520e8c148f7ddb8c38d5.tar.xz
syslinux-aa7dd29db684d73f044b520e8c148f7ddb8c38d5.zip
ldlinux: Pass config filename as argv[1] to ldlinux.c32
Instead of hijacking ConfigName use a more standard method of passing a config name to ldlinux.c32's main() function, via argc and argv. This allows us to actually call open_config() the first time ldlinux.c32 is executed even if the file system has already modified ConfigName. For example, pxelinux_configfile() parses the DHCP 209 option and fills out ConfigName before ldlinux.c32 is launched, but because the PXE code needs to do things with the path to the config file (such as parsing the DHCP 210 option), we need to leave the config mangling to open_config() and not try and lookup ConfigName from ldlinux. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/elflink/ldlinux/execute.c13
-rw-r--r--com32/elflink/ldlinux/ldlinux.c8
-rw-r--r--core/elflink/load_env32.c8
-rw-r--r--core/include/core.h2
4 files changed, 17 insertions, 14 deletions
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index c6fa8d85..ffbcf74a 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -122,17 +122,23 @@ __export void execute(const char *cmdline, uint32_t type)
ldlinux_enter_command();
} else if (type == IMAGE_TYPE_CONFIG) {
- char *argv[] = { "ldlinux.c32", NULL };
+ char *argv[] = { "ldlinux.c32", NULL, NULL };
+ char *config;
int rv;
/* kernel contains the config file name */
- realpath(ConfigName, kernel, FILENAME_MAX);
+ config = malloc(FILENAME_MAX);
+ if (!config)
+ goto out;
+
+ realpath(config, kernel, FILENAME_MAX);
/* If we got anything on the command line, do a chdir */
if (*args)
mangle_name(config_cwd, args);
- rv = start_ldlinux(argv);
+ argv[1] = config;
+ rv = start_ldlinux(2, argv);
printf("Failed to exec ldlinux.c32: %s\n", strerror(rv));
} else if (type == IMAGE_TYPE_LOCALBOOT) {
local_boot(strtoul(kernel, NULL, 0));
@@ -145,6 +151,7 @@ __export void execute(const char *cmdline, uint32_t type)
new_linux_kernel((char *)kernel, (char *)args);
}
+out:
free((void *)kernel);
/* If this returns, something went bad; return to menu */
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index a8b1b386..92346ee5 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -277,19 +277,15 @@ void ldlinux_console_init(void)
openconsole(&dev_stdcon_r, &dev_ansiserial_w);
}
-__export int main(int argc __unused, char **argv __unused)
+__export int main(int argc __unused, char **argv)
{
const void *adv;
const char *cmdline;
size_t count = 0;
- char *config_argv[2] = { NULL, NULL };
ldlinux_console_init();
- if (ConfigName[0])
- config_argv[0] = ConfigName;
-
- parse_configs(config_argv);
+ parse_configs(&argv[1]);
__syslinux_set_serial_console_info();
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index c84582de..50ec266d 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -59,12 +59,12 @@ void init_module_subsystem(struct elf_module *module)
list_add(&module->list, &modules_head);
}
-__export int start_ldlinux(char **argv)
+__export int start_ldlinux(int argc, char **argv)
{
int rv;
again:
- rv = spawn_load(LDLINUX, 1, argv);
+ rv = spawn_load(LDLINUX, argc, argv);
if (rv == EEXIST) {
/*
* If a COM32 module calls execute() we may need to
@@ -134,7 +134,7 @@ void load_env32(com32sys_t * regs __unused)
init_module_subsystem(&core_module);
- start_ldlinux(argv);
+ start_ldlinux(1, argv);
/*
* If we failed to load LDLINUX it could be because our
@@ -178,7 +178,7 @@ void load_env32(com32sys_t * regs __unused)
strcat(PATH, path);
}
- start_ldlinux(argv);
+ start_ldlinux(1, argv);
}
out:
diff --git a/core/include/core.h b/core/include/core.h
index a6ecbc4a..d54495bb 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -111,7 +111,7 @@ static inline void set_flags(com32sys_t *regs, uint32_t flags)
regs->eflags.l = eflags;
}
-extern int start_ldlinux(char **argv);
+extern int start_ldlinux(int argc, char **argv);
extern int create_args_and_load(char *);
extern void write_serial(char data);