ostree-prepare-root: enabler for simpler kernel arg

With the current approach, when ostree-prepare-root is used
on the kernel command line as init=, it always assumes that
the next value in the argument list is a path to the sysroot.
The code for falling back to a default path (if none is provided),
would only work if init= is the last arg in the argument list.
We can not rely on that and have to explicitly provide the
path to the sysroot. Which defeats the purpose of a default
path selection code.

To keep command line neater assume that sysroot is on / when
using ostree-prepare-root as init. This probably is what most
people want anyways. Also _ostree_kernel_args* API assumes
that args are space separated list. Which is problematic for:
"init=${ostree}/usr/lib/ostree/ostree-prepare-root /" as it
gets split in two.

Closes: #1401
Approved by: cgwalters
This commit is contained in:
Gatis Paeglis 2016-08-12 08:50:29 +02:00 committed by Atomic Bot
parent 94bbbdf3ca
commit 62cb078973
1 changed files with 9 additions and 3 deletions

View File

@ -102,10 +102,16 @@ main(int argc, char *argv[])
struct stat stbuf;
int we_mounted_proc = 0;
if (argc < 2)
root_arg = "/";
if (getpid() == 1)
{
root_arg = "/";
}
else
root_arg = argv[1];
{
if (argc < 2)
err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT");
root_arg = argv[1];
}
if (stat ("/proc/cmdline", &stbuf) < 0)
{