From 281e6e2253e737675458e75624a5ba42f0a5f4d6 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 7 Feb 2013 11:28:58 +0000 Subject: [PATCH] ldlinux: Append BOOT_IMAGE= to kernel cmdline Some users rely on the syntax of the kernel cmdline from 4.xx and this is currently different in 5.xx. Fix things to match the 4.xx syntax. Cc: H. Peter Anvin Signed-off-by: Matt Fleming --- com32/elflink/ldlinux/execute.c | 2 +- com32/elflink/ldlinux/kernel.c | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c index 5c53b99..c6fa8d8 100644 --- a/com32/elflink/ldlinux/execute.c +++ b/com32/elflink/ldlinux/execute.c @@ -142,7 +142,7 @@ __export void execute(const char *cmdline, uint32_t type) } else { /* Need add one item for kernel load, as we don't use * the assembly runkernel.inc any more */ - new_linux_kernel((char *)kernel, (char *)cmdline); + new_linux_kernel((char *)kernel, (char *)args); } free((void *)kernel); diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c index 920246f..f3ba37f 100644 --- a/com32/elflink/ldlinux/kernel.c +++ b/com32/elflink/ldlinux/kernel.c @@ -35,14 +35,10 @@ int new_linux_kernel(char *okernel, char *ocmdline) else if (append) args = append; - cmdline_len = strlen(kernel_name); - if (args) { - /* +1 for the space (' ') between kernel and args */ - cmdline_len += strlen(args) + 1; - } - - /* +1 for NUL termination */ - cmdline_len++; + cmdline_len = strlen("BOOT_IMAGE=") + strlen(kernel_name); + cmdline_len += 1; /* space between BOOT_IMAGE and args */ + cmdline_len += strlen(args); + cmdline_len += 1; /* NUL-termination */ cmdline = malloc(cmdline_len); if (!cmdline) { @@ -50,10 +46,7 @@ int new_linux_kernel(char *okernel, char *ocmdline) return 1; } - if (args) - snprintf(cmdline, cmdline_len, "%s %s", kernel_name, args); - else - snprintf(cmdline, cmdline_len, "%s", kernel_name); + sprintf(cmdline, "BOOT_IMAGE=%s %s", kernel_name, args); /* "keeppxe" handling */ #if IS_PXELINUX -- 1.7.6.5