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
This commit is contained in:
Robert Wing 2021-02-16 22:51:38 -09:00
parent 0dfbdd9fc2
commit 88e531f38c
4 changed files with 18 additions and 1 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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)
{

View file

@ -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);