From: Joseph Marrero Corchado Date: Thu, 29 May 2025 18:48:50 +0000 (-0400) Subject: ostree-prepare-root: add option processing for kernel arguments X-Git-Tag: archive/raspbian/2025.7-2+rpi1^2^2~6^2~4^2~24^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9fa6e8fb60dd467e27b075c04d46204ce87a83ce;p=ostree.git ostree-prepare-root: add option processing for kernel arguments In a future soft-reboot feature this will allow us to pass kernel arguments for the deployment we are going to soft-reboot into. --- diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 68707f10..1e77809f 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -97,6 +97,8 @@ #include "ostree-mount-util.h" +static GOptionEntry options[] = { { NULL } }; + static bool sysroot_is_configured_ro (const char *sysroot) { @@ -261,11 +263,26 @@ main (int argc, char *argv[]) struct stat stbuf; g_autoptr (GError) error = NULL; + g_autoptr (GOptionContext) context = g_option_context_new ("SYSROOT [KERNEL_CMDLINE]"); + g_option_context_add_main_entries (context, options, NULL); + if (!g_option_context_parse (context, &argc, &argv, &error)) + errx (EXIT_FAILURE, "Error parsing options: %s", error->message); + if (argc < 2) - err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT"); + err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT [KERNEL_CMDLINE]"); const char *root_arg = argv[1]; - g_autofree char *kernel_cmdline = read_proc_cmdline (); + g_autofree char *kernel_cmdline = NULL; + if (argc < 3) + { + kernel_cmdline = read_proc_cmdline (); + } + else + { + // Duplicate argv[2] so g_autofree can safely manage it. + kernel_cmdline = g_strdup (argv[2]); + } + if (!kernel_cmdline) errx (EXIT_FAILURE, "Failed to read kernel cmdline");