[syslinux] [PATCH 12/12] ldlinux: makes loading initramfs compatible with multidisk

Andre Ericson de.ericson at gmail.com
Mon Aug 20 01:23:02 PDT 2012


Since you can specify more than one initramfs separated by a comma it
broke multidisk syntax as something like (hd0,2) would be broken at the
comma resulting in "(hd0" and "2)". The first comma of the path is now
ignored if it starts with '('.

Signed-off-by: Andre Ericson <de.ericson at gmail.com>
---
 com32/elflink/ldlinux/kernel.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index b8f9cb8..4c06b51 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -21,6 +21,7 @@ int new_linux_kernel(char *okernel, char *ocmdline)
 	void *kernel_data;
 	size_t kernel_len;
 	bool opt_quiet = false;
+	bool accept_comma = false; /* multidisk syntax workaround for initramfs */
 	char initrd_name[256];
 	char cmdline_buf[256], *cmdline;
 
@@ -107,12 +108,19 @@ int new_linux_kernel(char *okernel, char *ocmdline)
 
 		temp += 6; /* strlen("initrd") */
 		do {
+		    accept_comma = false;
 		    char *p = initrd_name;
 
 		    temp++;	/* Skip = or , */
 
-		    while (*temp != ' ' && *temp != ',' && *temp)
-			*p++ = *temp++;
+		    if (*temp == '(') /* multidisk path */
+			    accept_comma = true;
+
+		    /* should not stop at first comma if it's a multidisk path */
+		    while (*temp != ' ' &&
+			    (*temp != ','|| (accept_comma && !(accept_comma = false)))
+			    && *temp)
+			    *p++ = *temp++;
 		    *p = '\0';
 
 		    if (!opt_quiet)
-- 
1.7.11.3




More information about the Syslinux mailing list