From 62cb078973f2dacd0975a7d67da907d267dbd8bd Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 12 Aug 2016 08:50:29 +0200 Subject: [PATCH] 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 --- src/switchroot/ostree-prepare-root.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 9b8c3381..43e15fcc 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -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) { -- 2.30.2