From: Gatis Paeglis Date: Fri, 12 Aug 2016 06:50:29 +0000 (+0200) Subject: ostree-prepare-root: enabler for simpler kernel arg X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~27^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=62cb078973f2dacd0975a7d67da907d267dbd8bd;p=ostree.git 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 --- 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) {