From: Richard W.M. Jones Date: Mon, 28 Nov 2011 19:12:44 +0000 (+0000) Subject: fish: When -m option fails, canonicalize device names that are printed. X-Git-Tag: 1.14.5~18 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=3b782ee5cb517cd30e87f8603bc3b130fdf8b421;p=libguestfs.git fish: When -m option fails, canonicalize device names that are printed. The error message now looks like this: guestfish: '/dev/vda6' could not be mounted. Did you mean one of these? /dev/sda1 (ext4) /dev/vg_f15x32/lv_root (ext4) /dev/vg_f15x32/lv_swap (swap) Note that '/dev/sda1' has been canonicalized. (cherry picked from commit f5bfc68fdb3e25b9d75c65e3f5e88983584b25ed) --- diff --git a/fish/options.c b/fish/options.c index f6cc61f..48c8e1c 100644 --- a/fish/options.c +++ b/fish/options.c @@ -21,6 +21,8 @@ #include #include +#include "c-ctype.h" + #include "guestfs.h" #include "options.h" @@ -98,6 +100,7 @@ add_drives (struct drv *drv, char next_drive) } static void display_mountpoints_on_failure (const char *mp_device); +static void canonical_device_name (char *dev); /* List is built in reverse order, so mount them in reverse order. */ void @@ -150,6 +153,7 @@ display_mountpoints_on_failure (const char *mp_device) program_name, mp_device); for (i = 0; fses[i] != NULL; i += 2) { + canonical_device_name (fses[i]); fprintf (stderr, "\t%s (%s)\n", fses[i], fses[i+1]); free (fses[i]); free (fses[i+1]); @@ -158,6 +162,17 @@ display_mountpoints_on_failure (const char *mp_device) free (fses); } +static void +canonical_device_name (char *dev) +{ + if (STRPREFIX (dev, "/dev/") && + (dev[5] == 'h' || dev[5] == 'v') && + dev[6] == 'd' && + c_isalpha (dev[7]) && + (c_isdigit (dev[8]) || dev[8] == '\0')) + dev[5] = 's'; +} + void free_drives (struct drv *drv) {