Page MenuHomeFreeBSD

D42023.id128196.diff
No OneTemporary

D42023.id128196.diff

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));
@@ -260,6 +262,7 @@
flush_caches(void)
{
struct statfs *mntbuf;
+ struct statfs statbuf;
int i, nitems;
nitems = getmntinfo(&mntbuf, MNT_WAIT);
@@ -274,8 +277,23 @@
mntbuf[i].f_mntonname);
continue;
}
+ /*
+ * A direct map mountpoint may have been mounted over, in
+ * which case we can't MNT_UPDATE it. There's an obvious race
+ * condition remaining here, but that has to be fixed in the
+ * kernel.
+ */
+ if (statfs(mntbuf[i].f_mntonname, &statbuf) != 0) {
+ log_err(1, "cannot statfs %s", mntbuf[i].f_mntonname);
+ continue;
+ }
+ if (strcmp(statbuf.f_fstypename, "autofs") != 0) {
+ log_debugx("skipping %s, filesystem type is not autofs",
+ mntbuf[i].f_mntonname);
+ continue;
+ }
- flush_autofs(mntbuf[i].f_mntonname);
+ flush_autofs(mntbuf[i].f_mntonname, &mntbuf[i].f_fsid);
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, May 2, 6:38 PM (13 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17910074
Default Alt Text
D42023.id128196.diff (2 KB)

Event Timeline