aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-08-13 16:45:11 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-08-13 16:45:37 +0100
commitfe084791a5e8c0985717d990d26652f416d12f15 (patch)
treecae01d8061e6f8ef224ed98beb021e20d3e9b6c1 /com32/elflink/ldlinux
parentb6b97c945d171aebc30510249a77581cd57fc8e7 (diff)
parentd1d03dee6bc961b0afd8dfc68fd35772ecded8be (diff)
downloadsyslinux-fe084791a5e8c0985717d990d26652f416d12f15.tar.gz
syslinux-fe084791a5e8c0985717d990d26652f416d12f15.tar.xz
syslinux-fe084791a5e8c0985717d990d26652f416d12f15.zip
Merge remote-tracking branch 'mfleming/elflink' into for-hpa/elflink/firmware
Conflicts: com32/lib/sys/module/common.c
Diffstat (limited to 'com32/elflink/ldlinux')
-rw-r--r--com32/elflink/ldlinux/config.h2
-rw-r--r--com32/elflink/ldlinux/execute.c10
-rw-r--r--com32/elflink/ldlinux/ldlinux.c70
3 files changed, 49 insertions, 33 deletions
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index 45832022..ea4736e6 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -47,4 +47,6 @@ extern int new_linux_kernel(char *okernel, char *ocmdline);
extern void pm_load_high(com32sys_t *regs);
+extern void ldlinux_enter_command(bool prompt);
+
#endif /* __CONFIG_H__ */
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 77d268c8..e7969c2e 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -18,6 +18,7 @@
#include <com32.h>
#include <sys/exec.h>
#include <sys/io.h>
+#include <sys/module.h>
#include "core.h"
#include "menu.h"
#include "fs.h"
@@ -93,6 +94,15 @@ void execute(const char *cmdline, uint32_t type)
if (type == IMAGE_TYPE_COM32) {
/* new entry for elf format c32 */
create_args_and_load((char *)cmdline);
+
+ /*
+ * The old COM32 module code would run the module then
+ * drop the user back at the command prompt,
+ * irrespective of how the COM32 module was loaded,
+ * e.g. from vesamenu.c32.
+ */
+ unload_modules_since("ldlinux.c32");
+ ldlinux_enter_command(!noescape);
} else if (type == IMAGE_TYPE_CONFIG) {
char *argv[] = { "ldlinux.c32", NULL };
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 073f1116..1c261cd5 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -83,19 +83,20 @@ static const char *get_extension(const char *kernel)
for (ext = file_extensions; ext->name; ext++) {
char *str;
int elen = strlen(ext->name);
- int fd;
+ FILE *f;
str = malloc(len + elen + 1);
strncpy(str, kernel, len);
strncpy(str + len, ext->name, elen);
str[len + elen] = '\0';
-
- fd = searchdir(str);
+ f = findpath(str);
free(str);
- if (fd >= 0)
+ if (f) {
+ fclose(f);
return ext->name;
+ }
}
return NULL;
@@ -222,6 +223,35 @@ static void enter_cmdline(void)
}
}
+void ldlinux_enter_command(bool prompt)
+{
+ const char *cmdline = default_cmd;
+
+ if (prompt)
+ goto cmdline;
+auto_boot:
+ /*
+ * Auto boot
+ */
+ if (defaultlevel || noescape) {
+ if (defaultlevel) {
+ load_kernel(cmdline); /* Shouldn't return */
+ } else {
+ printf("No DEFAULT or UI configuration directive found!\n");
+
+ if (noescape)
+ kaboom();
+ }
+ }
+
+cmdline:
+ /* Only returns if the user pressed enter or input timed out */
+ enter_cmdline();
+
+ cmdline = ontimeoutlen ? ontimeout : default_cmd;
+
+ goto auto_boot;
+}
int main(int argc __unused, char **argv __unused)
{
const void *adv;
@@ -249,7 +279,7 @@ int main(int argc __unused, char **argv __unused)
cmdline = dst = malloc(count + 1);
if (!dst) {
printf("Failed to allocate memory for ADV\n");
- goto cmdline;
+ ldlinux_enter_command(true);
}
for (i = 0; i < count; i++)
@@ -261,37 +291,11 @@ int main(int argc __unused, char **argv __unused)
syslinux_adv_write();
load_kernel(cmdline); /* Shouldn't return */
- goto cmdline;
+ ldlinux_enter_command(true);
}
/* TODO: Check KbdFlags? */
- if (forceprompt)
- goto cmdline;
-
- cmdline = default_cmd;
-auto_boot:
- /*
- * Auto boot
- */
- if (defaultlevel || noescape) {
- if (defaultlevel) {
- load_kernel(cmdline); /* Shouldn't return */
- } else {
- printf("No DEFAULT or UI configuration directive found!\n");
-
- if (noescape)
- kaboom();
- }
- }
-
-cmdline:
- /* Only returns if the user pressed enter or input timed out */
- enter_cmdline();
-
- cmdline = ontimeoutlen ? ontimeout : default_cmd;
-
- goto auto_boot;
-
+ ldlinux_enter_command(forceprompt);
return 0;
}