[syslinux] [PATCH 13/19] ldlinux: chdir to the APPEND str when parsing a CONFIG directive

Matt Fleming matt at console-pimps.org
Fri Mar 23 11:02:47 PDT 2012


From: Matt Fleming <matt.fleming at intel.com>

If an APPEND directive was specified for a CONFIG label then we need
to chdir to that directory after parsing the new config file.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>
---
 com32/elflink/ldlinux/execute.c    |    4 ++++
 com32/elflink/ldlinux/readconfig.c |    5 +++++
 core/fs/lib/searchconfig.c         |    1 +
 core/include/core.h                |    1 +
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index c01d63f..b3ed958 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -96,6 +96,10 @@ void execute(const char *cmdline, enum kernel_type type)
 		/* kernel contains the config file name */
 		realpath(ConfigName, kernel, FILENAME_MAX);
 
+		/* If we got anything on the command line, do a chdir */
+		if (*args)
+			mangle_name(config_cwd, args);
+
 		start_ldlinux("ldlinux.c32", 1, argv);
 	} else {
 		/* process the image need int 22 support */
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 564cbef..573d724 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1345,6 +1345,11 @@ static int parse_one_config(const char *filename)
 	f = fdopen(fd, mode);
 	parse_config_file(f);
 
+	if (config_cwd[0]) {
+		chdir(config_cwd);
+		config_cwd[0] = NULL;
+	}
+
 	return 0;
 }
 
diff --git a/core/fs/lib/searchconfig.c b/core/fs/lib/searchconfig.c
index 7fdad18..f688e7f 100644
--- a/core/fs/lib/searchconfig.c
+++ b/core/fs/lib/searchconfig.c
@@ -5,6 +5,7 @@
 #include <fs.h>
 
 char ConfigName[FILENAME_MAX];
+char config_cwd[FILENAME_MAX];
 
 /*
  * Common implementation of load_config
diff --git a/core/include/core.h b/core/include/core.h
index a247d49..d2aaf72 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -18,6 +18,7 @@ extern char trackbuf[];
 extern char CurrentDirName[];
 extern char SubvolName[];
 extern char ConfigName[];
+extern char config_cwd[];
 extern char KernelName[];
 extern char cmd_line[];
 extern char ConfigFile[];
-- 
1.7.4.4




More information about the Syslinux mailing list