aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gierth <andrew@tao146.riddles.org.uk>2023-07-10 15:09:56 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-10-24 00:47:20 +0000
commit29dae977ae9b01f429ae876743514da92ee8ecf4 (patch)
tree0ef6377a360f88e45349319323ca2fee91d4bc8d
parent321af2d24da0a54612f473afca2d3fec5820132f (diff)
automount: check for mounted-over autofs instances on flush
PR: 272446 (cherry picked from commit 21b8e363c4eb24c0a5659101603cc08a86d87759)
-rw-r--r--usr.sbin/autofs/automount.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c
index 188bbc3a040f..cee647cb4e2c 100644
--- a/usr.sbin/autofs/automount.c
+++ b/usr.sbin/autofs/automount.c
@@ -260,6 +260,7 @@ static void
flush_caches(void)
{
struct statfs *mntbuf;
+ struct statfs statbuf;
int i, nitems;
nitems = getmntinfo(&mntbuf, MNT_WAIT);
@@ -274,6 +275,21 @@ flush_caches(void)
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);
}