[arch-projects] [mkinitcpio] [RFC] Rewrite parse_cmdline (again)
d at falconindy.com
Fri Apr 15 06:22:36 EDT 2011
On Fri, Apr 15, 2011 at 10:06:55AM +0200, Thomas Bächler wrote:
> Am 15.04.2011 02:24, schrieb Dave Reisner:
> > Yes, the idea is that the user is expected to escape their own
> > whitespace, just as they are expected to do so in /etc/fstab.
> You don't understand the problem at all: We cannot simply change the
> format of the kernel command line as we wish.
> I'll explain it to you as clearly as possible:
> The kernel interprets A=B pairs on the command line, where B can be
> double-quoted - as far as I am aware, the kernel does not interpret any
> kind of escapes here, solely double quotes.
> This is what the kernel does with them (as far as I figured it out so far):
> (1) If the option A is recognized by any part of the kernel, B is passed
> as the value of A to that part of the kernel. If we were to escape
> characters inside it, it wouldn't understand the value anymore.
> (2) If the option A is not recognized by the kernel, it is exported into
> the initial environment (which is passed on to PID 1).
> (3) If an option is not of the form A=B, but does not contain a =, the
> option is parsed as an argument to init.
> Sadly, some of the variables we need in early userspace are not exported
> - this at least applies to root=, but there might be more (root= is
> traditionally used by the kernel, so (1) applies to it). Therefore, we
> need to parse the whole command line again.
> Most of what we parse there is actually redundant - like the acpi_osi=
> or video= options, which are never used in early userspace. However,
> even if we omit setting those variables, we still need to parse them to
> know where they end, in order to get all options from the command line.
> What we MUST do is deal with the format the kernel command line has. I
> didn't even understand your comments until now, because I would never
> have thought your suggestion was that ridiculous.
Cool, good to see a breakdown of how the cmdline parameters are passed.
I didn't come across any of this in my googling adventures. I do notice,
however, that only simple words (not variable decls) at the _end_ of the
cmdline are passed on as positional parameters to init. Anything else
seems to be ignored.
More information about the arch-projects