ldlinux: Don't discard cmdline arguments when executing labels
authorMatt Fleming <matt.fleming@intel.com>
Thu, 21 Feb 2013 14:24:57 +0000 (14:24 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 21 Feb 2013 14:31:21 +0000 (14:31 +0000)
Don't throw away additional cmdline arguments when executing a
label. Append them instead. Gene Cumm reports,

  When using the CLI and calling a LABEL "mylabel", specifying
  "mylabel options" does not pass "options" through to the kernel's
  command line.

Reported-by: Gene Cumm <gene.cumm@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/elflink/ldlinux/ldlinux.c

index 92346ee..c692d75 100644 (file)
@@ -154,9 +154,29 @@ __export void load_kernel(const char *command_line)
        /* Virtual kernel? */
        me = find_label(kernel);
        if (me) {
-               type = parse_image_type(me->cmdline);
+               const char *args;
+               char *cmd;
+               size_t len = strlen(me->cmdline) + 1;
 
-               execute(me->cmdline, type);
+               /* Find the end of the command */
+               args = find_command(kernel);
+               while(*args && my_isspace(*args))
+                       args++;
+
+               if (strlen(args))
+                       len += strlen(args) + 1; /* +1 for space (' ') */
+
+               cmd = malloc(len);
+               if (!cmd)
+                       goto bad_kernel;
+
+               if (strlen(args))
+                       snprintf(cmd, len, "%s %s", me->cmdline, args);
+               else
+                       strncpy(cmd, me->cmdline, len);
+
+               type = parse_image_type(cmd);
+               execute(cmd, type);
                /* We shouldn't return */
                goto bad_kernel;
        }