summaryrefslogtreecommitdiffstats
path: root/main/syslinux/boot_image.patch
blob: 59f5e046c867e97084e3159f57d0f1aa2f64fa4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 281e6e2253e737675458e75624a5ba42f0a5f4d6 Mon Sep 17 00:00:00 2001
From: Matt Fleming <matt.fleming@intel.com>
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 <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 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