[syslinux:elflink] ldlinux: Complain to user on failure to perform file operations

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Nov 29 05:33:07 PST 2012


Commit-ID:  0174945b6b604425e8f576c0af0908ce00cdc493
Gitweb:     http://www.syslinux.org/commit/0174945b6b604425e8f576c0af0908ce00cdc493
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 29 Nov 2012 09:34:18 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 29 Nov 2012 13:28:47 +0000

ldlinux: Complain to user on failure to perform file operations

If we fail to chdir or to execute a COM32 file we should inform the
user so that they can debug the problem. We don't currently print
anything if the user tries to execute a regular file, such as a config
file, as an COM32 image.

We also shouldn't be returning the exit value of the module from
spawn_load(), because we have no way of doing anything useful with it,
and just because a main() function returns -1 doesn't mean it failed
to run. Modules need to take care of printing any error messages
themselves.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/elflink/ldlinux/execute.c    | 3 ++-
 com32/elflink/ldlinux/readconfig.c | 3 ++-
 com32/lib/sys/module/exec.c        | 2 --
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 1039923..2f0e037 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -109,7 +109,8 @@ void execute(const char *cmdline, uint32_t type)
 		ldlinux_console_init();
 
 		/* new entry for elf format c32 */
-		create_args_and_load((char *)cmdline);
+		if (create_args_and_load((char *)cmdline))
+			printf("Failed to load COM32 file %s\n", kernel);
 
 		/*
 		 * The old COM32 module code would run the module then
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 2fa0641..cc57dd8 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1368,7 +1368,8 @@ static int parse_one_config(const char *filename)
 	parse_config_file(f);
 
 	if (config_cwd[0]) {
-		chdir(config_cwd);
+		if (chdir(config_cwd) < 0)
+			printf("Failed to chdir to %s\n", config_cwd);
 		config_cwd[0] = '\0';
 	}
 
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 9ccab36..559bafc 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -261,8 +261,6 @@ int spawn_load(const char *name, int argc, char **argv)
 
 		if (res != 0)
 			goto out;
-
-		return ((unsigned int)ret_val & 0xFF);
 	}
 
 out:


More information about the Syslinux-commits mailing list