Use this macro to simplify the code. Signed-off-by: Wanlong Gao <gaowanlong@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..5d267e6 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; - } - } + DUP_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 c25bda1..1ce4026 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -8923,7 +8923,7 @@ call C<guestfs_max_disks>." }; { defaults with name = "xfs_info"; - style = RStruct ("info", "xfsinfo"), [Pathname "path"], []; + style = RStruct ("info", "xfsinfo"), [String "pathordevice"], []; proc_nr = Some 337; optional = Some "xfs"; tests = [ @@ -8937,8 +8937,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.2.249.g31c7954