[ostree] Add ostree_ensure_repo_writable()
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] Add ostree_ensure_repo_writable()
- Date: Wed, 25 Mar 2015 21:25:23 +0000 (UTC)
commit 7941189dfde3795fb649aba41e207f0072dfcd86
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Jan 16 10:04:18 2015 -0500
Add ostree_ensure_repo_writable()
Commands that need to write files within the repo directory can call
this early to ensure the directory is writable for the current user.
If not, it fails with a helpful "You need to be root to perform this
command" message.
src/ostree/ot-main.c | 14 ++++++++++++++
src/ostree/ot-main.h | 2 ++
2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index c48a03c..94d29ca 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -360,3 +360,17 @@ ostree_admin_option_context_parse (GOptionContext *context,
out:
return success;
}
+
+gboolean
+ostree_ensure_repo_writable (OstreeRepo *repo,
+ GError **error)
+{
+ gboolean ret;
+
+ ret = ostree_repo_is_writable (repo, error);
+
+ g_prefix_error (error, "Cannot write to repository: ");
+
+ return ret;
+}
+
diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h
index 5f31b24..659727f 100644
--- a/src/ostree/ot-main.h
+++ b/src/ostree/ot-main.h
@@ -51,3 +51,5 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
int *argc, char ***argv,
OstreeSysroot **out_sysroot,
GCancellable *cancellable, GError **error);
+
+gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]