aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mountd/mountd.c
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2019-05-14 22:00:47 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2019-05-14 22:00:47 +0000
commit711d44ee5644d5bd4e57b6e27d0e20421fff4632 (patch)
treed8ffec32b18855a62cbb9815d449be6c9734975c /usr.sbin/mountd/mountd.c
parent5a1e222bfda79fa1cb0276f9cba320900a0ccfc8 (diff)
downloadsrc-711d44ee5644d5bd4e57b6e27d0e20421fff4632.tar.gz
src-711d44ee5644d5bd4e57b6e27d0e20421fff4632.zip
Replace global list for grouplist with list(s) for each exportlist element.
In mountd.c, the grouplist structures are linked into a single global linked list headed by "grphead". The only use of this linked list is to free all list elements when the exportlist elements are also all being free'd at the time the exports are being reloaded. This patch replaces this one global linked list head with a list head in each exportlist structure, where the grouplist elements for that exported file system are linked. The only change is that now the grouplist elements are free'd with the associated exportlist element as they are free'd instead of all grouplist elements being free'd after the exportlist elements are free'd. This change should have no effect in practice. This is being done, since a future patch that will add a "-I" option for incrementally updating the exports in the kernel needs to know which grouplist elements are associated with each exported file system and having them linked into a list headed by the exportlist element does that. MFC after: 1 month
Notes
Notes: svn path=/head/; revision=347583
Diffstat (limited to 'usr.sbin/mountd/mountd.c')
-rw-r--r--usr.sbin/mountd/mountd.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 291a0f5f8404..ae143ade5ae4 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -114,6 +114,7 @@ struct dirlist {
struct exportlist {
struct dirlist *ex_dirl;
struct dirlist *ex_defdir;
+ struct grouplist *ex_grphead;
int ex_flag;
fsid_t ex_fs;
char *ex_fsdir;
@@ -235,7 +236,6 @@ static void terminate(int);
static struct exportlisthead exphead = SLIST_HEAD_INITIALIZER(&exphead);
static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(&mlhead);
-static struct grouplist *grphead;
static char *exnames_default[2] = { _PATH_EXPORTS, NULL };
static char **exnames;
static char **hosts = NULL;
@@ -455,7 +455,6 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- grphead = (struct grouplist *)NULL;
if (argc > 0)
exnames = argv;
else
@@ -1692,8 +1691,8 @@ get_exportlist_one(void)
*/
if (has_host) {
hang_dirp(dirhead, tgrp, ep, opt_flags);
- grp->gr_next = grphead;
- grphead = tgrp;
+ grp->gr_next = ep->ex_grphead;
+ ep->ex_grphead = tgrp;
} else {
hang_dirp(dirhead, (struct grouplist *)NULL, ep,
opt_flags);
@@ -1720,7 +1719,6 @@ nextline:
static void
get_exportlist(void)
{
- struct grouplist *grp, *tgrp;
struct export_args export;
struct iovec *iov;
struct statfs *mntbufp;
@@ -1743,14 +1741,6 @@ get_exportlist(void)
*/
free_exports(&exphead);
- grp = grphead;
- while (grp) {
- tgrp = grp;
- grp = grp->gr_next;
- free_grp(tgrp);
- }
- grphead = (struct grouplist *)NULL;
-
/*
* and the old V4 root dir.
*/
@@ -2448,6 +2438,7 @@ get_host(char *cp, struct grouplist *grp, struct grouplist *tgrp)
static void
free_exp(struct exportlist *ep)
{
+ struct grouplist *grp, *tgrp;
if (ep->ex_defdir) {
free_host(ep->ex_defdir->dp_hosts);
@@ -2458,6 +2449,12 @@ free_exp(struct exportlist *ep)
if (ep->ex_indexfile)
free(ep->ex_indexfile);
free_dir(ep->ex_dirl);
+ grp = ep->ex_grphead;
+ while (grp) {
+ tgrp = grp;
+ grp = grp->gr_next;
+ free_grp(tgrp);
+ }
free((caddr_t)ep);
}