summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUmang Jain <umang@endlessm.com>2018-08-31 19:50:29 +0530
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-04 21:31:34 +0000
commit68420f70bbb288cbd4424413f86f6cfecc06d7b1 (patch)
treeae1ab8cbe99c035e7dccff41a6fdca79b0dea8e9
parent3814d075cb7306f111bfa41f10b7d719d08b2679 (diff)
downloadostree-68420f70bbb288cbd4424413f86f6cfecc06d7b1.tar.gz
lib/repo: Add an API to get min-free-space-* reserved bytes
https://phabricator.endlessm.com/T23694 Closes: #1715 Approved by: cgwalters
-rw-r--r--apidoc/ostree-sections.txt1
-rw-r--r--src/libostree/libostree-devel.sym1
-rw-r--r--src/libostree/ostree-repo.c20
-rw-r--r--src/libostree/ostree-repo.h2
4 files changed, 24 insertions, 0 deletions
diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt
index 2e174244..70f93bab 100644
--- a/apidoc/ostree-sections.txt
+++ b/apidoc/ostree-sections.txt
@@ -294,6 +294,7 @@ ostree_repo_create_at
ostree_repo_create
ostree_repo_get_path
ostree_repo_get_mode
+ostree_repo_get_min_free_space_bytes
ostree_repo_get_config
ostree_repo_get_dfd
ostree_repo_hash
diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym
index 24db9df2..0bdade75 100644
--- a/src/libostree/libostree-devel.sym
+++ b/src/libostree/libostree-devel.sym
@@ -19,6 +19,7 @@
/* Add new symbols here. Release commits should copy this section into -released.sym. */
LIBOSTREE_2018.9 {
+ostree_repo_get_min_free_space_bytes;
} LIBOSTREE_2018.7;
/* Stub section for the stable release *after* this development one; don't
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 18736c24..edcb8af9 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -3293,6 +3293,26 @@ ostree_repo_get_mode (OstreeRepo *self)
}
/**
+ * ostree_repo_get_min_free_space:
+ * @self: Repo
+ *
+ * It should be noted that this function should be used only if there
+ * is a transaction active. It is a programmer error to request it
+ * otherwise.
+ *
+ * Returns: Value (in bytes) of min-free-space-* config option
+ * Since: 2018.9
+ */
+guint64
+ostree_repo_get_min_free_space_bytes (OstreeRepo *self)
+{
+ g_return_val_if_fail (OSTREE_IS_REPO (self), 0);
+ g_return_val_if_fail (self->in_transaction == TRUE, 0);
+
+ return self->reserved_blocks * self->txn.blocksize;
+}
+
+/**
* ostree_repo_get_parent:
* @self: Repo
*
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 60fa3d3e..11b7927e 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -128,6 +128,8 @@ _OSTREE_PUBLIC
OstreeRepoMode ostree_repo_get_mode (OstreeRepo *self);
_OSTREE_PUBLIC
+guint64 ostree_repo_get_min_free_space_bytes (OstreeRepo *self);
+_OSTREE_PUBLIC
GKeyFile * ostree_repo_get_config (OstreeRepo *self);
_OSTREE_PUBLIC