Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 24 ++++++++++++++++++++++++
generator/actions.ml | 14 ++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 79de539..de20bc3 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1375,3 +1375,27 @@ do_btrfs_scrub (const char *path)
return 0;
}
+
+int
+do_btrfs_check (const char *device)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "check");
+ 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);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index b44ce1c..c328319 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12267,6 +12267,20 @@ Reads all the data and metadata on the filesystem, and uses
checksums
and the duplicate copies from RAID storage to identify and repair any
corrupt data." };
+ { defaults with
+ name = "btrfs_check";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 436;
+ optional = Some "btrfs"; camel_name = "BTRFSCheck";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["btrfs_check"; "/dev/sda1"]]), [];
+ ];
+ shortdesc = "check or repair a btrfs filesystem offline";
+ longdesc = "\
+Check or repair a btrfs filesystem offline." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 5910394..246662b 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-435
+436
--
2.2.1