diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1313,9 +1313,10 @@ struct vnode *rootvp; void *bufp; struct mount *mp; - int error, export_error, i, len; + int error, export_error, i, len, fsid_up_len; uint64_t flag; gid_t *grps; + fsid_t *fsid_up; bool vfs_suser_failed; ASSERT_VOP_ELOCKED(vp, __func__); @@ -1378,10 +1379,24 @@ VI_UNLOCK(vp); VOP_UNLOCK(vp); + rootvp = NULL; + + if (vfs_getopt(*optlist, "fsid", (void **)&fsid_up, + &fsid_up_len) == 0) { + if (fsid_up_len != sizeof(*fsid_up)) { + error = EINVAL; + goto end; + } + if (fsidcmp(&fsid_up, &mp->mnt_stat.f_fsid) != 0) { + error = ENOENT; + goto end; + } + vfs_deleteopt(*optlist, "fsid"); + } + vfs_op_enter(mp); vn_seqc_write_begin(vp); - rootvp = NULL; MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) { MNT_IUNLOCK(mp); diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -229,7 +229,7 @@ } static void -flush_autofs(const char *fspath) +flush_autofs(const char *fspath, const fsid_t *fsid) { struct iovec *iov = NULL; char errmsg[255]; @@ -242,6 +242,8 @@ __DECONST(void *, "autofs"), (size_t)-1); build_iovec(&iov, &iovlen, "fspath", __DECONST(void *, fspath), (size_t)-1); + build_iovec(&iov, &iovlen, "fsid", + __DECONST(void *, fsid), sizeof(*fsid)); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); @@ -275,7 +277,7 @@ continue; } - flush_autofs(mntbuf[i].f_mntonname); + flush_autofs(mntbuf[i].f_mntonname, &mntbuf[i].f_fsid); } }