From f5bfc68fdb3e25b9d75c65e3f5e88983584b25ed Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 28 Nov 2011 19:12:44 +0000 Subject: [PATCH] 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. --- fish/options.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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) { -- 1.8.3.1