diff options
author | Colin Walters <walters@verbum.org> | 2015-08-13 12:43:14 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-08-13 12:43:14 -0400 |
commit | 5c20ea920e0986686b3bd680a43a1ab1cdde37ea (patch) | |
tree | e8f818e8091a663873c4ec287cbf6c525548ac18 | |
parent | 3861b79efd876cd6116700e8e94776cd1ef23219 (diff) | |
download | ostree-5c20ea920e0986686b3bd680a43a1ab1cdde37ea.tar.gz |
sysroot: Add an unload() API
This will be used by gnome-continuous at least to drop the reference
to the fd so that unmounting can proceed. See
https://git.gnome.org/browse/gnome-continuous/commit/?id=95e9910ea288d302509ca667e0d190dd89377dd5
-rw-r--r-- | src/libostree/ostree-sysroot.c | 21 | ||||
-rw-r--r-- | src/libostree/ostree-sysroot.h | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index c7b3e474..7a4686d8 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -72,8 +72,7 @@ ostree_sysroot_finalize (GObject *object) glnx_release_lock_file (&self->lock); - if (self->sysroot_fd != -1) - (void) close (self->sysroot_fd); + (void) ostree_sysroot_unload (self); G_OBJECT_CLASS (ostree_sysroot_parent_class)->finalize (object); } @@ -224,6 +223,24 @@ ostree_sysroot_get_fd (OstreeSysroot *self) } /** + * ostree_sysroot_unload: + * @self: Sysroot + * + * Release any resources such as file descriptors referring to the + * root directory of this sysroot. Normally, those resources are + * cleared by finalization, but in garbage collected languages that + * may not be predictable. + * + * This undoes the effect of `ostree_sysroot_load()`. + */ +void +ostree_sysroot_unload (OstreeSysroot *self) +{ + if (self->sysroot_fd != -1) + (void) close (self->sysroot_fd); +} + +/** * ostree_sysroot_ensure_initialized: * @self: Sysroot * @cancellable: Cancellable diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h index ce128bba..2fbc23b3 100644 --- a/src/libostree/ostree-sysroot.h +++ b/src/libostree/ostree-sysroot.h @@ -45,6 +45,8 @@ gboolean ostree_sysroot_load (OstreeSysroot *self, GCancellable *cancellable, GError **error); +void ostree_sysroot_unload (OstreeSysroot *self); + gboolean ostree_sysroot_ensure_initialized (OstreeSysroot *self, GCancellable *cancellable, GError **error); |