[ostree] sysroot: Add ostree_sysroot_get_fd()



commit 24087d477cd738a8efebe852d858fad2df699fb2
Author: Colin Walters <walters verbum org>
Date:   Fri Apr 17 09:13:31 2015 -0400

    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(+), 0 deletions(-)
---
diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt
index efb160f..d26d37a 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 6d62240..b18c6b7 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -197,6 +197,23 @@ ensure_sysroot_fd (OstreeSysroot          *self,
 }
 
 /**
+ * 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
  * @cancellable: Cancellable
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
index 4342470..fe6441f 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]