diff options
author | Colin Walters <walters@verbum.org> | 2022-07-13 16:35:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 16:35:28 -0400 |
commit | ed1146738b9aa687c7dabb0a4fd8dc2ad16244ce (patch) | |
tree | ec7fe105a5c87e62e5027e24c2b31af5eebfefc6 /src/libostree/ostree-sysroot-deploy.c | |
parent | a3749efb1acab237999d9d4d2b870f4b1832cac0 (diff) | |
parent | 2c716552052cd3d03cef5f2968d5945d799f8d90 (diff) | |
download | ostree-ed1146738b9aa687c7dabb0a4fd8dc2ad16244ce.tar.gz |
Merge pull request #2669 from HuijingHei/fix-kargs
Fix `ostree admin kargs edit-in-place` fails issue
Diffstat (limited to 'src/libostree/ostree-sysroot-deploy.c')
-rw-r--r-- | src/libostree/ostree-sysroot-deploy.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 3b04267c..2dc9f58b 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -3592,6 +3592,53 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, } /** + * ostree_sysroot_deployment_set_kargs_in_place: + * @self: Sysroot + * @deployment: A deployment + * @kargs_str: (allow none): Replace @deployment's kernel arguments + * @cancellable: Cancellable + * @error: Error + * + * Replace the kernel arguments of @deployment with the values in @kargs_str. + */ +gboolean +ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, + OstreeDeployment *deployment, + char *kargs_str, + GCancellable *cancellable, + GError **error) +{ + if (!ostree_sysroot_initialize (self, error)) + return FALSE; + if (!_ostree_sysroot_ensure_boot_fd (self, error)) + return FALSE; + if (!_ostree_sysroot_ensure_writable (self, error)) + return FALSE; + + g_assert (!ostree_deployment_is_staged (deployment)); + + OstreeBootconfigParser *new_bootconfig = ostree_deployment_get_bootconfig (deployment); + ostree_bootconfig_parser_set (new_bootconfig, "options", kargs_str); + + g_autofree char *bootconf_name = + g_strdup_printf ("ostree-%d-%s.conf", + self->deployments->len - ostree_deployment_get_index (deployment), + ostree_deployment_get_osname (deployment)); + + g_autofree char *bootconfdir = g_strdup_printf ("loader.%d/entries", self->bootversion); + glnx_autofd int bootconf_dfd = -1; + if (!glnx_opendirat (self->boot_fd, bootconfdir, TRUE, &bootconf_dfd, error)) + return FALSE; + + if (!ostree_bootconfig_parser_write_at (new_bootconfig, + bootconf_dfd, bootconf_name, + cancellable, error)) + return FALSE; + + return TRUE; +} + +/** * ostree_sysroot_deployment_set_mutable: * @self: Sysroot * @deployment: A deployment |