Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/mountd Split get_exportlist() into get_exportlist()...
details: https://anonhg.NetBSD.org/src/rev/b3c56e1f2a42
branches: trunk
changeset: 952737:b3c56e1f2a42
user: hannken <hannken%NetBSD.org@localhost>
date: Tue Feb 16 09:58:35 2021 +0000
description:
Split get_exportlist() into get_exportlist() and get_exportlist_one()
in preparation to support multiple input files.
No functional change intended.
diffstat:
usr.sbin/mountd/mountd.c | 142 +++++++++++++++++++++++++---------------------
1 files changed, 77 insertions(+), 65 deletions(-)
diffs (182 lines):
diff -r fe4bf27d352b -r b3c56e1f2a42 usr.sbin/mountd/mountd.c
--- a/usr.sbin/mountd/mountd.c Tue Feb 16 09:56:32 2021 +0000
+++ b/usr.sbin/mountd/mountd.c Tue Feb 16 09:58:35 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mountd.c,v 1.132 2020/06/17 00:16:21 kamil Exp $ */
+/* $NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: mountd.c,v 1.132 2020/06/17 00:16:21 kamil Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $");
#endif
#endif /* not lint */
@@ -1009,81 +1009,22 @@
}
-/*
- * Get the export list
- */
-/* ARGSUSED */
-void
-get_exportlist(int n)
+static void
+get_exportlist_one(FILE *exp_file)
{
struct exportlist *ep, *ep2;
struct grouplist *grp, *tgrp;
struct exportlist **epp;
struct dirlist *dirhead;
- struct statvfs fsb, *fsp;
+ struct statvfs fsb;
struct addrinfo *ai;
struct uucred anon;
char *cp, *endcp, *dirp, savedc;
- int has_host, exflags, got_nondir, dirplen, num, i;
- FILE *exp_file;
+ int has_host, exflags, got_nondir, dirplen;
char *line;
size_t lineno = 0, len;
-
- /*
- * First, get rid of the old list
- */
- ep = exphead;
- while (ep) {
- ep2 = ep;
- ep = ep->ex_next;
- free_exp(ep2);
- }
- exphead = NULL;
-
dirp = NULL;
- dirplen = 0;
- grp = grphead;
- while (grp) {
- tgrp = grp;
- grp = grp->gr_next;
- free_grp(tgrp);
- }
- grphead = NULL;
-
- /*
- * And delete exports that are in the kernel for all local
- * file systems.
- */
- num = getmntinfo(&fsp, MNT_NOWAIT);
- for (i = 0; i < num; i++) {
- struct mountd_exports_list mel;
-
- /* Delete all entries from the export list. */
- mel.mel_path = fsp->f_mntonname;
- mel.mel_nexports = 0;
- if (nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1 &&
- errno != EOPNOTSUPP)
- syslog(LOG_ERR, "Can't delete exports for %s (%m)",
- fsp->f_mntonname);
-
- fsp++;
- }
-
- /*
- * Read in the exports file and build the list, calling
- * mount() as we go along to push the export rules into the kernel.
- */
- if ((exp_file = fopen(exname, "r")) == NULL) {
- /*
- * Don't exit here; we can still reload the config
- * after a SIGHUP.
- */
- if (mountd_debug)
- (void)fprintf(stderr, "Can't open %s: %s\n", exname,
- strerror(errno));
- return;
- }
dirhead = NULL;
while ((line = fparseln(exp_file, &len, &lineno, NULL, 0)) != NULL) {
if (mountd_debug)
@@ -1262,6 +1203,77 @@
}
free(line);
}
+}
+
+/*
+ * Get the export list
+ */
+/* ARGSUSED */
+void
+get_exportlist(int n)
+{
+ struct exportlist *ep, *ep2;
+ struct grouplist *grp, *tgrp;
+ struct statvfs *fsp;
+ int num, i;
+ FILE *exp_file;
+
+
+ /*
+ * First, get rid of the old list
+ */
+ ep = exphead;
+ while (ep) {
+ ep2 = ep;
+ ep = ep->ex_next;
+ free_exp(ep2);
+ }
+ exphead = NULL;
+
+ grp = grphead;
+ while (grp) {
+ tgrp = grp;
+ grp = grp->gr_next;
+ free_grp(tgrp);
+ }
+ grphead = NULL;
+
+ /*
+ * And delete exports that are in the kernel for all local
+ * file systems.
+ */
+ num = getmntinfo(&fsp, MNT_NOWAIT);
+ for (i = 0; i < num; i++) {
+ struct mountd_exports_list mel;
+
+ /* Delete all entries from the export list. */
+ mel.mel_path = fsp->f_mntonname;
+ mel.mel_nexports = 0;
+ if (nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1 &&
+ errno != EOPNOTSUPP)
+ syslog(LOG_ERR, "Can't delete exports for %s (%m)",
+ fsp->f_mntonname);
+
+ fsp++;
+ }
+
+ /*
+ * Read in the exports file and build the list, calling
+ * mount() as we go along to push the export rules into the kernel.
+ */
+ if ((exp_file = fopen(exname, "r")) == NULL) {
+ /*
+ * Don't exit here; we can still reload the config
+ * after a SIGHUP.
+ */
+ if (mountd_debug)
+ (void)fprintf(stderr, "Can't open %s: %s\n", exname,
+ strerror(errno));
+ return;
+ }
+
+ get_exportlist_one(exp_file);
+
(void)fclose(exp_file);
}
Home |
Main Index |
Thread Index |
Old Index