Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 32 ++++++++++++++++++++++++++++++++
generator/actions.ml | 16 ++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 09ee7dd..700af9a 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1566,3 +1566,35 @@ do_btrfs_balance_status (const char *path)
return out;
}
+
+char *
+do_btrfs_scrub_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, "scrub");
+ 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 c777720..8d8b891 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12328,6 +12328,22 @@ Resume a paused balance on a btrfs filesystem." };
longdesc = "\
Show the status of a running or paused balance on a btrfs filesystem." };
+ { defaults with
+ name = "btrfs_scrub_status";
+ style = RString "status", [Pathname "path"], [];
+ proc_nr = Some 442;
+ optional = Some "btrfs"; camel_name = "BTRFSScrubStatus";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["mount"; "/dev/sda1"; "/"];
+ ["btrfs_scrub_start"; "/"];
+ ["btrfs_scrub_status"; "/"]]), [];
+ ];
+ shortdesc = "show status of running or finished scrub";
+ longdesc = "\
+Show status of running or finished scrub 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 54bb288..18e1dd6 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-441
+442
--
2.1.0