Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 26 ++++++++++++++++++++++++++
generator/actions.ml | 14 ++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index a17d656..78c5498 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1647,3 +1647,29 @@ do_btrfs_filesystem_defragment (const char *path, int flush, const
char *compres
return 0;
}
+
+int
+do_btrfs_rescue_chunk_recover (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, "rescue");
+ ADD_ARG (argv, i, "chunk-recover");
+ ADD_ARG (argv, i, "-y");
+ 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 2774336..eef764c 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12364,6 +12364,20 @@ Show status of running or finished scrub on a btrfs
filesystem." };
longdesc = "\
Defragment a file or directory on a btrfs filesystem. compress is one of zlib or
lzo." };
+ { defaults with
+ name = "btrfs_rescue_chunk_recover";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 444;
+ optional = Some "btrfs"; camel_name = "BTRFSRescueChunkRecover";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["btrfs_rescue_chunk_recover"; "/dev/sda1"]]), [];
+ ];
+ shortdesc = "recover the chunk tree of btrfs filesystem";
+ longdesc = "\
+Recover the chunk tree of btrfs filesystem by scannning the devices one by one." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 6a13cf6..1e6fd03 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-443
+444
--
2.1.0