aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorslashdd <[email protected]>2016-09-20 13:07:58 -0400
committerBrian Behlendorf <[email protected]>2016-09-20 10:07:58 -0700
commit792517389fad5c495a2738b61c2e9c65dedaaa9a (patch)
tree5eef2ac0ecc1db47b3f11ec4ba12a97b6427e1b7 /cmd
parent25e2ab16be74cb37934e6736a1dc10fd50a00c56 (diff)
Change /etc/mtab to /proc/self/mounts
Fix misleading error message: "The /dev/zfs device is missing and must be created.", if /etc/mtab is missing. Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Eric Desrochers <[email protected]> Closes #4680 Closes #5029
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mount_zfs/mount_zfs.c14
-rw-r--r--cmd/zfs/zfs_main.c23
-rw-r--r--cmd/zinject/translate.c2
3 files changed, 20 insertions, 19 deletions
diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c
index b78c91c7c..f6631a527 100644
--- a/cmd/mount_zfs/mount_zfs.c
+++ b/cmd/mount_zfs/mount_zfs.c
@@ -294,11 +294,11 @@ mtab_is_writeable(void)
struct stat st;
int error, fd;
- error = lstat(MNTTAB, &st);
+ error = lstat("/etc/mtab", &st);
if (error || S_ISLNK(st.st_mode))
return (0);
- fd = open(MNTTAB, O_RDWR | O_CREAT, 0644);
+ fd = open("/etc/mtab", O_RDWR | O_CREAT, 0644);
if (fd < 0)
return (0);
@@ -320,21 +320,21 @@ mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
mnt.mnt_freq = 0;
mnt.mnt_passno = 0;
- fp = setmntent(MNTTAB, "a+");
+ fp = setmntent("/etc/mtab", "a+");
if (!fp) {
(void) fprintf(stderr, gettext(
- "filesystem '%s' was mounted, but %s "
+ "filesystem '%s' was mounted, but /etc/mtab "
"could not be opened due to error %d\n"),
- dataset, MNTTAB, errno);
+ dataset, errno);
return (MOUNT_FILEIO);
}
error = addmntent(fp, &mnt);
if (error) {
(void) fprintf(stderr, gettext(
- "filesystem '%s' was mounted, but %s "
+ "filesystem '%s' was mounted, but /etc/mtab "
"could not be updated due to error %d\n"),
- dataset, MNTTAB, errno);
+ dataset, errno);
return (MOUNT_FILEIO);
}
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index dd165da0e..cca52dbe7 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -6146,9 +6146,10 @@ share_mount(int op, int argc, char **argv)
}
/*
- * When mount is given no arguments, go through /etc/mtab and
- * display any active ZFS mounts. We hide any snapshots, since
- * they are controlled automatically.
+ * When mount is given no arguments, go through
+ * /proc/self/mounts and display any active ZFS mounts.
+ * We hide any snapshots, since they are controlled
+ * automatically.
*/
/* Reopen MNTTAB to prevent reading stale data from open file */
@@ -6228,8 +6229,8 @@ unshare_unmount_compare(const void *larg, const void *rarg, void *unused)
/*
* Convenience routine used by zfs_do_umount() and manual_unmount(). Given an
- * absolute path, find the entry /etc/mtab, verify that its a ZFS filesystem,
- * and unmount it appropriately.
+ * absolute path, find the entry /proc/self/mounts, verify that its a
+ * ZFS filesystems, and unmount it appropriately.
*/
static int
unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
@@ -6242,7 +6243,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
ino_t path_inode;
/*
- * Search for the path in /etc/mtab. Rather than looking for the
+ * Search for the path in /proc/self/mounts. Rather than looking for the
* specific path, which can be fooled by non-standard paths (i.e. ".."
* or "//"), we stat() the path and search for the corresponding
* (major,minor) device pair.
@@ -6273,8 +6274,8 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
"currently mounted\n"), cmdname, path);
return (1);
}
- (void) fprintf(stderr, gettext("warning: %s not in mtab\n"),
- path);
+ (void) fprintf(stderr, gettext("warning: %s not in"
+ "/proc/self/mounts\n"), path);
if ((ret = umount2(path, flags)) != 0)
(void) fprintf(stderr, gettext("%s: %s\n"), path,
strerror(errno));
@@ -6385,9 +6386,9 @@ unshare_unmount(int op, int argc, char **argv)
/*
* We could make use of zfs_for_each() to walk all datasets in
* the system, but this would be very inefficient, especially
- * since we would have to linearly search /etc/mtab for each
- * one. Instead, do one pass through /etc/mtab looking for
- * zfs entries and call zfs_unmount() for each one.
+ * since we would have to linearly search /proc/self/mounts for
+ * each one. Instead, do one pass through /proc/self/mounts
+ * looking for zfs entries and call zfs_unmount() for each one.
*
* Things get a little tricky if the administrator has created
* mountpoints beneath other ZFS filesystems. In this case, we
diff --git a/cmd/zinject/translate.c b/cmd/zinject/translate.c
index 5cc9d9fdc..adace72ff 100644
--- a/cmd/zinject/translate.c
+++ b/cmd/zinject/translate.c
@@ -120,7 +120,7 @@ parse_pathname(const char *inpath, char *dataset, char *relpath,
#else
if ((fp = fopen(MNTTAB, "r")) == NULL) {
#endif
- (void) fprintf(stderr, "cannot open /etc/mtab\n");
+ (void) fprintf(stderr, "cannot open %s\n", MNTTAB);
return (-1);
}