From f4094b91d2cdb7635c79269f4534f18a153a4828 Mon Sep 17 00:00:00 2001 From: Wanlong Gao Date: Tue, 24 Jul 2012 16:47:22 +0800 Subject: xfs_info: resolve device when doing xfs_info on a device Resolve device first, like do_umount. Use Dev_or_Path. Signed-off-by: Wanlong Gao --- daemon/xfs.c | 21 ++++++++------------- generator/generator_actions.ml | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/daemon/xfs.c b/daemon/xfs.c index 3efc14f7..e0f0062a 100644 --- a/daemon/xfs.c +++ b/daemon/xfs.c @@ -311,26 +311,21 @@ error: } guestfs_int_xfsinfo * -do_xfs_info (const char *path) +do_xfs_info (const char *pathordevice) { int r; char *buf; char *out = NULL, *err = NULL; char **lines = NULL; guestfs_int_xfsinfo *ret = NULL; + int is_dev; - 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; - } + is_dev = STREQLEN (pathordevice, "/dev/", 5); + buf = is_dev ? strdup (pathordevice) + : sysroot_path (pathordevice); + if (buf == NULL) { + reply_with_perror ("malloc"); + return NULL; } r = command (&out, &err, "xfs_info", buf, NULL); diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index d512d7ce..4e18b4ee 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -8954,7 +8954,7 @@ call C." }; { 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 = [ -- cgit