Skip to content

Commit 957f968

Browse files
authored
mount_zfs: print strerror instead of errno for error reporting
Tracking down an error message with the errno value can be difficult, using strerror makes the error message clearer. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Érico Rolim <[email protected]> Closes #11303
1 parent 1e4667a commit 957f968

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cmd/mount_zfs/mount_zfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
110110
if (!fp) {
111111
(void) fprintf(stderr, gettext(
112112
"filesystem '%s' was mounted, but /etc/mtab "
113-
"could not be opened due to error %d\n"),
114-
dataset, errno);
113+
"could not be opened due to error: %s\n"),
114+
dataset, strerror(errno));
115115
return (MOUNT_FILEIO);
116116
}
117117

118118
error = addmntent(fp, &mnt);
119119
if (error) {
120120
(void) fprintf(stderr, gettext(
121121
"filesystem '%s' was mounted, but /etc/mtab "
122-
"could not be updated due to error %d\n"),
123-
dataset, errno);
122+
"could not be updated due to error: %s\n"),
123+
dataset, strerror(errno));
124124
return (MOUNT_FILEIO);
125125
}
126126

@@ -200,8 +200,8 @@ main(int argc, char **argv)
200200
/* canonicalize the mount point */
201201
if (realpath(argv[1], mntpoint) == NULL) {
202202
(void) fprintf(stderr, gettext("filesystem '%s' cannot be "
203-
"mounted at '%s' due to canonicalization error %d.\n"),
204-
dataset, argv[1], errno);
203+
"mounted at '%s' due to canonicalization error: %s\n"),
204+
dataset, argv[1], strerror(errno));
205205
return (MOUNT_SYSERR);
206206
}
207207

0 commit comments

Comments
 (0)