From: Hu Tao <hutao(a)cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 38 ++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 15 +++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 6b93973..e1f617d 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1929,3 +1929,41 @@ error:
free (ret);
return NULL;
}
+
+int64_t
+do_btrfs_inspect_internal_rootid (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;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+ int64_t ret;
+
+ path_buf = sysroot_path (path);
+ if (path_buf == NULL) {
+ reply_with_perror ("malloc");
+ return -1;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "inspect-internal");
+ ADD_ARG (argv, i, "rootid");
+ 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 -1;
+ }
+
+ if (sscanf (out, "%" SCNi64, &ret) != 1) {
+ reply_with_error ("%s: could not parse rootid: %s.", argv[0], out);
+ return -1;
+ }
+
+ return ret;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index c995787..be4cc98 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12475,6 +12475,21 @@ Show the status of a running or paused balance on a btrfs
filesystem." };
longdesc = "\
Show status of running or finished scrub on a btrfs filesystem." };
+ { defaults with
+ name = "btrfs_inspect_internal_rootid";
+ style = RInt64 "id", [Pathname "path"], [];
+ proc_nr = Some 450;
+ optional = Some "btrfs"; camel_name = "BTRFSInspectRootid";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["mount"; "/dev/sda1"; "/"];
+ ["btrfs_inspect_internal_rootid"; "/"]]), [];
+ ];
+ shortdesc = "get tree ID of the containing subvolume of path";
+ longdesc = "\
+Get tree ID of the containing subvolume of path." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 2b20fd0..29ba0df 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-449
+450
--
2.1.0