kernel: Support multiple initrds
authorH. Peter Anvin <hpa@zytor.com>
Tue, 27 Mar 2012 21:42:51 +0000 (14:42 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 27 Mar 2012 21:42:51 +0000 (14:42 -0700)
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@zytor.com>
com32/elflink/ldlinux/kernel.c

index 8165954..375dab0 100644 (file)
@@ -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);