[Libguestfs] [PATCH V2] NEW API: add new api btrfs-fsck

Wanlong Gao gaowanlong at cn.fujitsu.com
Tue May 15 07:57:10 UTC 2012


Add the new API btrfs-fsck to check the btrfs filesystem.
Btrfs is currently under heavy development, and not suitable for
any uses other than benchmarking and review. But it'll be useful
in the near future.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 daemon/btrfs.c                 |   17 +++++++++++++++++
 generator/generator_actions.ml |   12 ++++++++++++
 src/MAX_PROC_NR                |    2 +-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ab3babc..62f07f3 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -619,3 +619,20 @@ do_btrfs_set_seeding (const char *device, int svalue)
   free (err);
   return r;
 }
+
+int
+do_btrfs_fsck (const char *device)
+{
+  char *err;
+  int r;
+
+  r = commandr (NULL, &err, "btrfsck", device, NULL);
+  if (r == -1) {
+    reply_with_error ("%s: %s", device, err);
+    free (err);
+    return -1;
+  }
+
+  free (err);
+  return r;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index fc2df42..d4c1385 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -7232,6 +7232,18 @@ If C<devices> is an empty list, this does nothing.");
 Enable or disable the seeding feature of a device that contains
 a btrfs filesystem.");
 
+  ("btrfs_fsck", (RErr, [Device "device"], []), 332, [Optional "btrfs"],
+   [InitPartition, IfAvailable "btrfs", TestRun (
+     [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+      ["btrfs_fsck"; "/dev/sda1"]])],
+   "check a btrfs filesystem",
+   "\
+Used to check a btrfs filesystem, C<device> is the device file where the
+filesystem is stored.
+
+I<Note:> Btrfs is currently under heavy development, and not suitable for any
+uses other than benchmarking and review.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index ec6cab0..6f96da6 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-331
+332
-- 
1.7.10




More information about the Libguestfs mailing list