Add an API to set/unset a deployment tree's mutability
This will be used by rpm-ostree to unset the immutable bit temporarily in order to do package layering. We could add an API to deploy a tree without the immutable bit, but this is simpler.
This commit is contained in:
parent
54f848a78c
commit
42744628b3
|
|
@ -1829,8 +1829,8 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
|
|||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!_ostree_linuxfs_alter_immutable_flag (new_deployment_path, TRUE,
|
||||
cancellable, error))
|
||||
if (!ostree_sysroot_deployment_set_mutable (self, new_deployment, FALSE,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
{ ostree_cleanup_sepolicy_fscreatecon gpointer dummy = NULL;
|
||||
|
|
@ -1927,3 +1927,39 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
|
|||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_sysroot_deployment_set_mutable:
|
||||
* @self: Sysroot
|
||||
* @deployment: A deployment
|
||||
* @mutable: Whether or not deployment's files can be changed
|
||||
* @error: Error
|
||||
*
|
||||
* By default, deployment directories are not mutable. This function
|
||||
* will allow making them temporarily mutable, for example to allow
|
||||
* layering additional non-OSTree content.
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_deployment_set_mutable (OstreeSysroot *self,
|
||||
OstreeDeployment *deployment,
|
||||
gboolean mutable,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
|
||||
glnx_fd_close int fd = -1;
|
||||
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &fd, error))
|
||||
goto out;
|
||||
|
||||
if (!_ostree_linuxfs_fd_alter_immutable_flag (fd, !mutable, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@ gboolean ostree_sysroot_deploy_tree (OstreeSysroot *self,
|
|||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_sysroot_deployment_set_mutable (OstreeSysroot *self,
|
||||
OstreeDeployment *deployment,
|
||||
gboolean mutable,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
OstreeDeployment *ostree_sysroot_get_merge_deployment (OstreeSysroot *self,
|
||||
const char *osname);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue