]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: improve kernel command line parsing
authorMike Frysinger <vapier@gentoo.org>
Wed, 29 Oct 2014 04:19:03 +0000 (00:19 -0400)
committerKarel Zak <kzak@redhat.com>
Fri, 31 Oct 2014 09:39:15 +0000 (10:39 +0100)
commit72a2a3f5d7cb56e0054b69f54bfc86e9e4a4ced9
tree33eef84caea639b7562f2f3608f4f95d7d70ec92
parent6ee8e19489ca2523aca65ab935af5efb90b50930
libmount: improve kernel command line parsing

The current command line parser will stop at the first occurrence of an
option, however the kernel does the opposite.  So if you have:
root=/dev/sda1 root=/dev/sda2
When you look for "root", the kernel will use /dev/sda2, but util-linux
uses /dev/sda1.

Further, if args are passed to custom init programs, the parser will
pick those up as kernel options.  So if you have:
root=/dev/sda1 -- /foo bar=yes
The kernel will stop at the "--" and pass the rest to userland.  But if
you look for "bar", util-linux will incorrectly return "yes".

Ultimately, there's no way for util-linux to exactly parse the command
line the same way as the kernel -- we don't know exactly which ones the
kernel picks up and which it passes on to userland (either as env vars
or as command line args).  The kernel passes all unrecognized options.
These updates are simple best effort.

URL: https://bugs.gentoo.org/526754
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
libmount/src/utils.c