[syslinux:elflink] kernel: Support multiple initrds

syslinux-bot for H. Peter Anvin hpa at zytor.com
Tue Mar 27 14:45:04 PDT 2012


Commit-ID:  f4bb0ff748a3259427c5856714720570a7a5ebf6
Gitweb:     http://www.syslinux.org/commit/f4bb0ff748a3259427c5856714720570a7a5ebf6
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 27 Mar 2012 14:42:51 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 27 Mar 2012 14:42:51 -0700

kernel: Support multiple initrds

Support loading multiple initrd images separated by commas.  It still
doesn't correctly handle a secondary initrd= argument overriding the
first; not clear if that really was a good idea or if they would be
considered additive arguments.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 com32/elflink/ldlinux/kernel.c |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index 8165954..375dab0 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -101,22 +101,35 @@ int new_linux_kernel(char *okernel, char *ocmdline)
 	/* Find and load initramfs */
 	temp = strstr(cmdline, "initrd=");
 	if (temp) {
-		i = 0;
-
 		/* Initialize the initramfs chain */
 		initramfs = initramfs_init();
 		if (!initramfs)
 			goto bail;
 
-		temp += strlen("initrd=");
-		while (*temp != ' ' && *temp)
-			initrd_name[i++] = *temp++;
-		initrd_name[i] = '\0';
+		temp += 6; /* strlen("initrd") */
+		do {
+		    char *p = initrd_name;
 
-		initramfs_load_archive(initramfs, initrd_name);
-	}
+		    temp++;	/* Skip = or , */
+
+		    while (*temp != ' ' && *temp != ',' && *temp)
+			*p++ = *temp++;
+		    *p = '\0';
+
+		    if (!opt_quiet)
+			printf("Loading %s...", initrd_name);
 
-	//dprintf("loading initrd done");
+		    if (initramfs_load_archive(initramfs, initrd_name)) {
+			if (opt_quiet)
+			    printf("Loading %s ", initrd_name);
+			printf("failed!\n");
+			goto bail;
+		    }
+
+		    if (!opt_quiet)
+			printf("ok\n");
+		} while (*temp == ',');
+	}
 
 	/* This should not return... */
 	syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline);


More information about the Syslinux-commits mailing list