summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-kernel-args.c
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2014-09-23 11:16:53 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2014-09-26 10:40:37 -0400
commit262cba09c0bfdcd5f13dea63369b451d817d871f (patch)
tree4b33a9b1ab514071698de6849eb9f4cf6ac5ee79 /src/libostree/ostree-kernel-args.c
parentedf9cf5a7f0a44895cc3fc0918b427283d129b25 (diff)
downloadostree-262cba09c0bfdcd5f13dea63369b451d817d871f.tar.gz
ostree admin instutil set-kargs: make more flexible
Add command line arguments: --import-proc-cmdline: import values from /proc/cmdline --merge: import current values --replace=ARG=VALUE: replace value --append=ARG=VALUE: append a new argument Extra command line arguments are treated like --append=, which gives backwards compatibility. https://bugzilla.gnome.org/show_bug.cgi?id=731051
Diffstat (limited to 'src/libostree/ostree-kernel-args.c')
-rw-r--r--src/libostree/ostree-kernel-args.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libostree/ostree-kernel-args.c b/src/libostree/ostree-kernel-args.c
index f31932ed..524b9cdd 100644
--- a/src/libostree/ostree-kernel-args.c
+++ b/src/libostree/ostree-kernel-args.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "ostree-kernel-args.h"
+#include "libgsystem.h"
#include <string.h>
@@ -156,6 +157,29 @@ _ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
}
}
+gboolean
+_ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gs_unref_object GFile *proc_cmdline_path = g_file_new_for_path ("/proc/cmdline");
+ gs_free char *proc_cmdline = NULL;
+ gsize proc_cmdline_len = 0;
+ gs_strfreev char **proc_cmdline_args = NULL;
+
+ if (!g_file_load_contents (proc_cmdline_path, cancellable,
+ &proc_cmdline, &proc_cmdline_len,
+ NULL, error))
+ return FALSE;
+
+ g_strchomp (proc_cmdline);
+
+ proc_cmdline_args = g_strsplit (proc_cmdline, " ", -1);
+ _ostree_kernel_args_append_argv (kargs, proc_cmdline_args);
+
+ return TRUE;
+}
+
void
_ostree_kernel_args_parse_append (OstreeKernelArgs *kargs,
const char *options)