fish/mount: Add better error message when -m (mount) fails (RHBZ#824043).

(cherry picked from commit ee9ab52bc3)
This commit is contained in:
Richard W.M. Jones
2012-05-24 14:50:20 +01:00
parent 59373c3947
commit dc8250dfdc
2 changed files with 16 additions and 7 deletions

View File

@@ -111,7 +111,8 @@ do_mount_vfs (const char *options, const char *vfstype,
"mount", "-o", options, device, mp, NULL);
free (mp);
if (r == -1) {
reply_with_error ("%s on %s: %s", device, mountpoint, error);
reply_with_error ("%s on %s (options: '%s'): %s",
device, mountpoint, options, error);
free (error);
return -1;
}

View File

@@ -102,7 +102,7 @@ add_drives (struct drv *drv, char next_drive)
return next_drive;
}
static void display_mountpoints_on_failure (const char *mp_device);
static void display_mountpoints_on_failure (const char *mp_device, const char *user_supplied_options);
static void canonical_device_name (char *dev);
/* List is built in reverse order, so mount them in reverse order. */
@@ -124,7 +124,7 @@ mount_mps (struct mp *mp)
r = guestfs_mount_options (g, options, mp->device, mp->mountpoint);
if (r == -1) {
display_mountpoints_on_failure (mp->device);
display_mountpoints_on_failure (mp->device, mp->options);
exit (EXIT_FAILURE);
}
}
@@ -134,7 +134,8 @@ mount_mps (struct mp *mp)
* message listing the mountpoints.
*/
static void
display_mountpoints_on_failure (const char *mp_device)
display_mountpoints_on_failure (const char *mp_device,
const char *user_supplied_options)
{
char **fses;
size_t i;
@@ -147,13 +148,20 @@ display_mountpoints_on_failure (const char *mp_device)
return;
}
fprintf (stderr,
_("%s: '%s' could not be mounted. Did you mean one of these?\n"),
fprintf (stderr, _("%s: '%s' could not be mounted.\n"),
program_name, mp_device);
if (user_supplied_options)
fprintf (stderr, _("%s: Check mount(8) man page to ensure options '%s'\n"
"%s: are supported by the filesystem that is being mounted.\n"),
program_name, user_supplied_options, program_name);
fprintf (stderr, _("%s: Did you mean to mount one of these filesystems?\n"),
program_name);
for (i = 0; fses[i] != NULL; i += 2) {
canonical_device_name (fses[i]);
fprintf (stderr, "\t%s (%s)\n", fses[i], fses[i+1]);
fprintf (stderr, "%s: \t%s (%s)\n", program_name, fses[i], fses[i+1]);
free (fses[i]);
free (fses[i+1]);
}