Merge tag 'trace-v5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[sfrench/cifs-2.6.git] / init / main.c
index cc0ee4873419ce36558a3ec8d2561f78d6407e1c..f95b014a5479712176e385174cb81ff51e1b65df 100644 (file)
@@ -142,6 +142,15 @@ static char *extra_command_line;
 /* Extra init arguments */
 static char *extra_init_args;
 
+#ifdef CONFIG_BOOT_CONFIG
+/* Is bootconfig on command line? */
+static bool bootconfig_found;
+static bool initargs_found;
+#else
+# define bootconfig_found false
+# define initargs_found false
+#endif
+
 static char *execute_command;
 static char *ramdisk_execute_command;
 
@@ -336,17 +345,30 @@ u32 boot_config_checksum(unsigned char *p, u32 size)
        return ret;
 }
 
+static int __init bootconfig_params(char *param, char *val,
+                                   const char *unused, void *arg)
+{
+       if (strcmp(param, "bootconfig") == 0) {
+               bootconfig_found = true;
+       } else if (strcmp(param, "--") == 0) {
+               initargs_found = true;
+       }
+       return 0;
+}
+
 static void __init setup_boot_config(const char *cmdline)
 {
+       static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
        u32 size, csum;
        char *data, *copy;
-       const char *p;
        u32 *hdr;
        int ret;
 
-       p = strstr(cmdline, "bootconfig");
-       if (!p || (p != cmdline && !isspace(*(p-1))) ||
-           (p[10] && !isspace(p[10])))
+       strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+       parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
+                  bootconfig_params);
+
+       if (!bootconfig_found)
                return;
 
        if (!initrd_end)
@@ -562,11 +584,12 @@ static void __init setup_command_line(char *command_line)
                 * to init.
                 */
                len = strlen(saved_command_line);
-               if (!strstr(boot_command_line, " -- ")) {
+               if (initargs_found) {
+                       saved_command_line[len++] = ' ';
+               } else {
                        strcpy(saved_command_line + len, " -- ");
                        len += 4;
-               } else
-                       saved_command_line[len++] = ' ';
+               }
 
                strcpy(saved_command_line + len, extra_init_args);
        }