aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink
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 /com32/elflink
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>
Diffstat (limited to 'com32/elflink')
-rw-r--r--com32/elflink/ldlinux/execute.c13
-rw-r--r--com32/elflink/ldlinux/ldlinux.c8
2 files changed, 12 insertions, 9 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();