summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mountd
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/mountd
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'usr.sbin/mountd')
-rw-r--r--usr.sbin/mountd/Makefile3
-rw-r--r--usr.sbin/mountd/mountd.88
-rw-r--r--usr.sbin/mountd/mountd.c55
3 files changed, 28 insertions, 38 deletions
diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile
index c141d8a..ab32fa3 100644
--- a/usr.sbin/mountd/Makefile
+++ b/usr.sbin/mountd/Makefile
@@ -11,7 +11,6 @@ WARNS?= 2
.PATH: ${MOUNT}
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.include <bsd.prog.mk>
diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8
index fe73743..4dbf5ff 100644
--- a/usr.sbin/mountd/mountd.8
+++ b/usr.sbin/mountd/mountd.8
@@ -38,7 +38,7 @@
mount requests
.Sh SYNOPSIS
.Nm
-.Op Fl 2delnorS
+.Op Fl 2delnrS
.Op Fl h Ar bindip
.Op Fl p Ar port
.Op Ar exportsfile ...
@@ -69,8 +69,7 @@ Output debugging information.
will not detach from the controlling terminal and will print
debugging messages to stderr.
.It Fl e
-The new NFS server that includes NFSv4 support is now the default, so this
-option is now a no-op and should be considered deprecated.
+Ignored; included for backward compatibility.
.It Fl h Ar bindip
Specify specific IP addresses to bind to for TCP and UDP requests.
This option may be specified multiple times.
@@ -98,9 +97,6 @@ This should only be specified if there are clients such as PC's,
that require it.
It will automatically clear the vfs.nfsrv.nfs_privport sysctl flag, which
controls if the kernel will accept NFS requests from reserved ports only.
-.It Fl o
-This flag forces the system to run the old NFS server, which does not
-have NFSv4 support in it.
.It Fl p Ar port
Force
.Nm
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 6e4085c..d916577 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -253,7 +253,6 @@ static int have_v6 = 1;
int v4root_phase = 0;
char v4root_dirpath[PATH_MAX + 1];
-int run_v4server = 1;
int has_publicfh = 0;
struct pidfh *pfh = NULL;
@@ -312,7 +311,7 @@ main(int argc, char **argv)
else
close(s);
- while ((c = getopt(argc, argv, "2deh:lnop:rS")) != -1)
+ while ((c = getopt(argc, argv, "2deh:lnp:rS")) != -1)
switch (c) {
case '2':
force_v2 = 1;
@@ -332,9 +331,6 @@ main(int argc, char **argv)
case 'l':
dolog = 1;
break;
- case 'o':
- run_v4server = 0;
- break;
case 'p':
endptr = NULL;
svcport = (in_port_t)strtoul(optarg, &endptr, 10);
@@ -371,19 +367,9 @@ main(int argc, char **argv)
usage();
};
- /*
- * Unless the "-o" option was specified, try and run "nfsd".
- * If "-o" was specified, try and run "nfsserver".
- */
- if (run_v4server > 0) {
- if (modfind("nfsd") < 0) {
- /* Not present in kernel, try loading it */
- if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
- errx(1, "NFS server is not available");
- }
- } else if (modfind("nfsserver") < 0) {
+ if (modfind("nfsd") < 0) {
/* Not present in kernel, try loading it */
- if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
+ if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
errx(1, "NFS server is not available");
}
@@ -627,7 +613,6 @@ create_service(struct netconfig *nconf)
/* Get mountd's address on this transport */
memset(&hints, 0, sizeof hints);
- hints.ai_flags = AI_PASSIVE;
hints.ai_family = si.si_af;
hints.ai_socktype = si.si_socktype;
hints.ai_protocol = si.si_proto;
@@ -644,6 +629,8 @@ create_service(struct netconfig *nconf)
sock_fd[sock_fdcnt++] = -1; /* Set invalid for now. */
mallocd_res = 0;
+ hints.ai_flags = AI_PASSIVE;
+
/*
* XXX - using RPC library internal functions.
*/
@@ -1423,6 +1410,9 @@ get_exportlist_one(void)
}
if (check_dirpath(cp) &&
statfs(cp, &fsb) >= 0) {
+ if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0)
+ syslog(LOG_ERR, "Warning: exporting of "
+ "automounted fs %s not supported", cp);
if (got_nondir) {
syslog(LOG_ERR, "dirs must be first");
getexp_err(ep, tgrp);
@@ -1696,8 +1686,7 @@ get_exportlist(void)
*/
bzero(&eargs, sizeof (eargs));
eargs.export.ex_flags = MNT_DELEXPORT;
- if (run_v4server > 0 &&
- nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&eargs) < 0 &&
+ if (nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&eargs) < 0 &&
errno != ENOENT)
syslog(LOG_ERR, "Can't delete exports for V4:");
@@ -1731,6 +1720,12 @@ get_exportlist(void)
}
/*
+ * We do not need to delete "export" flag from
+ * filesystems that do not have it set.
+ */
+ if (!(fsp->f_flags & MNT_EXPORTED))
+ continue;
+ /*
* Do not delete export for network filesystem by
* passing "export" arg to nmount().
* It only makes sense to do this for local filesystems.
@@ -1746,8 +1741,12 @@ get_exportlist(void)
iov[5].iov_len = strlen(fsp->f_mntfromname) + 1;
errmsg[0] = '\0';
+ /*
+ * EXDEV is returned when path exists but is not a
+ * mount point. May happens if raced with unmount.
+ */
if (nmount(iov, iovlen, fsp->f_flags) < 0 &&
- errno != ENOENT && errno != ENOTSUP) {
+ errno != ENOENT && errno != ENOTSUP && errno != EXDEV) {
syslog(LOG_ERR,
"can't delete exports for %s: %m %s",
fsp->f_mntonname, errmsg);
@@ -1792,7 +1791,7 @@ get_exportlist(void)
/*
* If there was no public fh, clear any previous one set.
*/
- if (run_v4server > 0 && has_publicfh == 0)
+ if (has_publicfh == 0)
(void) nfssvc(NFSSVC_NOPUBLICFH, NULL);
/* Resume the nfsd. If they weren't suspended, this is harmless. */
@@ -2389,7 +2388,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
{
struct statfs fsb1;
struct addrinfo *ai;
- struct export_args ea, *eap;
+ struct export_args *eap;
char errmsg[255];
char *cp;
int done;
@@ -2399,10 +2398,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
int ret;
struct nfsex_args nfsea;
- if (run_v4server > 0)
- eap = &nfsea.export;
- else
- eap = &ea;
+ eap = &nfsea.export;
cp = NULL;
savedc = '\0';
@@ -2482,8 +2478,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
*/
if (v4root_phase == 2) {
nfsea.fspec = v4root_dirpath;
- if (run_v4server > 0 &&
- nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&nfsea) < 0) {
+ if (nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&nfsea) < 0) {
syslog(LOG_ERR, "Exporting V4: failed");
return (2);
}
@@ -2572,7 +2567,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
* If this is the public directory, get the file handle
* and load it into the kernel via the nfssvc() syscall.
*/
- if (run_v4server > 0 && (exflags & MNT_EXPUBLIC) != 0) {
+ if ((exflags & MNT_EXPUBLIC) != 0) {
fhandle_t fh;
char *public_name;
OpenPOWER on IntegriCloud