[Libguestfs] [PATCH 08/16] New API: btrfs_balance_status

Hu Tao hutao at cn.fujitsu.com
Fri Jan 16 02:23:43 UTC 2015


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

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index cdf3982..09ee7dd 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1534,3 +1534,35 @@ do_btrfs_balance_resume (const char *path)
 
   return 0;
 }
+
+char *
+do_btrfs_balance_status (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;
+  char *out;
+  int r;
+
+  path_buf = sysroot_path (path);
+  if (path_buf == NULL) {
+    reply_with_perror ("malloc");
+    return NULL;
+  }
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "balance");
+  ADD_ARG (argv, i, "status");
+  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 NULL;
+  }
+
+  return out;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index df083a1..c777720 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12317,6 +12317,17 @@ Cancel a running balance on a btrfs filesystem." };
     shortdesc = "resume a paused balance";
     longdesc = "\
 Resume a paused balance on a btrfs filesystem." };
+
+{ defaults with
+    name = "btrfs_balance_status";
+    style = RString "status", [Pathname "path"], [];
+    proc_nr = Some 441;
+    optional = Some "btrfs"; camel_name = "BTRFSBalanceStatus";
+    test_excuse = "test disk isn't large enough that btrfs_balance completes before we can get its status";
+    shortdesc = "show the status of a running or paused balance";
+    longdesc = "\
+Show the status of a running or paused balance on a btrfs filesystem." };
+
 ]
 
 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 534a21e..54bb288 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-440
+441
-- 
2.1.0




More information about the Libguestfs mailing list