cd87151
diff --git a/support/include/nfs/nfs.h b/support/include/nfs/nfs.h
cd87151
index 00b0028..a64eb0a 100644
cd87151
--- a/support/include/nfs/nfs.h
cd87151
+++ b/support/include/nfs/nfs.h
cd87151
@@ -42,14 +42,21 @@ struct nfs_fh_old {
cd87151
 #define NFSCTL_GETFD		7	/* get an fh by path (used by mountd) */
cd87151
 #define NFSCTL_GETFS		8	/* get an fh by path with max size (used by mountd) */
cd87151
 
cd87151
+#define NFSCTL_UDPBIT		      (1 << (17 - 1))
cd87151
+#define NFSCTL_TCPBIT		      (1 << (18 - 1))
cd87151
+
cd87151
 #define NFSCTL_VERUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1))) 
cd87151
-#define NFSCTL_UDPUNSET(_cltbits)     ((_cltbits) &= ~(1 << (17 - 1))) 
cd87151
-#define NFSCTL_TCPUNSET(_cltbits)     ((_cltbits) &= ~(1 << (18 - 1))) 
cd87151
+#define NFSCTL_UDPUNSET(_cltbits)     ((_cltbits) &= ~NFSCTL_UDPBIT) 
cd87151
+#define NFSCTL_TCPUNSET(_cltbits)     ((_cltbits) &= ~NFSCTL_TCPBIT) 
cd87151
 
cd87151
 #define NFSCTL_VERISSET(_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1))) 
cd87151
-#define NFSCTL_UDPISSET(_cltbits)     ((_cltbits) & (1 << (17 - 1))) 
cd87151
-#define NFSCTL_TCPISSET(_cltbits)     ((_cltbits) & (1 << (18 - 1))) 
cd87151
+#define NFSCTL_UDPISSET(_cltbits)     ((_cltbits) & NFSCTL_UDPBIT) 
cd87151
+#define NFSCTL_TCPISSET(_cltbits)     ((_cltbits) & NFSCTL_TCPBIT) 
cd87151
+
cd87151
+#define NFSCTL_UDPSET(_cltbits)       ((_cltbits) |= NFSCTL_UDPBIT)
cd87151
+#define NFSCTL_TCPSET(_cltbits)       ((_cltbits) |= NFSCTL_TCPBIT)
cd87151
 
cd87151
+#define NFSCTL_ANYPROTO(_cltbits)     ((_cltbits) & (NFSCTL_UDPBIT | NFSCTL_TCPBIT))
cd87151
 #define NFSCTL_ALLBITS (~0)
cd87151
 
cd87151
 /* SVC */
cd87151
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
cd87151
index ae98650..537a31e 100644
cd87151
--- a/support/include/nfslib.h
cd87151
+++ b/support/include/nfslib.h
cd87151
@@ -130,7 +130,6 @@ int			wildmat(char *text, char *pattern);
cd87151
  * nfsd library functions.
cd87151
  */
cd87151
 int			nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
cd87151
-int			nfssvc(int port, int nrservs, unsigned int versbits, int minorvers4, unsigned int portbits, char *haddr);
cd87151
 int			nfsaddclient(struct nfsctl_client *clp);
cd87151
 int			nfsdelclient(struct nfsctl_client *clp);
cd87151
 int			nfsexport(struct nfsctl_export *exp);
cd87151
diff --git a/support/nfs/Makefile.am b/support/nfs/Makefile.am
cd87151
index 86f52a1..096f56d 100644
cd87151
--- a/support/nfs/Makefile.am
cd87151
+++ b/support/nfs/Makefile.am
cd87151
@@ -2,7 +2,7 @@
cd87151
 
cd87151
 noinst_LIBRARIES = libnfs.a
cd87151
 libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \
cd87151
-		   xlog.c xcommon.c wildmat.c nfssvc.c nfsclient.c \
cd87151
+		   xlog.c xcommon.c wildmat.c nfsclient.c \
cd87151
 		   nfsexport.c getfh.c nfsctl.c rpc_socket.c getport.c \
cd87151
 		   svc_socket.c cacheio.c closeall.c nfs_mntent.c
cd87151
 
cd87151
diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c
cd87151
deleted file mode 100644
cd87151
index 33c15a7..0000000
cd87151
--- a/support/nfs/nfssvc.c
cd87151
+++ /dev/null
cd87151
@@ -1,187 +0,0 @@
cd87151
-/*
cd87151
- * support/nfs/nfssvc.c
cd87151
- *
cd87151
- * Run an NFS daemon.
cd87151
- *
cd87151
- * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
cd87151
- */
cd87151
-
cd87151
-#ifdef HAVE_CONFIG_H
cd87151
-#include <config.h>
cd87151
-#endif
cd87151
-
cd87151
-#include <sys/socket.h>
cd87151
-#include <netinet/in.h>
cd87151
-#include <arpa/inet.h>
cd87151
-#include <unistd.h>
cd87151
-#include <fcntl.h>
cd87151
-#include <errno.h>
cd87151
-#include <syslog.h>
cd87151
-
cd87151
-
cd87151
-#include "nfslib.h"
cd87151
-
cd87151
-#define NFSD_PORTS_FILE     "/proc/fs/nfsd/portlist"
cd87151
-#define NFSD_VERS_FILE    "/proc/fs/nfsd/versions"
cd87151
-#define NFSD_THREAD_FILE  "/proc/fs/nfsd/threads"
cd87151
-
cd87151
-static void
cd87151
-nfssvc_setfds(int port, unsigned int ctlbits, char *haddr)
cd87151
-{
cd87151
-	int fd, n, on=1;
cd87151
-	char buf[BUFSIZ];
cd87151
-	int udpfd = -1, tcpfd = -1;
cd87151
-	struct sockaddr_in sin;
cd87151
-
cd87151
-	fd = open(NFSD_PORTS_FILE, O_RDONLY);
cd87151
-	if (fd < 0)
cd87151
-		return;
cd87151
-	n = read(fd, buf, BUFSIZ);
cd87151
-	close(fd);
cd87151
-	if (n != 0)
cd87151
-		return;
cd87151
-	/* there are no ports currently open, so it is safe to
cd87151
-	 * try to open some and pass them through.
cd87151
-	 * Note: If the user explicitly asked for 'udp', then
cd87151
-	 * we should probably check if that is open, and should
cd87151
-	 * open it if not.  However we don't yet.  All sockets
cd87151
-	 * have to be opened when the first daemon is started.
cd87151
-	 */
cd87151
-	fd = open(NFSD_PORTS_FILE, O_WRONLY);
cd87151
-	if (fd < 0)
cd87151
-		return;
cd87151
-	sin.sin_family = AF_INET;
cd87151
-	sin.sin_port   = htons(port);
cd87151
-	sin.sin_addr.s_addr =  inet_addr(haddr);
cd87151
-
cd87151
-	if (NFSCTL_UDPISSET(ctlbits)) {
cd87151
-		udpfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
cd87151
-		if (udpfd < 0) {
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to create UPD socket: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-		if (bind(udpfd, (struct  sockaddr  *)&sin, sizeof(sin)) < 0){
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to bind UPD socket: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-	}
cd87151
-
cd87151
-	if (NFSCTL_TCPISSET(ctlbits)) {
cd87151
-		tcpfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
cd87151
-		if (tcpfd < 0) {
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to createt tcp socket: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-		if (setsockopt(tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to set SO_REUSEADDR: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-		if (bind(tcpfd, (struct  sockaddr  *)&sin, sizeof(sin)) < 0){
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to bind TCP socket: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-		if (listen(tcpfd, 64) < 0){
cd87151
-			syslog(LOG_ERR, "nfssvc: unable to create listening socket: "
cd87151
-				"errno %d (%s)\n", errno, strerror(errno));
cd87151
-			exit(1);
cd87151
-		}
cd87151
-	}
cd87151
-	if (udpfd >= 0) {
cd87151
-		snprintf(buf, BUFSIZ,"%d\n", udpfd); 
cd87151
-		if (write(fd, buf, strlen(buf)) != strlen(buf)) {
cd87151
-			syslog(LOG_ERR, 
cd87151
-			       "nfssvc: writing fds to kernel failed: errno %d (%s)", 
cd87151
-			       errno, strerror(errno));
cd87151
-		}
cd87151
-		close(fd);
cd87151
-		fd = -1;
cd87151
-	}
cd87151
-	if (tcpfd >= 0) {
cd87151
-		if (fd < 0)
cd87151
-			fd = open(NFSD_PORTS_FILE, O_WRONLY);
cd87151
-		snprintf(buf, BUFSIZ,"%d\n", tcpfd); 
cd87151
-		if (write(fd, buf, strlen(buf)) != strlen(buf)) {
cd87151
-			syslog(LOG_ERR, 
cd87151
-			       "nfssvc: writing fds to kernel failed: errno %d (%s)", 
cd87151
-			       errno, strerror(errno));
cd87151
-		}
cd87151
-	}
cd87151
-	close(fd);
cd87151
-
cd87151
-	return;
cd87151
-}
cd87151
-static void
cd87151
-nfssvc_versbits(unsigned int ctlbits, int minorvers4)
cd87151
-{
cd87151
-	int fd, n, off;
cd87151
-	char buf[BUFSIZ], *ptr;
cd87151
-
cd87151
-	ptr = buf;
cd87151
-	off = 0;
cd87151
-	fd = open(NFSD_VERS_FILE, O_WRONLY);
cd87151
-	if (fd < 0)
cd87151
-		return;
cd87151
-
cd87151
-	for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
cd87151
-		if (NFSCTL_VERISSET(ctlbits, n))
cd87151
-		    off += snprintf(ptr+off, BUFSIZ - off, "+%d ", n);
cd87151
-		else
cd87151
-		    off += snprintf(ptr+off, BUFSIZ - off, "-%d ", n);
cd87151
-	}
cd87151
-	n = minorvers4 >= 0 ? minorvers4 : -minorvers4;
cd87151
-	if (n >= NFSD_MINMINORVERS4 && n <= NFSD_MAXMINORVERS4)
cd87151
-		    off += snprintf(ptr+off, BUFSIZ - off, "%c4.%d",
cd87151
-				    minorvers4 > 0 ? '+' : '-',
cd87151
-				    n);
cd87151
-	snprintf(ptr+off, BUFSIZ - off, "\n");
cd87151
-	if (write(fd, buf, strlen(buf)) != strlen(buf)) {
cd87151
-		syslog(LOG_ERR, "nfssvc: Setting version failed: errno %d (%s)", 
cd87151
-			errno, strerror(errno));
cd87151
-	}
cd87151
-	close(fd);
cd87151
-
cd87151
-	return;
cd87151
-}
cd87151
-int
cd87151
-nfssvc(int port, int nrservs, unsigned int versbits, int minorvers4,
cd87151
-	unsigned protobits, char *haddr)
cd87151
-{
cd87151
-	struct nfsctl_arg	arg;
cd87151
-	int fd;
cd87151
-
cd87151
-	/* Note: must set versions before fds so that
cd87151
-	 * the ports get registered with portmap against correct
cd87151
-	 * versions
cd87151
-	 */
cd87151
-	nfssvc_versbits(versbits, minorvers4);
cd87151
-	nfssvc_setfds(port, protobits, haddr);
cd87151
-
cd87151
-	fd = open(NFSD_THREAD_FILE, O_WRONLY);
cd87151
-	if (fd < 0)
cd87151
-		fd = open("/proc/fs/nfs/threads", O_WRONLY);
cd87151
-	if (fd >= 0) {
cd87151
-		/* 2.5+ kernel with nfsd filesystem mounted.
cd87151
-		 * Just write the number in.
cd87151
-		 * Cannot handle port number yet, but does anyone care?
cd87151
-		 */
cd87151
-		char buf[20];
cd87151
-		int n;
cd87151
-		snprintf(buf, 20,"%d\n", nrservs);
cd87151
-		n = write(fd, buf, strlen(buf));
cd87151
-		close(fd);
cd87151
-		if (n != strlen(buf))
cd87151
-			return -1;
cd87151
-		else
cd87151
-			return 0;
cd87151
-	}
cd87151
-
cd87151
-	arg.ca_version = NFSCTL_VERSION;
cd87151
-	arg.ca_svc.svc_nthreads = nrservs;
cd87151
-	arg.ca_svc.svc_port = port;
cd87151
-	return nfsctl(NFSCTL_SVC, &arg, NULL);
cd87151
-}
cd87151
diff --git a/utils/nfsd/Makefile.am b/utils/nfsd/Makefile.am
cd87151
index 445e3fd..c4c6fb0 100644
cd87151
--- a/utils/nfsd/Makefile.am
cd87151
+++ b/utils/nfsd/Makefile.am
cd87151
@@ -7,10 +7,8 @@ RPCPREFIX	= rpc.
cd87151
 KPREFIX		= @kprefix@
cd87151
 sbin_PROGRAMS	= nfsd
cd87151
 
cd87151
-nfsd_SOURCES = nfsd.c
cd87151
-nfsd_LDADD = ../../support/export/libexport.a \
cd87151
-	     ../../support/nfs/libnfs.a \
cd87151
-	     ../../support/misc/libmisc.a
cd87151
+nfsd_SOURCES = nfsd.c nfssvc.c
cd87151
+nfsd_LDADD = ../../support/nfs/libnfs.a
cd87151
 
cd87151
 MAINTAINERCLEANFILES = Makefile.in
cd87151
 
cd87151
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
cd87151
index e3c0094..650c593 100644
cd87151
--- a/utils/nfsd/nfsd.c
cd87151
+++ b/utils/nfsd/nfsd.c
cd87151
@@ -18,13 +18,14 @@
cd87151
 #include <string.h>
cd87151
 #include <errno.h>
cd87151
 #include <getopt.h>
cd87151
-#include <syslog.h>
cd87151
 #include <netdb.h>
cd87151
 #include <sys/socket.h>
cd87151
 #include <netinet/in.h>
cd87151
 #include <arpa/inet.h>
cd87151
 
cd87151
 #include "nfslib.h"
cd87151
+#include "nfssvc.h"
cd87151
+#include "xlog.h"
cd87151
 
cd87151
 static void	usage(const char *);
cd87151
 
cd87151
@@ -37,47 +38,116 @@ static struct option longopts[] =
cd87151
 	{ "no-udp", 0, 0, 'U' },
cd87151
 	{ "port", 1, 0, 'P' },
cd87151
 	{ "port", 1, 0, 'p' },
cd87151
+	{ "debug", 0, 0, 'd' },
cd87151
+	{ "syslog", 0, 0, 's' },
cd87151
 	{ NULL, 0, 0, 0 }
cd87151
 };
cd87151
-unsigned int protobits = NFSCTL_ALLBITS;
cd87151
-unsigned int versbits = NFSCTL_ALLBITS;
cd87151
-int minorvers4 = NFSD_MAXMINORVERS4;		/* nfsv4 minor version */
cd87151
-char *haddr = NULL;
cd87151
+
cd87151
+/* given a family and ctlbits, disable any that aren't listed in netconfig */
cd87151
+#ifdef HAVE_LIBTIRPC
cd87151
+static void
cd87151
+nfsd_enable_protos(unsigned int *proto4, unsigned int *proto6)
cd87151
+{
cd87151
+	struct netconfig *nconf;
cd87151
+	unsigned int *famproto;
cd87151
+	void *handle;
cd87151
+
cd87151
+	xlog(D_GENERAL, "Checking netconfig for visible protocols.");
cd87151
+
cd87151
+	handle = setnetconfig();
cd87151
+	while((nconf = getnetconfig(handle))) {
cd87151
+		if (!(nconf->nc_flag & NC_VISIBLE))
cd87151
+			continue;
cd87151
+
cd87151
+		if (!strcmp(nconf->nc_protofmly, NC_INET))
cd87151
+			famproto = proto4;
cd87151
+		else if (!strcmp(nconf->nc_protofmly, NC_INET6))
cd87151
+			famproto = proto6;
cd87151
+		else
cd87151
+			continue;
cd87151
+
cd87151
+		if (!strcmp(nconf->nc_proto, NC_TCP))
cd87151
+			NFSCTL_TCPSET(*famproto);
cd87151
+		else if (!strcmp(nconf->nc_proto, NC_UDP))
cd87151
+			NFSCTL_UDPSET(*famproto);
cd87151
+
cd87151
+		xlog(D_GENERAL, "Enabling %s %s.", nconf->nc_protofmly,
cd87151
+			nconf->nc_proto);
cd87151
+	}
cd87151
+	endnetconfig(handle);
cd87151
+	return;
cd87151
+}
cd87151
+#else /* HAVE_LIBTIRPC */
cd87151
+static void
cd87151
+nfsd_enable_protos(unsigned int *proto4, unsigned int *proto6)
cd87151
+{
cd87151
+	/* Enable all IPv4 protocols if no TIRPC support */
cd87151
+	*proto4 = NFSCTL_ALLBITS;
cd87151
+	*proto6 = 0;
cd87151
+}
cd87151
+#endif /* HAVE_LIBTIRPC */
cd87151
 
cd87151
 int
cd87151
 main(int argc, char **argv)
cd87151
 {
cd87151
-	int	count = 1, c, error, port, fd, found_one;
cd87151
-	struct servent *ent;
cd87151
-	struct hostent *hp;
cd87151
-	char *p;
cd87151
-
cd87151
-	ent = getservbyname ("nfs", "udp");
cd87151
-	if (ent != NULL)
cd87151
-		port = ntohs (ent->s_port);
cd87151
-	else
cd87151
-		port = 2049;
cd87151
-
cd87151
-	while ((c = getopt_long(argc, argv, "H:hN:p:P:TU", longopts, NULL)) != EOF) {
cd87151
+	int	count = 1, c, error = 0, portnum = 0, fd, found_one;
cd87151
+	char *p, *progname, *port;
cd87151
+	char *haddr = NULL;
cd87151
+	int	socket_up = 0;
cd87151
+	int minorvers4 = NFSD_MAXMINORVERS4;	/* nfsv4 minor version */
cd87151
+	unsigned int versbits = NFSCTL_ALLBITS;
cd87151
+	unsigned int protobits = NFSCTL_ALLBITS;
cd87151
+	unsigned int proto4 = 0;
cd87151
+	unsigned int proto6 = 0;
cd87151
+
cd87151
+	progname = strdup(basename(argv[0]));
cd87151
+	if (!progname) {
cd87151
+		fprintf(stderr, "%s: unable to allocate memory.\n", argv[0]);
cd87151
+		exit(1);
cd87151
+	}
cd87151
+
cd87151
+	port = strdup("nfs");
cd87151
+	if (!port) {
cd87151
+		fprintf(stderr, "%s: unable to allocate memory.\n", progname);
cd87151
+		exit(1);
cd87151
+	}
cd87151
+
cd87151
+	xlog_syslog(0);
cd87151
+	xlog_stderr(1);
cd87151
+
cd87151
+	while ((c = getopt_long(argc, argv, "dH:hN:p:P:sTU", longopts, NULL)) != EOF) {
cd87151
 		switch(c) {
cd87151
+		case 'd':
cd87151
+			xlog_config(D_ALL, 1);
cd87151
+			break;
cd87151
 		case 'H':
cd87151
-			if (inet_addr(optarg) != INADDR_NONE) {
cd87151
-				haddr = strdup(optarg);
cd87151
-			} else if ((hp = gethostbyname(optarg)) != NULL) {
cd87151
-				haddr = inet_ntoa((*(struct in_addr*)(hp->h_addr_list[0])));
cd87151
-			} else {
cd87151
-				fprintf(stderr, "%s: Unknown hostname: %s\n",
cd87151
-					argv[0], optarg);
cd87151
-				usage(argv [0]);
cd87151
+			/*
cd87151
+			 * for now, this only handles one -H option. Use the
cd87151
+			 * last one specified.
cd87151
+			 */
cd87151
+			free(haddr);
cd87151
+			haddr = strdup(optarg);
cd87151
+			if (!haddr) {
cd87151
+				fprintf(stderr, "%s: unable to allocate "
cd87151
+					"memory.\n", progname);
cd87151
+				exit(1);
cd87151
 			}
cd87151
 			break;
cd87151
 		case 'P':	/* XXX for nfs-server compatibility */
cd87151
 		case 'p':
cd87151
-			port = atoi(optarg);
cd87151
-			if (port <= 0 || port > 65535) {
cd87151
+			/* only the last -p option has any effect */
cd87151
+			portnum = atoi(optarg);
cd87151
+			if (portnum <= 0 || portnum > 65535) {
cd87151
 				fprintf(stderr, "%s: bad port number: %s\n",
cd87151
-					argv[0], optarg);
cd87151
-				usage(argv [0]);
cd87151
+					progname, optarg);
cd87151
+				usage(progname);
cd87151
+			}
cd87151
+			free(port);
cd87151
+			port = strdup(optarg);
cd87151
+			if (!port) {
cd87151
+				fprintf(stderr, "%s: unable to allocate "
cd87151
+						"memory.\n", progname);
cd87151
+				exit(1);
cd87151
 			}
cd87151
 			break;
cd87151
 		case 'N':
cd87151
@@ -96,80 +166,133 @@ main(int argc, char **argv)
cd87151
 				exit(1);
cd87151
 			}
cd87151
 			break;
cd87151
+		case 's':
cd87151
+			xlog_syslog(1);
cd87151
+			xlog_stderr(0);
cd87151
+			break;
cd87151
 		case 'T':
cd87151
-				NFSCTL_TCPUNSET(protobits);
cd87151
-				break;
cd87151
+			NFSCTL_TCPUNSET(protobits);
cd87151
+			break;
cd87151
 		case 'U':
cd87151
-				NFSCTL_UDPUNSET(protobits);
cd87151
-				break;
cd87151
+			NFSCTL_UDPUNSET(protobits);
cd87151
+			break;
cd87151
 		default:
cd87151
 			fprintf(stderr, "Invalid argument: '%c'\n", c);
cd87151
 		case 'h':
cd87151
-			usage(argv[0]);
cd87151
+			usage(progname);
cd87151
 		}
cd87151
 	}
cd87151
-	/*
cd87151
-	 * Do some sanity checking, if the ctlbits are set
cd87151
-	 */
cd87151
-	if (!NFSCTL_UDPISSET(protobits) && !NFSCTL_TCPISSET(protobits)) {
cd87151
-		fprintf(stderr, "invalid protocol specified\n");
cd87151
-		exit(1);
cd87151
+
cd87151
+	if (optind < argc) {
cd87151
+		if ((count = atoi(argv[optind])) < 0) {
cd87151
+			/* insane # of servers */
cd87151
+			fprintf(stderr,
cd87151
+				"%s: invalid server count (%d), using 1\n",
cd87151
+				argv[0], count);
cd87151
+			count = 1;
cd87151
+		} else if (count == 0) {
cd87151
+			/*
cd87151
+			 * don't bother setting anything else if the threads
cd87151
+			 * are coming down anyway.
cd87151
+			 */
cd87151
+			socket_up = 1;
cd87151
+			goto set_threads;
cd87151
+		}
cd87151
 	}
cd87151
+
cd87151
+	xlog_open(progname);
cd87151
+
cd87151
+	nfsd_enable_protos(&proto4, &proto6);
cd87151
+
cd87151
+	if (!NFSCTL_TCPISSET(protobits)) {
cd87151
+		NFSCTL_TCPUNSET(proto4);
cd87151
+		NFSCTL_TCPUNSET(proto6);
cd87151
+	}
cd87151
+
cd87151
+	if (!NFSCTL_UDPISSET(protobits)) {
cd87151
+		NFSCTL_UDPUNSET(proto4);
cd87151
+		NFSCTL_UDPUNSET(proto6);
cd87151
+	}
cd87151
+
cd87151
+	/* make sure that at least one version is enabled */
cd87151
 	found_one = 0;
cd87151
 	for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) {
cd87151
 		if (NFSCTL_VERISSET(versbits, c))
cd87151
 			found_one = 1;
cd87151
 	}
cd87151
 	if (!found_one) {
cd87151
-		fprintf(stderr, "no version specified\n");
cd87151
+		xlog(L_ERROR, "no version specified");
cd87151
 		exit(1);
cd87151
 	}			
cd87151
 
cd87151
-	if (NFSCTL_VERISSET(versbits, 4) && !NFSCTL_TCPISSET(protobits)) {
cd87151
-		fprintf(stderr, "version 4 requires the TCP protocol\n");
cd87151
+	if (NFSCTL_VERISSET(versbits, 4) &&
cd87151
+	    !NFSCTL_TCPISSET(proto4) &&
cd87151
+	    !NFSCTL_TCPISSET(proto6)) {
cd87151
+		xlog(L_ERROR, "version 4 requires the TCP protocol");
cd87151
 		exit(1);
cd87151
 	}
cd87151
-	if (haddr == NULL) {
cd87151
-		struct in_addr in = {INADDR_ANY}; 
cd87151
-		haddr = strdup(inet_ntoa(in));
cd87151
-	}
cd87151
 
cd87151
 	if (chdir(NFS_STATEDIR)) {
cd87151
-		fprintf(stderr, "%s: chdir(%s) failed: %s\n",
cd87151
-			argv [0], NFS_STATEDIR, strerror(errno));
cd87151
+		xlog(L_ERROR, "chdir(%s) failed: %m", NFS_STATEDIR);
cd87151
 		exit(1);
cd87151
 	}
cd87151
 
cd87151
-	if (optind < argc) {
cd87151
-		if ((count = atoi(argv[optind])) < 0) {
cd87151
-			/* insane # of servers */
cd87151
-			fprintf(stderr,
cd87151
-				"%s: invalid server count (%d), using 1\n",
cd87151
-				argv[0], count);
cd87151
-			count = 1;
cd87151
-		}
cd87151
+	/* can only change number of threads if nfsd is already up */
cd87151
+	if (nfssvc_inuse()) {
cd87151
+		socket_up = 1;
cd87151
+		goto set_threads;
cd87151
 	}
cd87151
-	/* KLUDGE ALERT:
cd87151
-	   Some kernels let nfsd kernel threads inherit open files
cd87151
-	   from the program that spawns them (i.e. us).  So close
cd87151
-	   everything before spawning kernel threads.  --Chip */
cd87151
+
cd87151
+	/*
cd87151
+	 * must set versions before the fd's so that the right versions get
cd87151
+	 * registered with rpcbind. Note that on older kernels w/o the right
cd87151
+	 * interfaces, these are a no-op.
cd87151
+	 */
cd87151
+	nfssvc_setvers(versbits, minorvers4);
cd87151
+ 
cd87151
+	error = nfssvc_set_sockets(AF_INET, proto4, haddr, port);
cd87151
+	if (!error)
cd87151
+		socket_up = 1;
cd87151
+
cd87151
+#ifdef IPV6_SUPPORTED
cd87151
+	error = nfssvc_set_sockets(AF_INET6, proto6, haddr, port);
cd87151
+	if (!error)
cd87151
+		socket_up = 1;
cd87151
+#endif /* IPV6_SUPPORTED */
cd87151
+
cd87151
+set_threads:
cd87151
+	/* don't start any threads if unable to hand off any sockets */
cd87151
+	if (!socket_up) {
cd87151
+		xlog(L_ERROR, "unable to set any sockets for nfsd");
cd87151
+		goto out;
cd87151
+	}
cd87151
+	error = 0;
cd87151
+
cd87151
+	/*
cd87151
+	 * KLUDGE ALERT:
cd87151
+	 * Some kernels let nfsd kernel threads inherit open files
cd87151
+	 * from the program that spawns them (i.e. us).  So close
cd87151
+	 * everything before spawning kernel threads.  --Chip
cd87151
+	 */
cd87151
 	fd = open("/dev/null", O_RDWR);
cd87151
 	if (fd == -1)
cd87151
-		perror("/dev/null");
cd87151
+		xlog(L_ERROR, "Unable to open /dev/null: %m");
cd87151
 	else {
cd87151
+		/* switch xlog output to syslog since stderr is being closed */
cd87151
+		xlog_syslog(1);
cd87151
+		xlog_stderr(0);
cd87151
 		(void) dup2(fd, 0);
cd87151
 		(void) dup2(fd, 1);
cd87151
 		(void) dup2(fd, 2);
cd87151
 	}
cd87151
 	closeall(3);
cd87151
 
cd87151
-	openlog("nfsd", LOG_PID, LOG_DAEMON);
cd87151
-	if ((error = nfssvc(port, count, versbits, minorvers4, protobits, haddr)) < 0) {
cd87151
-		int e = errno;
cd87151
-		syslog(LOG_ERR, "nfssvc: %s", strerror(e));
cd87151
-		closelog();
cd87151
-	}
cd87151
-
cd87151
+	if ((error = nfssvc_threads(portnum, count)) < 0)
cd87151
+		xlog(L_ERROR, "error starting threads: errno %d (%m)", errno);
cd87151
+out:
cd87151
+	free(port);
cd87151
+	free(haddr);
cd87151
+	free(progname);
cd87151
 	return (error != 0);
cd87151
 }
cd87151
 
cd87151
@@ -177,7 +300,7 @@ static void
cd87151
 usage(const char *prog)
cd87151
 {
cd87151
 	fprintf(stderr, "Usage:\n"
cd87151
-		"%s [-H hostname] [-p|-P|--port port] [-N|--no-nfs-version version ] [-T|--no-tcp] [-U|--no-udp] nrservs\n", 
cd87151
+		"%s [-d|--debug] [-H hostname] [-p|-P|--port port] [-N|--no-nfs-version version ] [-s|--syslog] [-T|--no-tcp] [-U|--no-udp] nrservs\n", 
cd87151
 		prog);
cd87151
 	exit(2);
cd87151
 }
cd87151
diff --git a/utils/nfsd/nfsd.man b/utils/nfsd/nfsd.man
cd87151
index 4eb3e21..d8988d2 100644
cd87151
--- a/utils/nfsd/nfsd.man
cd87151
+++ b/utils/nfsd/nfsd.man
cd87151
@@ -13,8 +13,9 @@ The
cd87151
 program implements the user level part of the NFS service. The
cd87151
 main functionality is handled by the
cd87151
 .B nfsd
cd87151
-kernel module; the user space program merely starts the specified
cd87151
-number of kernel threads.
cd87151
+kernel module. The user space program merely specifies what sort of sockets
cd87151
+the kernel service should listen on, what NFS versions it should support, and
cd87151
+how many kernel threads it should use.
cd87151
 .P
cd87151
 The
cd87151
 .B rpc.mountd
cd87151
@@ -22,6 +23,9 @@ server provides an ancillary service needed to satisfy mount requests
cd87151
 by NFS clients.
cd87151
 .SH OPTIONS
cd87151
 .TP
cd87151
+.B \-d " or " \-\-debug
cd87151
+enable logging of debugging messages
cd87151
+.TP
cd87151
 .B \-H " or " \-\-host  hostname
cd87151
 specify a particular hostname (or address) that NFS requests will
cd87151
 be accepted on. By default,
cd87151
@@ -45,6 +49,14 @@ does not offer certain versions of NFS. The current version of
cd87151
 .B rpc.nfsd
cd87151
 can support both NFS version 2,3 and the newer version 4.
cd87151
 .TP
cd87151
+.B \-s " or " \-\-syslog
cd87151
+By default,
cd87151
+.B rpc.nfsd
cd87151
+logs error messages (and debug messages, if enabled) to stderr. This option makes 
cd87151
+.B rpc.nfsd
cd87151
+log these messages to syslog instead. Note that errors encountered during
cd87151
+option processing will still be logged to stderr regardless of this option.
cd87151
+.TP
cd87151
 .B \-T " or " \-\-no-tcp
cd87151
 Disable 
cd87151
 .B rpc.nfsd 
cd87151
@@ -75,12 +87,19 @@ In particular
cd87151
 .B rpc.nfsd 0
cd87151
 will stop all threads and thus close any open connections.
cd87151
 
cd87151
+.SH NOTES
cd87151
+If the program is built with TI-RPC support, it will enable any protocol and
cd87151
+address family combinations that are marked visible in the
cd87151
+.B netconfig
cd87151
+database.
cd87151
+
cd87151
 .SH SEE ALSO
cd87151
 .BR rpc.mountd (8),
cd87151
 .BR exports (5),
cd87151
 .BR exportfs (8),
cd87151
 .BR rpc.rquotad (8),
cd87151
-.BR nfsstat (8).
cd87151
+.BR nfsstat (8),
cd87151
+.BR netconfig(5).
cd87151
 .SH AUTHOR
cd87151
 Olaf Kirch, Bill Hawes, H. J. Lu, G. Allan Morris III,
cd87151
 and a host of others.
cd87151
diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c
cd87151
new file mode 100644
cd87151
index 0000000..ee862b2
cd87151
--- /dev/null
cd87151
+++ b/utils/nfsd/nfssvc.c
cd87151
@@ -0,0 +1,289 @@
cd87151
+/*
cd87151
+ * utils/nfsd/nfssvc.c
cd87151
+ *
cd87151
+ * Run an NFS daemon.
cd87151
+ *
cd87151
+ * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
cd87151
+ */
cd87151
+
cd87151
+#ifdef HAVE_CONFIG_H
cd87151
+#include <config.h>
cd87151
+#endif
cd87151
+
cd87151
+#include <sys/types.h>
cd87151
+#include <sys/socket.h>
cd87151
+#include <netdb.h>
cd87151
+#include <netinet/in.h>
cd87151
+#include <arpa/inet.h>
cd87151
+#include <unistd.h>
cd87151
+#include <fcntl.h>
cd87151
+#include <errno.h>
cd87151
+
cd87151
+#include "nfslib.h"
cd87151
+#include "xlog.h"
cd87151
+
cd87151
+#define NFSD_PORTS_FILE     "/proc/fs/nfsd/portlist"
cd87151
+#define NFSD_VERS_FILE    "/proc/fs/nfsd/versions"
cd87151
+#define NFSD_THREAD_FILE  "/proc/fs/nfsd/threads"
cd87151
+
cd87151
+/*
cd87151
+ * declaring a common static scratch buffer here keeps us from having to
cd87151
+ * continually thrash the stack. The value of 128 bytes here is really just a
cd87151
+ * SWAG and can be increased if necessary. It ought to be enough for the
cd87151
+ * routines below however.
cd87151
+ */
cd87151
+char buf[128];
cd87151
+
cd87151
+/*
cd87151
+ * Are there already sockets configured? If not, then it is safe to try to
cd87151
+ * open some and pass them through.
cd87151
+ *
cd87151
+ * Note: If the user explicitly asked for 'udp', then we should probably check
cd87151
+ * if that is open, and should open it if not. However we don't yet. All
cd87151
+ * sockets have to be opened when the first daemon is started.
cd87151
+ */
cd87151
+int
cd87151
+nfssvc_inuse(void)
cd87151
+{
cd87151
+	int fd, n;
cd87151
+
cd87151
+	fd = open(NFSD_PORTS_FILE, O_RDONLY);
cd87151
+
cd87151
+	/* problem opening file, assume that nothing is configured */
cd87151
+	if (fd < 0)
cd87151
+		return 0;
cd87151
+
cd87151
+	n = read(fd, buf, sizeof(buf));
cd87151
+	close(fd);
cd87151
+
cd87151
+	xlog(D_GENERAL, "knfsd is currently %s", (n > 0) ? "up" : "down");
cd87151
+
cd87151
+	return (n > 0);
cd87151
+}
cd87151
+
cd87151
+static int
cd87151
+nfssvc_setfds(const struct addrinfo *hints, const char *node, const char *port)
cd87151
+{
cd87151
+	int fd, on = 1, fac = L_ERROR;
cd87151
+	int sockfd = -1, rc = 0;
cd87151
+	struct addrinfo *addrhead = NULL, *addr;
cd87151
+	char *proto, *family;
cd87151
+
cd87151
+	/*
cd87151
+	 * if file can't be opened, then assume that it's not available and
cd87151
+	 * that the caller should just fall back to the old nfsctl interface
cd87151
+ 	 */
cd87151
+	fd = open(NFSD_PORTS_FILE, O_WRONLY);
cd87151
+	if (fd < 0)
cd87151
+		return 0;
cd87151
+
cd87151
+	switch(hints->ai_family) {
cd87151
+	case AF_INET:
cd87151
+		family = "inet";
cd87151
+		break;
cd87151
+#ifdef IPV6_SUPPORTED
cd87151
+	case AF_INET6:
cd87151
+		family = "inet6";
cd87151
+		break;
cd87151
+#endif /* IPV6_SUPPORTED */
cd87151
+	default:
cd87151
+		xlog(L_ERROR, "Unknown address family specified: %d\n",
cd87151
+				hints->ai_family);
cd87151
+		rc = EAFNOSUPPORT;
cd87151
+		goto error;
cd87151
+	}
cd87151
+
cd87151
+	rc = getaddrinfo(node, port, hints, &addrhead);
cd87151
+	if (rc == EAI_NONAME && !strcmp(port, "nfs")) {
cd87151
+		snprintf(buf, sizeof(buf), "%d", NFS_PORT);
cd87151
+		rc = getaddrinfo(node, buf, hints, &addrhead);
cd87151
+	}
cd87151
+
cd87151
+	if (rc != 0) {
cd87151
+		xlog(L_ERROR, "unable to resolve %s:%s to %s address: "
cd87151
+				"%s", node ? node : "ANYADDR", port, family,
cd87151
+				rc == EAI_SYSTEM ? strerror(errno) :
cd87151
+					gai_strerror(rc));
cd87151
+		goto error;
cd87151
+	}
cd87151
+
cd87151
+	addr = addrhead;
cd87151
+	while(addr) {
cd87151
+		/* skip non-TCP / non-UDP sockets */
cd87151
+		switch(addr->ai_protocol) {
cd87151
+		case IPPROTO_UDP:
cd87151
+			proto = "UDP";
cd87151
+			break;
cd87151
+		case IPPROTO_TCP:
cd87151
+			proto = "TCP";
cd87151
+			break;
cd87151
+		default:
cd87151
+			addr = addr->ai_next;
cd87151
+			continue;
cd87151
+		}
cd87151
+
cd87151
+		xlog(D_GENERAL, "Creating %s %s socket.", family, proto);
cd87151
+
cd87151
+		/* open socket and prepare to hand it off to kernel */
cd87151
+		sockfd = socket(addr->ai_family, addr->ai_socktype,
cd87151
+				addr->ai_protocol);
cd87151
+		if (sockfd < 0) {
cd87151
+			xlog(L_ERROR, "unable to create %s %s socket: "
cd87151
+				"errno %d (%m)", family, proto, errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+#ifdef IPV6_SUPPORTED
cd87151
+		if (addr->ai_family == AF_INET6 &&
cd87151
+		    setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on))) {
cd87151
+			xlog(L_ERROR, "unable to set IPV6_V6ONLY: "
cd87151
+				"errno %d (%m)\n", errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+#endif /* IPV6_SUPPORTED */
cd87151
+		if (addr->ai_protocol == IPPROTO_TCP &&
cd87151
+		    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) {
cd87151
+			xlog(L_ERROR, "unable to set SO_REUSEADDR on %s "
cd87151
+				"socket: errno %d (%m)", family, errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+		if (bind(sockfd, addr->ai_addr, addr->ai_addrlen)) {
cd87151
+			xlog(L_ERROR, "unable to bind %s %s socket: "
cd87151
+				"errno %d (%m)", family, proto, errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+		if (addr->ai_protocol == IPPROTO_TCP && listen(sockfd, 64)) {
cd87151
+			xlog(L_ERROR, "unable to create listening socket: "
cd87151
+				"errno %d (%m)", errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+
cd87151
+		if (fd < 0)
cd87151
+			fd = open(NFSD_PORTS_FILE, O_WRONLY);
cd87151
+
cd87151
+		if (fd < 0) {
cd87151
+			xlog(L_ERROR, "couldn't open ports file: errno "
cd87151
+				      "%d (%m)", errno);
cd87151
+			goto error;
cd87151
+		}
cd87151
+
cd87151
+		snprintf(buf, sizeof(buf), "%d\n", sockfd); 
cd87151
+		if (write(fd, buf, strlen(buf)) != strlen(buf)) {
cd87151
+			/*
cd87151
+			 * this error may be common on older kernels that don't
cd87151
+			 * support IPv6, so turn into a debug message.
cd87151
+			 */
cd87151
+			if (errno == EAFNOSUPPORT)
cd87151
+				fac = D_ALL;
cd87151
+			xlog(fac, "writing fd to kernel failed: errno %d (%m)",
cd87151
+				  errno);
cd87151
+			rc = errno;
cd87151
+			goto error;
cd87151
+		}
cd87151
+		close(fd);
cd87151
+		close(sockfd);
cd87151
+		sockfd = fd = -1;
cd87151
+		addr = addr->ai_next;
cd87151
+	}
cd87151
+error:
cd87151
+	if (fd >= 0)
cd87151
+		close(fd);
cd87151
+	if (sockfd >= 0)
cd87151
+		close(sockfd);
cd87151
+	if (addrhead)
cd87151
+		freeaddrinfo(addrhead);
cd87151
+	return rc;
cd87151
+}
cd87151
+
cd87151
+int
cd87151
+nfssvc_set_sockets(const int family, const unsigned int protobits,
cd87151
+		   const char *host, const char *port)
cd87151
+{
cd87151
+	struct addrinfo hints = { .ai_flags = AI_PASSIVE | AI_ADDRCONFIG };
cd87151
+
cd87151
+	hints.ai_family = family;
cd87151
+
cd87151
+	if (!NFSCTL_ANYPROTO(protobits))
cd87151
+		return EPROTOTYPE;
cd87151
+	else if (!NFSCTL_UDPISSET(protobits))
cd87151
+		hints.ai_protocol = IPPROTO_TCP;
cd87151
+	else if (!NFSCTL_TCPISSET(protobits))
cd87151
+		hints.ai_protocol = IPPROTO_UDP;
cd87151
+
cd87151
+	return nfssvc_setfds(&hints, host, port);
cd87151
+}
cd87151
+
cd87151
+void
cd87151
+nfssvc_setvers(unsigned int ctlbits, int minorvers4)
cd87151
+{
cd87151
+	int fd, n, off;
cd87151
+	char *ptr;
cd87151
+
cd87151
+	ptr = buf;
cd87151
+	off = 0;
cd87151
+	fd = open(NFSD_VERS_FILE, O_WRONLY);
cd87151
+	if (fd < 0)
cd87151
+		return;
cd87151
+
cd87151
+	for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
cd87151
+		if (NFSCTL_VERISSET(ctlbits, n))
cd87151
+		    off += snprintf(ptr+off, sizeof(buf) - off, "+%d ", n);
cd87151
+		else
cd87151
+		    off += snprintf(ptr+off, sizeof(buf) - off, "-%d ", n);
cd87151
+	}
cd87151
+	n = minorvers4 >= 0 ? minorvers4 : -minorvers4;
cd87151
+	if (n >= NFSD_MINMINORVERS4 && n <= NFSD_MAXMINORVERS4)
cd87151
+		    off += snprintf(ptr+off, sizeof(buf) - off, "%c4.%d",
cd87151
+				    minorvers4 > 0 ? '+' : '-',
cd87151
+				    n);
cd87151
+	xlog(D_GENERAL, "Writing version string to kernel: %s", buf);
cd87151
+	snprintf(ptr+off, sizeof(buf) - off, "\n");
cd87151
+	if (write(fd, buf, strlen(buf)) != strlen(buf))
cd87151
+		xlog(L_ERROR, "Setting version failed: errno %d (%m)", errno);
cd87151
+
cd87151
+	close(fd);
cd87151
+
cd87151
+	return;
cd87151
+}
cd87151
+
cd87151
+int
cd87151
+nfssvc_threads(unsigned short port, const int nrservs)
cd87151
+{
cd87151
+	struct nfsctl_arg	arg;
cd87151
+	struct servent *ent;
cd87151
+	ssize_t n;
cd87151
+	int fd;
cd87151
+
cd87151
+	fd = open(NFSD_THREAD_FILE, O_WRONLY);
cd87151
+	if (fd < 0)
cd87151
+		fd = open("/proc/fs/nfs/threads", O_WRONLY);
cd87151
+	if (fd >= 0) {
cd87151
+		/* 2.5+ kernel with nfsd filesystem mounted.
cd87151
+		 * Just write the number of threads.
cd87151
+		 */
cd87151
+		snprintf(buf, sizeof(buf), "%d\n", nrservs);
cd87151
+		n = write(fd, buf, strlen(buf));
cd87151
+		close(fd);
cd87151
+		if (n != strlen(buf))
cd87151
+			return -1;
cd87151
+		else
cd87151
+			return 0;
cd87151
+	}
cd87151
+
cd87151
+	if (!port) {
cd87151
+		ent = getservbyname("nfs", "udp");
cd87151
+		if (ent != NULL)
cd87151
+			port = ntohs(ent->s_port);
cd87151
+		else
cd87151
+			port = NFS_PORT;
cd87151
+	}
cd87151
+
cd87151
+	arg.ca_version = NFSCTL_VERSION;
cd87151
+	arg.ca_svc.svc_nthreads = nrservs;
cd87151
+	arg.ca_svc.svc_port = port;
cd87151
+	return nfsctl(NFSCTL_SVC, &arg, NULL);
cd87151
+}
cd87151
diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h
cd87151
new file mode 100644
cd87151
index 0000000..0c69bd6
cd87151
--- /dev/null
cd87151
+++ b/utils/nfsd/nfssvc.h
cd87151
@@ -0,0 +1,27 @@
cd87151
+/*
cd87151
+ *   utils/nfsd/nfssvc.h -- nfs service control routines for rpc.nfsd
cd87151
+ *
cd87151
+ *   Copyright (C) 2009 Red Hat, Inc <nfs@redhat.com>.
cd87151
+ *   Copyright (C) 2009 Jeff Layton <jlayton@redhat.com>
cd87151
+ *
cd87151
+ * This program is free software; you can redistribute it and/or
cd87151
+ * modify it under the terms of the GNU General Public License
cd87151
+ * as published by the Free Software Foundation; either version 2
cd87151
+ * of the License, or (at your option) any later version.
cd87151
+ *
cd87151
+ * This program is distributed in the hope that it will be useful,
cd87151
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
cd87151
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cd87151
+ * GNU General Public License for more details.
cd87151
+ *
cd87151
+ * You should have received a copy of the GNU General Public License along
cd87151
+ * with this program; if not, write to the Free Software Foundation, Inc.,
cd87151
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
cd87151
+ *
cd87151
+ */
cd87151
+
cd87151
+int	nfssvc_inuse(void);
cd87151
+int	nfssvc_set_sockets(const int family, const unsigned int protobits,
cd87151
+			   const char *host, const char *port);
cd87151
+void	nfssvc_setvers(unsigned int ctlbits, int minorvers4);
cd87151
+int	nfssvc_threads(unsigned short port, int nrservs);