aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-29 22:52:42 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-30 11:04:23 +0000
commit163b8b1a7aabad440e824c64e51c19709cd0a529 (patch)
tree316106e146c7ca2e1bdf0aa9c63cb39431653d61
parent4bd9ed23c51beb53f5fb650992ed20328876c411 (diff)
downloadsyslinux-163b8b1a7aabad440e824c64e51c19709cd0a529.tar.gz
syslinux-163b8b1a7aabad440e824c64e51c19709cd0a529.tar.xz
syslinux-163b8b1a7aabad440e824c64e51c19709cd0a529.zip
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@intel.com>
-rw-r--r--com32/elflink/ldlinux/execute.c4
-rw-r--r--core/elflink/load_env32.c10
2 files changed, 13 insertions, 1 deletions
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 2f0e037e..4b4faf82 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 23d6baa1..a4bee754 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);
/*