]> git.proxmox.com Git - mirror_zfs.git/commitdiff
mount_zfs: print strerror instead of errno for error reporting
authorÉrico Nogueira Rolim <34201958+ericonr@users.noreply.github.com>
Thu, 10 Dec 2020 05:24:59 +0000 (02:24 -0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 23 Dec 2020 22:34:59 +0000 (14:34 -0800)
Tracking down an error message with the errno value can be difficult,
using strerror makes the error message clearer.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Érico Rolim <erico.erc@gmail.com>
Closes #11303

cmd/mount_zfs/mount_zfs.c

index 0e7810703e26d22de9a7a745adbbec30b32c29ef..ca39d228479e71946c0c6f95461dfc705fdeb990 100644 (file)
@@ -110,8 +110,8 @@ mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
        if (!fp) {
                (void) fprintf(stderr, gettext(
                    "filesystem '%s' was mounted, but /etc/mtab "
-                   "could not be opened due to error %d\n"),
-                   dataset, errno);
+                   "could not be opened due to error: %s\n"),
+                   dataset, strerror(errno));
                return (MOUNT_FILEIO);
        }
 
@@ -119,8 +119,8 @@ mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
        if (error) {
                (void) fprintf(stderr, gettext(
                    "filesystem '%s' was mounted, but /etc/mtab "
-                   "could not be updated due to error %d\n"),
-                   dataset, errno);
+                   "could not be updated due to error: %s\n"),
+                   dataset, strerror(errno));
                return (MOUNT_FILEIO);
        }
 
@@ -200,8 +200,8 @@ main(int argc, char **argv)
        /* canonicalize the mount point */
        if (realpath(argv[1], mntpoint) == NULL) {
                (void) fprintf(stderr, gettext("filesystem '%s' cannot be "
-                   "mounted at '%s' due to canonicalization error %d.\n"),
-                   dataset, argv[1], errno);
+                   "mounted at '%s' due to canonicalization error: %s\n"),
+                   dataset, argv[1], strerror(errno));
                return (MOUNT_SYSERR);
        }