Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HuijingHei committed Jul 8, 2022
1 parent c93fb71 commit e408b95
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/libostree/libostree-devel.sym
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
LIBOSTREE_2022.5 {
global:
ostree_kernel_args_append_if_missing;
ostree_sysroot_deployment_set_kargs_in_place;
} LIBOSTREE_2022.4;

/* Stub section for the stable release *after* this development one; don't
Expand Down
34 changes: 34 additions & 0 deletions src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3620,6 +3620,40 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
return TRUE;
}

gboolean
ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self,
OstreeDeployment *deployment,
char *kargs_str,
GCancellable *cancellable,
GError **error)
{
if (!_ostree_sysroot_ensure_writable (self, error))
return FALSE;

/* For now; instead of this do a redeployment */
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 (ostree_deployment_get_bootconfig (deployment),
bootconf_dfd, bootconf_name,
cancellable, error))
return FALSE;

return TRUE;
}

/**
* ostree_sysroot_deployment_set_mutable:
* @self: Sysroot
Expand Down
7 changes: 7 additions & 0 deletions src/libostree/ostree-sysroot.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ gboolean ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
GCancellable *cancellable,
GError **error);

_OSTREE_PUBLIC
gboolean ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self,
OstreeDeployment *deployment,
char *kargs_str,
GCancellable *cancellable,
GError **error);

_OSTREE_PUBLIC
gboolean ostree_sysroot_write_deployments (OstreeSysroot *self,
GPtrArray *new_deployments,
Expand Down
6 changes: 3 additions & 3 deletions src/ostree/ot-admin-kargs-builtin-edit-in-place.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ ot_admin_kargs_builtin_edit_in_place (int argc, char **argv, OstreeCommandInvoca
}
}

g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
g_autofree char *new_options = ostree_kernel_args_to_string (kargs);

if (!ostree_sysroot_deployment_set_kargs (sysroot, deployment,
kargs_strv,
if (!ostree_sysroot_deployment_set_kargs_in_place (sysroot, deployment,
new_options,
cancellable, error))
return FALSE;

Expand Down

0 comments on commit e408b95

Please sign in to comment.