Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/nfs/nfsservice Use the original nfsd.



details:   https://anonhg.NetBSD.org/src/rev/a6f1400d1ced
branches:  trunk
changeset: 812618:a6f1400d1ced
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 23 18:42:23 2015 +0000

description:
Use the original nfsd.

diffstat:

 tests/fs/nfs/nfsservice/Makefile |    6 +-
 tests/fs/nfs/nfsservice/nfsd.c   |  582 ---------------------------------------
 2 files changed, 3 insertions(+), 585 deletions(-)

diffs (truncated from 607 to 300 lines):

diff -r 0971ff0da660 -r a6f1400d1ced tests/fs/nfs/nfsservice/Makefile
--- a/tests/fs/nfs/nfsservice/Makefile  Wed Dec 23 18:41:54 2015 +0000
+++ b/tests/fs/nfs/nfsservice/Makefile  Wed Dec 23 18:42:23 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.10 2015/12/23 18:10:10 christos Exp $
+#      $NetBSD: Makefile,v 1.11 2015/12/23 18:42:23 christos Exp $
 #
 
 NOMAN= 1
@@ -27,9 +27,9 @@
 LDADD+=        -lpthread -lutil
 
 CPPFLAGS+=     -DDEBUG -DMOUNT_NOMAIN -D_REENTRANT
-CPPFLAGS+=     -DRUMP_SYS_NETWORKING -DMOUNTD_RUMP
+CPPFLAGS+=     -DRUMP_SYS_NETWORKING -DMOUNTD_RUMP -DNFSD_RUMP
 
-.PATH.c: ${NETBSDSRCDIR}/usr.sbin/mountd
+.PATH.c: ${NETBSDSRCDIR}/usr.sbin/mountd ${NETBSDSRCDIR}/usr.sbin/nfsd
 
 # RPCBIND
 .PATH.c: ${NETBSDSRCDIR}/usr.sbin/rpcbind
diff -r 0971ff0da660 -r a6f1400d1ced tests/fs/nfs/nfsservice/nfsd.c
--- a/tests/fs/nfs/nfsservice/nfsd.c    Wed Dec 23 18:41:54 2015 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,582 +0,0 @@
-/*     $NetBSD: nfsd.c,v 1.6 2015/12/23 18:10:39 christos Exp $        */
-
-/*
- * Copyright (c) 1989, 1993, 1994
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\
- The Regents of the University of California.  All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)nfsd.c     8.9 (Berkeley) 3/29/95";
-#else
-__RCSID("$NetBSD: nfsd.c,v 1.6 2015/12/23 18:10:39 christos Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/uio.h>
-#include <sys/ucred.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <poll.h>
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <rpc/pmap_prot.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <netdb.h>
-
-#include <rump/rump.h>
-#include <rump/rump_syscalls.h>
-
-/* Global defs */
-#ifdef DEBUG
-#define        syslog(e, s, args...)                                           \
-do {                                                                   \
-    fprintf(stderr,(s), ## args);                                      \
-    fprintf(stderr, "\n");                                             \
-} while (/*CONSTCOND*/0)
-static int     debug = 1;
-#else
-static int     debug = 0;
-#endif
-
-void   nonfs(int);
-void   usage(void);
-
-static void *
-child(void *arg)
-{
-       struct  nfsd_srvargs nsd;
-       int nfssvc_flag;
-
-       nfssvc_flag = NFSSVC_NFSD;
-       memset(&nsd, 0, sizeof(nsd));
-       while (rump_sys_nfssvc(nfssvc_flag, &nsd) < 0) {
-               if (errno != ENEEDAUTH) {
-                       syslog(LOG_ERR, "nfssvc (%s)", strerror(errno));
-                       exit(1);
-               }
-               nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL;
-       }
-
-       return NULL;
-}
-
-/*
- * Nfs server daemon mostly just a user context for nfssvc()
- *
- * 1 - do file descriptor and signal cleanup
- * 2 - create the nfsd thread(s)
- * 3 - create server socket(s)
- * 4 - register socket with portmap
- *
- * For connectionless protocols, just pass the socket into the kernel via
- * nfssvc().
- * For connection based sockets, loop doing accepts. When you get a new
- * socket from accept, pass the msgsock into the kernel via nfssvc().
- * The arguments are:
- *     -c - support iso cltp clients
- *     -r - reregister with portmapper
- *     -t - support tcp nfs clients
- *     -u - support udp nfs clients
- * followed by "n" which is the number of nfsd threads to create
- */
-int nfsd_main(int, char**);
-int
-nfsd_main(argc, argv)
-       int argc;
-       char *argv[];
-{
-       struct nfsd_args nfsdargs;
-       struct addrinfo *ai_udp, *ai_tcp, *ai_udp6, *ai_tcp6, hints;
-       struct netconfig *nconf_udp, *nconf_tcp, *nconf_udp6, *nconf_tcp6;
-       struct netbuf nb_udp, nb_tcp, nb_udp6, nb_tcp6;
-       struct sockaddr_in inetpeer;
-       struct pollfd set[4];
-       socklen_t len;
-       int ch, connect_type_cnt, i, msgsock;
-       int nfsdcnt, on = 1, reregister, sock, tcpflag, tcpsock;
-       int tcp6sock, ip6flag;
-       int tp4cnt, tp4flag, tpipcnt, udpflag, ecode, s;
-
-#define        DEFNFSDCNT       4
-       nfsdcnt = DEFNFSDCNT;
-       reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0;
-       udpflag = ip6flag = 0;
-       nconf_udp = nconf_tcp = nconf_udp6 = nconf_tcp6 = NULL;
-       tcpsock = tcp6sock = -1;
-#define        GETOPT  "6n:rtu"
-#define        USAGE   "[-rtu] [-n num_servers]"
-       while ((ch = getopt(argc, argv, GETOPT)) != -1) {
-               switch (ch) {
-               case '6':
-                       ip6flag = 1;
-                       s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
-                       if (s < 0 && (errno == EPROTONOSUPPORT ||
-                           errno == EPFNOSUPPORT || errno == EAFNOSUPPORT))
-                               ip6flag = 0;
-                       else
-                               close(s);
-                       break;
-               case 'n':
-                       nfsdcnt = atoi(optarg);
-                       if (nfsdcnt < 1) {
-                               warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT);
-                               nfsdcnt = DEFNFSDCNT;
-                       }
-                       break;
-               case 'r':
-                       reregister = 1;
-                       break;
-               case 't':
-                       tcpflag = 1;
-                       break;
-               case 'u':
-                       udpflag = 1;
-                       break;
-               default:
-               case '?':
-                       usage();
-               };
-       }
-       argv += optind;
-       argc -= optind;
-
-       /*
-        * XXX
-        * Backward compatibility, trailing number is the count of daemons.
-        */
-       if (argc > 1)
-               usage();
-       if (argc == 1) {
-               nfsdcnt = atoi(argv[0]);
-               if (nfsdcnt < 1) {
-                       warnx("nfsd count %d; reset to %d", nfsdcnt, DEFNFSDCNT);
-                       nfsdcnt = DEFNFSDCNT;
-               }
-       }
-
-       /*
-        * If none of TCP or UDP are specified, default to UDP only.
-        */
-       if (tcpflag == 0 && udpflag == 0)
-               udpflag = 1;
-
-       if (debug == 0) {
-               fprintf(stderr, "non-debug not supported here\n");
-               exit(1);
-
-#ifdef not_the_debug_man
-               daemon(0, 0);
-               (void)signal(SIGHUP, SIG_IGN);
-               (void)signal(SIGINT, SIG_IGN);
-               (void)signal(SIGQUIT, SIG_IGN);
-               (void)signal(SIGSYS, nonfs);
-#endif
-       }
-
-       if (udpflag) {
-               memset(&hints, 0, sizeof hints);
-               hints.ai_flags = AI_PASSIVE;
-               hints.ai_family = PF_INET;
-               hints.ai_socktype = SOCK_DGRAM;
-               hints.ai_protocol = IPPROTO_UDP;
-
-               ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp);
-               if (ecode != 0) {
-                       syslog(LOG_ERR, "getaddrinfo udp: %s",
-                           gai_strerror(ecode));
-                       exit(1);
-               }
-
-               nconf_udp = getnetconfigent("udp");
-
-               if (nconf_udp == NULL)
-                       err(1, "getnetconfigent udp failed");
-
-               nb_udp.buf = ai_udp->ai_addr;
-               nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
-               if (reregister)
-                       if (!rpcb_set(RPCPROG_NFS, 2, nconf_udp, &nb_udp))
-                               err(1, "rpcb_set udp failed");
-       }
-
-       if (tcpflag) {
-               memset(&hints, 0, sizeof hints);
-               hints.ai_flags = AI_PASSIVE;
-               hints.ai_family = PF_INET;
-               hints.ai_socktype = SOCK_STREAM;
-               hints.ai_protocol = IPPROTO_TCP;
-
-               ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp);
-               if (ecode != 0) {
-                       syslog(LOG_ERR, "getaddrinfo tcp: %s",
-                           gai_strerror(ecode));
-                       exit(1);
-               }
-
-               nconf_tcp = getnetconfigent("tcp");
-
-               if (nconf_tcp == NULL)
-                       err(1, "getnetconfigent tcp failed");



Home | Main Index | Thread Index | Old Index