From 24087d477cd738a8efebe852d858fad2df699fb2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 17 Apr 2015 09:13:31 -0400 Subject: [PATCH] sysroot: Add ostree_sysroot_get_fd() This way external programs like rpm-ostree can do fd-relative operations on the deployment directories, like inspecting the RPM database. Closes: https://github.com/GNOME/ostree/pull/91 --- doc/ostree-sections.txt | 1 + src/libostree/ostree-sysroot.c | 17 +++++++++++++++++ src/libostree/ostree-sysroot.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt index efb160f8..d26d37a4 100644 --- a/doc/ostree-sections.txt +++ b/doc/ostree-sections.txt @@ -365,6 +365,7 @@ ostree_sysroot_new ostree_sysroot_new_default ostree_sysroot_get_path ostree_sysroot_load +ostree_sysroot_get_fd ostree_sysroot_ensure_initialized ostree_sysroot_get_bootversion ostree_sysroot_get_subbootversion diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 6d622402..b18c6b70 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -196,6 +196,23 @@ ensure_sysroot_fd (OstreeSysroot *self, return TRUE; } +/** + * ostree_sysroot_get_fd: + * @self: Sysroot + * + * Access a file descriptor that refers to the root directory of this + * sysroot. ostree_sysroot_load() must have been invoked prior to + * calling this function. + * + * Returns: A file descriptor valid for the lifetime of @self + */ +int +ostree_sysroot_get_fd (OstreeSysroot *self) +{ + g_return_val_if_fail (self->sysroot_fd != -1, -1); + return self->sysroot_fd; +} + /** * ostree_sysroot_ensure_initialized: * @self: Sysroot diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h index 4342470f..fe6441fb 100644 --- a/src/libostree/ostree-sysroot.h +++ b/src/libostree/ostree-sysroot.h @@ -39,6 +39,8 @@ OstreeSysroot* ostree_sysroot_new_default (void); GFile *ostree_sysroot_get_path (OstreeSysroot *self); +int ostree_sysroot_get_fd (OstreeSysroot *self); + gboolean ostree_sysroot_load (OstreeSysroot *self, GCancellable *cancellable, GError **error);