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

[Libguestfs] [PATCH 3/8] New API: btrfs_quota_enable



btrfs_quota_enable enables quota for subvolumes.

Signed-off-by: Hu Tao <hutao cn fujitsu com>
---
 daemon/btrfs.c       | 31 +++++++++++++++++++++++++++++++
 generator/actions.ml |  9 +++++++++
 src/MAX_PROC_NR      |  2 +-
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 2cfb364..31dd806 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -995,3 +995,34 @@ char **do_btrfs_subvolume_show (const char *subvolume)
   return ret.argv;
 
 }
+
+int do_btrfs_quota_enable (const char *path)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *path_buf = NULL;
+  CLEANUP_FREE char *err = NULL;
+  CLEANUP_FREE char *out = NULL;
+  int r;
+
+  path_buf = sysroot_path (path);
+  if (path_buf == NULL) {
+    reply_with_perror ("malloc");
+    return -1;
+  }
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "quota");
+  ADD_ARG (argv, i, "enable");
+  ADD_ARG (argv, i, path_buf);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", path, err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index d5ec528..3af8380 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12045,6 +12045,15 @@ Get the default subvolume or snapshot of a filesystem mounted at C<mountpoint>."
     longdesc = "\
 Return detailed information of the subvolume." };
 
+  { defaults with
+    name = "btrfs_quota_enable";
+    style = RErr, [Pathname "path"], [];
+    proc_nr = Some 427;
+    optional = Some "btrfs"; camel_name = "BTRFSQuotaEnable";
+    shortdesc = "enable subvolume quota support";
+    longdesc = "\
+Enable subvolume quota support for filesystem which contains C<path>." };
+
 ]
 
 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 9f51d08..d2a1e59 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-426
+427
-- 
1.9.3


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