[Libguestfs] [PATCH 1/2] New API: btrfs_filesystem_show

Chen Hanxiao
Thu, 05 Mar 2015 06:10:46 -0000

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
 daemon/btrfs.c       | 26 ++++++++++++++++++++++++++
 generator/actions.ml | 10 ++++++++++
 src/MAX_PROC_NR      |  2 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index d4b3207..df2fbf6 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1608,6 +1608,32 @@ do_btrfs_filesystem_defragment (const char *path, int
flush, const char *compres
   return 0;
 }

+char *
+do_btrfs_filesystem_show (const char *device)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *err = NULL;
+  char *out = NULL;
+  int r;
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "filesystem");
+  ADD_ARG (argv, i, "show");
+  ADD_ARG (argv, i, device);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", device, err);
+    free(out);
+    return NULL;
+  }
+
+  return out;
+}
+
 int
 do_btrfs_rescue_chunk_recover (const char *device)
 {
diff --git a/generator/actions.ml b/generator/actions.ml
index 9f32cb5..e6cd8f2 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12522,6 +12522,16 @@ This will Enable extended inode refs." };
     longdesc = "\
 This enable skinny metadata extent refs." };

+  { defaults with
+    name = "btrfs_filesystem_show";
+    style = RString "output", [Device "device"], [];
+    proc_nr = Some 453;
+    optional = Some "btrfs"; camel_name =
"BTRFSFilesystemShow";
+    test_excuse = "can't be tested becasue output will vary from each
mkfs.btrfs";
+    shortdesc = "show btrfs filesystem with some additional info";
+    longdesc = "\
+This show btrfs filesystem with some additional info." };
+
 ]

 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 8670c73..534b992 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-452
+453
--
2.1.0