diff options
author | Robert Wing <rew@FreeBSD.org> | 2021-02-17 07:51:38 +0000 |
---|---|---|
committer | Robert Wing <rew@FreeBSD.org> | 2021-05-11 23:48:44 +0000 |
commit | 6fa8a157705debef78e86de378f8a929207d62dc (patch) | |
tree | e67906f70d061039ee7db408d0a449735cea81f0 | |
parent | 09db9de2fea847de2ebc35acd7333c97390dc8f8 (diff) | |
download | src-6fa8a157705debef78e86de378f8a929207d62dc.tar.gz src-6fa8a157705debef78e86de378f8a929207d62dc.zip |
autofs: best effort to maintain mounttab and mountdtab
When an automounted filesystem is successfully unmounted, call
rpc.umntall(8) with the -k flag.
rpc.umntall(8) is used to clean up /var/db/mounttab on the client and
/var/db/mountdtab on the server. This is only useful for NFSv3.
PR: 251906
Reviewed by: trasz
Differential Revision: https://reviews.freebsd.org/D27801
(cherry picked from commit 88e531f38c2412bf030f4e8dd563efc45b70797e)
-rw-r--r-- | usr.sbin/autofs/automount.c | 2 | ||||
-rw-r--r-- | usr.sbin/autofs/autounmountd.c | 3 | ||||
-rw-r--r-- | usr.sbin/autofs/common.c | 13 | ||||
-rw-r--r-- | usr.sbin/autofs/common.h | 1 |
4 files changed, 18 insertions, 1 deletions
diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index e28129eee5b8..cd29c910bce2 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -80,6 +80,8 @@ unmount_by_statfs(const struct statfs *sb, bool force) free(fsid_str); if (error != 0) log_warn("cannot unmount %s", sb->f_mntonname); + else + rpc_umntall(); return (error); } diff --git a/usr.sbin/autofs/autounmountd.c b/usr.sbin/autofs/autounmountd.c index 92bc8a03c96f..33b3a366cb8d 100644 --- a/usr.sbin/autofs/autounmountd.c +++ b/usr.sbin/autofs/autounmountd.c @@ -170,7 +170,8 @@ unmount_by_fsid(const fsid_t fsid, const char *mountpoint) log_warn("cannot unmount %s (%s)", mountpoint, fsid_str); } - } + } else + rpc_umntall(); free(fsid_str); diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 7c8df4205a86..4581e5c4f2f9 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -1204,6 +1204,19 @@ lesser_daemon(void) } } +/* + * Applicable to NFSv3 only, see rpc.umntall(8). + */ +void +rpc_umntall(void) +{ + FILE *f; + + f = auto_popen("rpc.umntall", "-k", NULL); + assert(f != NULL); + auto_pclose(f); +} + int main(int argc, char **argv) { diff --git a/usr.sbin/autofs/common.h b/usr.sbin/autofs/common.h index 34257c1caeff..e68a0be5f7c8 100644 --- a/usr.sbin/autofs/common.h +++ b/usr.sbin/autofs/common.h @@ -96,6 +96,7 @@ char *defined_expand(const char *string); void defined_init(void); void defined_parse_and_add(char *def); void lesser_daemon(void); +void rpc_umntall(void); int main_automount(int argc, char **argv); int main_automountd(int argc, char **argv); |