Use this macro to simplify the code.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/xfs.c | 17 +++--------------
generator/generator_actions.ml | 6 +++---
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/daemon/xfs.c b/daemon/xfs.c
index 3efc14f..6736363 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -311,7 +311,7 @@ error:
}
guestfs_int_xfsinfo *
-do_xfs_info (const char *path)
+do_xfs_info (const char *pathordevice)
{
int r;
char *buf;
@@ -319,19 +319,8 @@ do_xfs_info (const char *path)
char **lines = NULL;
guestfs_int_xfsinfo *ret = NULL;
- if (do_is_dir (path)) {
- buf = sysroot_path (path);
- if (!buf) {
- reply_with_perror ("malloc");
- return NULL;
- }
- } else {
- buf = strdup(path);
- if (!buf) {
- reply_with_perror ("strdup");
- return NULL;
- }
- }
+ STRDUP_RESOLVE_DEVICE_OR_PATH (pathordevice, buf, ,
+ {free (buf); return NULL;});
r = command (&out, &err, "xfs_info", buf, NULL);
free (buf);
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 74f76bb..feb1162 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -8930,7 +8930,7 @@ call C<guestfs_max_disks>." };
{ defaults with
name = "xfs_info";
- style = RStruct ("info", "xfsinfo"), [Pathname "path"],
[];
+ style = RStruct ("info", "xfsinfo"), [Dev_or_Path
"pathordevice"], [];
proc_nr = Some 337;
optional = Some "xfs";
tests = [
@@ -8944,8 +8944,8 @@ call C<guestfs_max_disks>." };
];
shortdesc = "get geometry of XFS filesystem";
longdesc = "\
-C<path> is a mounted XFS filesystem. This command returns the
-geometry of the filesystem.
+C<pathordevice> is a mounted XFS filesystem. This command returns
+the geometry of the filesystem.
The returned struct contains geometry information. Missing
fields are returned as C<-1> (for numeric fields) or empty
--
1.7.11.3.287.ge771946