[syslinux:elflink] ldlinux: Don' t try reloading ldlinux.c32 unless it's likely to succeed

syslinux-bot for Matt Fleming matt.fleming at intel.com
Fri Nov 30 03:33:05 PST 2012


Commit-ID:  163b8b1a7aabad440e824c64e51c19709cd0a529
Gitweb:     http://www.syslinux.org/commit/163b8b1a7aabad440e824c64e51c19709cd0a529
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 29 Nov 2012 22:52:42 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Fri, 30 Nov 2012 11:04:23 +0000

ldlinux: Don't try reloading ldlinux.c32 unless it's likely to succeed

If we can't access ldlinux.c32 with findpath(), reloading it isn't
going to work so don't unload it or any of the other modules. Instead
return control to the caller.

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

---
 com32/elflink/ldlinux/execute.c |  4 +++-
 core/elflink/load_env32.c       | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 2f0e037..4b4faf8 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -126,6 +126,7 @@ void execute(const char *cmdline, uint32_t type)
 		ldlinux_enter_command();
 	} else if (type == IMAGE_TYPE_CONFIG) {
 		char *argv[] = { "ldlinux.c32", NULL };
+		int rv;
 
 		/* kernel contains the config file name */
 		realpath(ConfigName, kernel, FILENAME_MAX);
@@ -134,7 +135,8 @@ void execute(const char *cmdline, uint32_t type)
 		if (*args)
 			mangle_name(config_cwd, args);
 
-		start_ldlinux(argv);
+		rv = start_ldlinux(argv);
+		printf("Failed to exec ldlinux.c32: %s\n", strerror(rv));
 	} else if (type == IMAGE_TYPE_LOCALBOOT) {
 		local_boot(strtoul(kernel, NULL, 0));
 	} else if (type == IMAGE_TYPE_PXE || type == IMAGE_TYPE_BSS ||
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 23d6baa..a4bee75 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -71,9 +71,19 @@ again:
 		 * unload all the modules loaded since ldlinux.c32,
 		 * and restart initialisation. This is especially
 		 * important for config files.
+		 *
+		 * But before we do that, try our best to make sure
+		 * that spawn_load() is gonna succeed, e.g. that we
+		 * can find LDLINUX it in PATH.
 		 */
 		struct elf_module *ldlinux;
+		FILE *f;
+
+		f = findpath(LDLINUX);
+		if (!f)
+			return ENOENT;
 
+		fclose(f);
 		ldlinux = unload_modules_since(LDLINUX);
 
 		/*


More information about the Syslinux-commits mailing list