diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-02-09 10:15:38 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-03-13 10:22:03 +0000 |
commit | b0a737c5cdbd7de3790bc5cf9a0e4b21dd1aed56 (patch) | |
tree | 676ec634dea3f51df211d98921196ea73b4b6d31 | |
parent | c8224383b59b1887c020182684d23a134470802a (diff) | |
download | syslinux-b0a737c5cdbd7de3790bc5cf9a0e4b21dd1aed56.tar.gz syslinux-b0a737c5cdbd7de3790bc5cf9a0e4b21dd1aed56.tar.xz syslinux-b0a737c5cdbd7de3790bc5cf9a0e4b21dd1aed56.zip |
ldlinux: Parse kernel type for labels
We need to parse the kernel type for labels aswell as things entered
on the cmdline, instead of always passing KT_KERNEL or KT_NONE to
execute(). Move the logic into a new helper function.
This fixes a bug where an incorrect kernel type would be passed to
execute() if anything other than a linux kernel (such as a .bin) was
specified in a LABEL's KERNEL argument, which resulted in the file not
being executed.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | com32/elflink/ldlinux/ldlinux.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c index 53604179..dcde5427 100644 --- a/com32/elflink/ldlinux/ldlinux.c +++ b/com32/elflink/ldlinux/ldlinux.c @@ -11,43 +11,19 @@ #include <sys/module.h> -/* - * Attempt to load a kernel after deciding what type of image it is. - * - * We only return from this function if something went wrong loading - * the the kernel. If we return the caller should call enter_cmdline() - * so that the user can help us out. - */ -static void load_kernel(const char *kernel) +static enum kernel_type parse_kernel_type(char *kernel) { - struct menu_entry *me; enum kernel_type type; - const char *cmdline, *p; + const char *p; int len; - /* Virtual kernel? */ - me = find_label(kernel); - if (me) { - enum kernel_type type = KT_KERNEL; - - /* cmdline contains type specifier */ - if (me->cmdline[0] == '.') - type = KT_NONE; - - execute(me->cmdline, type); - /* We shouldn't return */ - goto bad_kernel; - } - - if (!allowimplicit) - goto bad_implicit; - - p = kernel; /* Find the end of the command */ + p = kernel; while (*p && !my_isspace(*p)) p++; len = p - kernel; + if (!strncmp(kernel + len - 4, ".c32", 4)) { type = KT_COM32; } else if (!strncmp(kernel + len - 2, ".0", 2)) { @@ -68,6 +44,40 @@ static void load_kernel(const char *kernel) else type = KT_KERNEL; + return type; +} + +/* + * Attempt to load a kernel after deciding what type of image it is. + * + * We only return from this function if something went wrong loading + * the the kernel. If we return the caller should call enter_cmdline() + * so that the user can help us out. + */ +static void load_kernel(const char *kernel) +{ + struct menu_entry *me; + enum kernel_type type; + const char *cmdline; + + /* Virtual kernel? */ + me = find_label(kernel); + if (me) { + type = parse_kernel_type(me->cmdline); + + /* cmdline contains type specifier */ + if (me->cmdline[0] == '.') + type = KT_NONE; + + execute(me->cmdline, type); + /* We shouldn't return */ + goto bad_kernel; + } + + if (!allowimplicit) + goto bad_implicit; + + type = parse_kernel_type(kernel); execute(kernel, type); bad_implicit: |