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 | 41 +++++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 10 ++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 2c2eb57..d84c28e 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2049,3 +2049,44 @@ do_btrfs_inspect_internal_inode_resolve (int64_t inode, const char
*fs)
return out;
}
+
+char *
+do_btrfs_inspect_internal_logical_resolve (int64_t logical, const char *fs)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *fs_buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ char *out;
+ size_t len;
+ int r;
+ char logical_str[32];
+
+ fs_buf = sysroot_path (fs);
+ if (fs_buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "inspect-internal");
+ ADD_ARG (argv, i, "logical-resolve");
+ snprintf (logical_str, sizeof logical_str, "%" PRIi64, logical);
+ ADD_ARG (argv, i, logical_str);
+ ADD_ARG (argv, i, fs_buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", fs, err);
+ return NULL;
+ }
+
+ /* Trim trailing '\n' */
+ len = strlen (out);
+ if (len > 0 && out[len-1] == '\n')
+ out[len-1] = '\0';
+
+ return out;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 0014c7d..7b7655d 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12521,6 +12521,16 @@ Get path on a btrfs filesystem for the given subvolume ID."
};
longdesc = "\
Get path on a btrfs filesystem for the given inode." };
+ { defaults with
+ name = "btrfs_inspect_internal_logical_resolve";
+ style = RString "path", [Int64 "logical"; Pathname
"fs"], [];
+ proc_nr = Some 453;
+ optional = Some "btrfs"; camel_name =
"BTRFSInspectInternalLogicalResolve";
+ test_excuse = "can't determine a valid logical address for test";
+ shortdesc = "get path for the given logical address";
+ longdesc = "\
+Get path on a btrfs filesystem for the logical address." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 8670c73..534b992 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-452
+453
--
2.1.0