summaryrefslogtreecommitdiffstats
path: root/cmd/mount_zfs
diff options
context:
space:
mode:
authornordaux <[email protected]>2012-02-13 05:44:20 +0200
committerBrian Behlendorf <[email protected]>2012-11-15 14:28:52 -0800
commit33364b15d302abfb2945129994b9cf42e61dc302 (patch)
tree7be015e83f34df3172b473400606a688848d466c /cmd/mount_zfs
parent54602c37718eca0dbeb668321edf5dfc41dcbe93 (diff)
mount.zfs: canonicalize mount point for mtab
Canonicalize the mount point passed to the mount.zfs helper. This way a clean path is always added to mtab which ensures the umount can properly locate and remove the entry. Test case: $ mkdir /mnt/foo $ mount -t zfs zpool/foo /mnt/../mnt/foo//// $ umount /mnt/foo $ cat /etc/mtab | grep zpool/foo zpool/foo /mnt/../mnt/foo//// zfs rw 0 0 Signed-off-by: Brian Behlendorf <[email protected]> Closes #573
Diffstat (limited to 'cmd/mount_zfs')
-rw-r--r--cmd/mount_zfs/mount_zfs.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c
index 0a69d69d7..6dd831d76 100644
--- a/cmd/mount_zfs/mount_zfs.c
+++ b/cmd/mount_zfs/mount_zfs.c
@@ -311,7 +311,8 @@ main(int argc, char **argv)
char mntopts[MNT_LINE_MAX] = { '\0' };
char badopt[MNT_LINE_MAX] = { '\0' };
char mtabopt[MNT_LINE_MAX] = { '\0' };
- char *dataset, *mntpoint;
+ char mntpoint[PATH_MAX];
+ char *dataset;
unsigned long mntflags = 0, zfsflags = 0, remount = 0;
int sloppy = 0, fake = 0, verbose = 0, nomtab = 0, zfsutil = 0;
int error, c;
@@ -367,7 +368,13 @@ main(int argc, char **argv)
}
dataset = parse_dataset(argv[0]);
- mntpoint = argv[1];
+
+ /* canonicalize the mount point */
+ if (realpath(argv[1], mntpoint) == NULL) {
+ (void) fprintf(stderr, gettext("filesystem '%s' cannot be "
+ "mounted due to a canonicalization failure.\n"), dataset);
+ return (MOUNT_SYSERR);
+ }
/* validate mount options and set mntflags */
error = parse_options(mntopts, &mntflags, &zfsflags, sloppy,