2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 static const char copyright[] =
35 "@(#) Copyright (c) 1989, 1993, 1994\n\
36 The Regents of the University of California. All rights reserved.\n";
41 static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95";
43 static const char rcsid[] =
47 #include <sys/param.h>
48 #include <sys/syslog.h>
50 #include <sys/mount.h>
51 #include <sys/linker.h>
52 #include <sys/module.h>
55 #include <rpc/pmap_clnt.h>
58 #include <arpa/inet.h>
59 #include <nfs/rpcv2.h>
60 #include <nfs/nfsproto.h>
61 #include <nfsserver/nfs.h>
74 #define syslog(e, s...) fprintf(stderr,s)
82 pid_t children[MAXNFSDCNT]; /* PIDs of children */
83 int nfsdcnt; /* number of children */
86 void child_cleanup(int);
87 void killchildren(void);
91 int setbindhost(struct addrinfo **ia, const char *bindhost,
92 struct addrinfo hints);
93 void start_server(int);
94 void unregistration(void);
98 * Nfs server daemon mostly just a user context for nfssvc()
100 * 1 - do file descriptor and signal cleanup
101 * 2 - fork the nfsd(s)
102 * 3 - create server socket(s)
103 * 4 - register socket with rpcbind
105 * For connectionless protocols, just pass the socket into the kernel via.
107 * For connection based sockets, loop doing accepts. When you get a new
108 * socket from accept, pass the msgsock into the kernel via. nfssvc().
110 * -r - reregister with rpcbind
111 * -d - unregister with rpcbind
112 * -t - support tcp nfs clients
113 * -u - support udp nfs clients
114 * followed by "n" which is the number of nfsds' to fork off
117 main(argc, argv, envp)
119 char *argv[], *envp[];
121 struct nfsd_args nfsdargs;
122 struct addrinfo *ai_udp, *ai_tcp, *ai_udp6, *ai_tcp6, hints;
123 struct netconfig *nconf_udp, *nconf_tcp, *nconf_udp6, *nconf_tcp6;
124 struct netbuf nb_udp, nb_tcp, nb_udp6, nb_tcp6;
125 struct sockaddr_in inetpeer;
126 struct sockaddr_in6 inet6peer;
127 fd_set ready, sockbits;
128 fd_set v4bits, v6bits;
129 int ch, connect_type_cnt, i, len, maxsock, msgsock;
130 int on = 1, unregister, reregister, sock;
131 int tcp6sock, ip6flag, tcpflag, tcpsock;
132 int udpflag, ecode, s, srvcnt;
133 int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
134 char **bindhost = NULL;
137 if (modfind("nfsserver") < 0) {
138 /* Not present in kernel, try loading it */
139 if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
140 errx(1, "NFS server is not available");
143 nfsdcnt = DEFNFSDCNT;
144 unregister = reregister = tcpflag = maxsock = 0;
145 bindanyflag = udpflag = connect_type_cnt = bindhostc = 0;
146 #define GETOPT "ah:n:rdtu"
147 #define USAGE "[-ardtu] [-n num_servers] [-h bindip]"
148 while ((ch = getopt(argc, argv, GETOPT)) != -1)
154 nfsdcnt = atoi(optarg);
155 if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
156 warnx("nfsd count %d; reset to %d", nfsdcnt,
158 nfsdcnt = DEFNFSDCNT;
163 bindhost = realloc(bindhost,sizeof(char *)*bindhostc);
164 if (bindhost == NULL)
165 errx(1, "Out of memory");
166 bindhost[bindhostc-1] = strdup(optarg);
167 if (bindhost[bindhostc-1] == NULL)
168 errx(1, "Out of memory");
186 if (!tcpflag && !udpflag)
193 * Backward compatibility, trailing number is the count of daemons.
198 nfsdcnt = atoi(argv[0]);
199 if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
200 warnx("nfsd count %d; reset to %d", nfsdcnt,
202 nfsdcnt = DEFNFSDCNT;
207 s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
209 if (errno != EPROTONOSUPPORT)
212 } else if (getnetconfigent("udp6") == NULL ||
213 getnetconfigent("tcp6") == NULL) {
219 if (bindhostc == 0 || bindanyflag) {
221 bindhost = realloc(bindhost,sizeof(char *)*bindhostc);
222 if (bindhost == NULL)
223 errx(1, "Out of memory");
224 bindhost[bindhostc-1] = strdup("*");
225 if (bindhost[bindhostc-1] == NULL)
226 errx(1, "Out of memory");
235 memset(&hints, 0, sizeof hints);
236 hints.ai_flags = AI_PASSIVE;
237 hints.ai_family = AF_INET;
238 hints.ai_socktype = SOCK_DGRAM;
239 hints.ai_protocol = IPPROTO_UDP;
240 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp);
242 err(1, "getaddrinfo udp: %s", gai_strerror(ecode));
243 nconf_udp = getnetconfigent("udp");
244 if (nconf_udp == NULL)
245 err(1, "getnetconfigent udp failed");
246 nb_udp.buf = ai_udp->ai_addr;
247 nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
248 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_udp, &nb_udp)) ||
249 (!rpcb_set(RPCPROG_NFS, 3, nconf_udp, &nb_udp)))
250 err(1, "rpcb_set udp failed");
251 freeaddrinfo(ai_udp);
253 if (udpflag && ip6flag) {
254 memset(&hints, 0, sizeof hints);
255 hints.ai_flags = AI_PASSIVE;
256 hints.ai_family = AF_INET6;
257 hints.ai_socktype = SOCK_DGRAM;
258 hints.ai_protocol = IPPROTO_UDP;
259 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp6);
261 err(1, "getaddrinfo udp6: %s", gai_strerror(ecode));
262 nconf_udp6 = getnetconfigent("udp6");
263 if (nconf_udp6 == NULL)
264 err(1, "getnetconfigent udp6 failed");
265 nb_udp6.buf = ai_udp6->ai_addr;
266 nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen;
267 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_udp6, &nb_udp6)) ||
268 (!rpcb_set(RPCPROG_NFS, 3, nconf_udp6, &nb_udp6)))
269 err(1, "rpcb_set udp6 failed");
270 freeaddrinfo(ai_udp6);
273 memset(&hints, 0, sizeof hints);
274 hints.ai_flags = AI_PASSIVE;
275 hints.ai_family = AF_INET;
276 hints.ai_socktype = SOCK_STREAM;
277 hints.ai_protocol = IPPROTO_TCP;
278 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp);
280 err(1, "getaddrinfo tcp: %s", gai_strerror(ecode));
281 nconf_tcp = getnetconfigent("tcp");
282 if (nconf_tcp == NULL)
283 err(1, "getnetconfigent tcp failed");
284 nb_tcp.buf = ai_tcp->ai_addr;
285 nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen;
286 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_tcp, &nb_tcp)) ||
287 (!rpcb_set(RPCPROG_NFS, 3, nconf_tcp, &nb_tcp)))
288 err(1, "rpcb_set tcp failed");
289 freeaddrinfo(ai_tcp);
291 if (tcpflag && ip6flag) {
292 memset(&hints, 0, sizeof hints);
293 hints.ai_flags = AI_PASSIVE;
294 hints.ai_family = AF_INET6;
295 hints.ai_socktype = SOCK_STREAM;
296 hints.ai_protocol = IPPROTO_TCP;
297 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp6);
299 err(1, "getaddrinfo tcp6: %s", gai_strerror(ecode));
300 nconf_tcp6 = getnetconfigent("tcp6");
301 if (nconf_tcp6 == NULL)
302 err(1, "getnetconfigent tcp6 failed");
303 nb_tcp6.buf = ai_tcp6->ai_addr;
304 nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen;
305 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_tcp6, &nb_tcp6)) ||
306 (!rpcb_set(RPCPROG_NFS, 3, nconf_tcp6, &nb_tcp6)))
307 err(1, "rpcb_set tcp6 failed");
308 freeaddrinfo(ai_tcp6);
314 (void)signal(SIGHUP, SIG_IGN);
315 (void)signal(SIGINT, SIG_IGN);
317 * nfsd sits in the kernel most of the time. It needs
318 * to ignore SIGTERM/SIGQUIT in order to stay alive as long
319 * as possible during a shutdown, otherwise loopback
320 * mounts will not be able to unmount.
322 (void)signal(SIGTERM, SIG_IGN);
323 (void)signal(SIGQUIT, SIG_IGN);
325 (void)signal(SIGSYS, nonfs);
326 (void)signal(SIGCHLD, reapchild);
328 openlog("nfsd", LOG_PID, LOG_DAEMON);
330 /* If we use UDP only, we start the last server below. */
331 srvcnt = tcpflag ? nfsdcnt : nfsdcnt - 1;
332 for (i = 0; i < srvcnt; i++) {
333 switch ((pid = fork())) {
335 syslog(LOG_ERR, "fork: %m");
343 (void)signal(SIGUSR1, child_cleanup);
344 setproctitle("server");
349 (void)signal(SIGUSR1, cleanup);
355 /* Set up the socket for udp and rpcb register it. */
358 for (i = 0; i < bindhostc; i++) {
359 memset(&hints, 0, sizeof hints);
360 hints.ai_flags = AI_PASSIVE;
361 hints.ai_family = AF_INET;
362 hints.ai_socktype = SOCK_DGRAM;
363 hints.ai_protocol = IPPROTO_UDP;
364 if (setbindhost(&ai_udp, bindhost[i], hints) == 0) {
367 if ((sock = socket(ai_udp->ai_family,
369 ai_udp->ai_protocol)) < 0) {
371 "can't create udp socket");
374 if (bind(sock, ai_udp->ai_addr,
375 ai_udp->ai_addrlen) < 0) {
377 "can't bind udp addr %s: %m",
381 freeaddrinfo(ai_udp);
382 nfsdargs.sock = sock;
383 nfsdargs.name = NULL;
384 nfsdargs.namelen = 0;
385 if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
386 syslog(LOG_ERR, "can't Add UDP socket");
393 memset(&hints, 0, sizeof hints);
394 hints.ai_flags = AI_PASSIVE;
395 hints.ai_family = AF_INET;
396 hints.ai_socktype = SOCK_DGRAM;
397 hints.ai_protocol = IPPROTO_UDP;
398 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp);
400 syslog(LOG_ERR, "getaddrinfo udp: %s",
401 gai_strerror(ecode));
404 nconf_udp = getnetconfigent("udp");
405 if (nconf_udp == NULL)
406 err(1, "getnetconfigent udp failed");
407 nb_udp.buf = ai_udp->ai_addr;
408 nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
409 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_udp, &nb_udp)) ||
410 (!rpcb_set(RPCPROG_NFS, 3, nconf_udp, &nb_udp)))
411 err(1, "rpcb_set udp failed");
412 freeaddrinfo(ai_udp);
416 /* Set up the socket for udp6 and rpcb register it. */
417 if (udpflag && ip6flag) {
419 for (i = 0; i < bindhostc; i++) {
420 memset(&hints, 0, sizeof hints);
421 hints.ai_flags = AI_PASSIVE;
422 hints.ai_family = AF_INET6;
423 hints.ai_socktype = SOCK_DGRAM;
424 hints.ai_protocol = IPPROTO_UDP;
425 if (setbindhost(&ai_udp6, bindhost[i], hints) == 0) {
428 if ((sock = socket(ai_udp6->ai_family,
429 ai_udp6->ai_socktype,
430 ai_udp6->ai_protocol)) < 0) {
432 "can't create udp6 socket");
435 if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
436 &on, sizeof on) < 0) {
438 "can't set v6-only binding for "
442 if (bind(sock, ai_udp6->ai_addr,
443 ai_udp6->ai_addrlen) < 0) {
445 "can't bind udp6 addr %s: %m",
449 freeaddrinfo(ai_udp6);
450 nfsdargs.sock = sock;
451 nfsdargs.name = NULL;
452 nfsdargs.namelen = 0;
453 if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
455 "can't add UDP6 socket");
462 memset(&hints, 0, sizeof hints);
463 hints.ai_flags = AI_PASSIVE;
464 hints.ai_family = AF_INET6;
465 hints.ai_socktype = SOCK_DGRAM;
466 hints.ai_protocol = IPPROTO_UDP;
467 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp6);
469 syslog(LOG_ERR, "getaddrinfo udp6: %s",
470 gai_strerror(ecode));
473 nconf_udp6 = getnetconfigent("udp6");
474 if (nconf_udp6 == NULL)
475 err(1, "getnetconfigent udp6 failed");
476 nb_udp6.buf = ai_udp6->ai_addr;
477 nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen;
478 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_udp6, &nb_udp6)) ||
479 (!rpcb_set(RPCPROG_NFS, 3, nconf_udp6, &nb_udp6)))
480 err(1, "rpcb_set udp6 failed");
481 freeaddrinfo(ai_udp6);
485 /* Set up the socket for tcp and rpcb register it. */
488 for (i = 0; i < bindhostc; i++) {
489 memset(&hints, 0, sizeof hints);
490 hints.ai_flags = AI_PASSIVE;
491 hints.ai_family = AF_INET;
492 hints.ai_socktype = SOCK_STREAM;
493 hints.ai_protocol = IPPROTO_TCP;
494 if (setbindhost(&ai_tcp, bindhost[i], hints) == 0) {
497 if ((tcpsock = socket(AF_INET, SOCK_STREAM,
500 "can't create tpc socket");
503 if (setsockopt(tcpsock, SOL_SOCKET,
505 (char *)&on, sizeof(on)) < 0)
507 "setsockopt SO_REUSEADDR: %m");
508 if (bind(tcpsock, ai_tcp->ai_addr,
509 ai_tcp->ai_addrlen) < 0) {
511 "can't bind tcp addr %s: %m",
515 if (listen(tcpsock, 5) < 0) {
516 syslog(LOG_ERR, "listen failed");
519 freeaddrinfo(ai_tcp);
520 FD_SET(tcpsock, &sockbits);
521 FD_SET(tcpsock, &v4bits);
527 memset(&hints, 0, sizeof hints);
528 hints.ai_flags = AI_PASSIVE;
529 hints.ai_family = AF_INET;
530 hints.ai_socktype = SOCK_STREAM;
531 hints.ai_protocol = IPPROTO_TCP;
532 ecode = getaddrinfo(NULL, "nfs", &hints,
535 syslog(LOG_ERR, "getaddrinfo tcp: %s",
536 gai_strerror(ecode));
539 nconf_tcp = getnetconfigent("tcp");
540 if (nconf_tcp == NULL)
541 err(1, "getnetconfigent tcp failed");
542 nb_tcp.buf = ai_tcp->ai_addr;
543 nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen;
544 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_tcp,
545 &nb_tcp)) || (!rpcb_set(RPCPROG_NFS, 3,
546 nconf_tcp, &nb_tcp)))
547 err(1, "rpcb_set tcp failed");
548 freeaddrinfo(ai_tcp);
552 /* Set up the socket for tcp6 and rpcb register it. */
553 if (tcpflag && ip6flag) {
555 for (i = 0; i < bindhostc; i++) {
556 memset(&hints, 0, sizeof hints);
557 hints.ai_flags = AI_PASSIVE;
558 hints.ai_family = AF_INET6;
559 hints.ai_socktype = SOCK_STREAM;
560 hints.ai_protocol = IPPROTO_TCP;
561 if (setbindhost(&ai_tcp6, bindhost[i], hints) == 0) {
564 if ((tcp6sock = socket(ai_tcp6->ai_family,
565 ai_tcp6->ai_socktype,
566 ai_tcp6->ai_protocol)) < 0) {
568 "can't create tcp6 socket");
571 if (setsockopt(tcp6sock, SOL_SOCKET,
573 (char *)&on, sizeof(on)) < 0)
575 "setsockopt SO_REUSEADDR: %m");
576 if (setsockopt(tcp6sock, IPPROTO_IPV6,
577 IPV6_V6ONLY, &on, sizeof on) < 0) {
579 "can't set v6-only binding for tcp6 "
583 if (bind(tcp6sock, ai_tcp6->ai_addr,
584 ai_tcp6->ai_addrlen) < 0) {
586 "can't bind tcp6 addr %s: %m",
590 if (listen(tcp6sock, 5) < 0) {
591 syslog(LOG_ERR, "listen failed");
594 freeaddrinfo(ai_tcp6);
595 FD_SET(tcp6sock, &sockbits);
596 FD_SET(tcp6sock, &v6bits);
597 if (maxsock < tcp6sock)
603 memset(&hints, 0, sizeof hints);
604 hints.ai_flags = AI_PASSIVE;
605 hints.ai_family = AF_INET6;
606 hints.ai_socktype = SOCK_STREAM;
607 hints.ai_protocol = IPPROTO_TCP;
608 ecode = getaddrinfo(NULL, "nfs", &hints, &ai_tcp6);
610 syslog(LOG_ERR, "getaddrinfo tcp6: %s",
611 gai_strerror(ecode));
614 nconf_tcp6 = getnetconfigent("tcp6");
615 if (nconf_tcp6 == NULL)
616 err(1, "getnetconfigent tcp6 failed");
617 nb_tcp6.buf = ai_tcp6->ai_addr;
618 nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen;
619 if ((!rpcb_set(RPCPROG_NFS, 2, nconf_tcp6, &nb_tcp6)) ||
620 (!rpcb_set(RPCPROG_NFS, 3, nconf_tcp6, &nb_tcp6)))
621 err(1, "rpcb_set tcp6 failed");
622 freeaddrinfo(ai_tcp6);
626 if (rpcbregcnt == 0) {
627 syslog(LOG_ERR, "rpcb_set() failed, nothing to do: %m");
631 if (tcpflag && connect_type_cnt == 0) {
632 syslog(LOG_ERR, "tcp connects == 0, nothing to do: %m");
636 setproctitle("master");
638 * We always want a master to have a clean way to to shut nfsd down
639 * (with unregistration): if the master is killed, it unregisters and
640 * kills all children. If we run for UDP only (and so do not have to
641 * loop waiting waiting for accept), we instead make the parent
642 * a "server" too. start_server will not return.
648 * Loop forever accepting connections and passing the sockets
649 * into the kernel for the mounts.
653 if (connect_type_cnt > 1) {
654 if (select(maxsock + 1,
655 &ready, NULL, NULL, NULL) < 1) {
656 syslog(LOG_ERR, "select failed: %m");
662 for (tcpsock = 0; tcpsock <= maxsock; tcpsock++) {
663 if (FD_ISSET(tcpsock, &ready)) {
664 if (FD_ISSET(tcpsock, &v4bits)) {
665 len = sizeof(inetpeer);
666 if ((msgsock = accept(tcpsock,
667 (struct sockaddr *)&inetpeer, &len)) < 0) {
668 syslog(LOG_ERR, "accept failed: %m");
669 if (errno == ECONNABORTED ||
674 memset(inetpeer.sin_zero, 0,
675 sizeof(inetpeer.sin_zero));
676 if (setsockopt(msgsock, SOL_SOCKET,
677 SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
679 "setsockopt SO_KEEPALIVE: %m");
680 nfsdargs.sock = msgsock;
681 nfsdargs.name = (caddr_t)&inetpeer;
682 nfsdargs.namelen = len;
683 nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
684 (void)close(msgsock);
685 } else if (FD_ISSET(tcpsock, &v6bits)) {
686 len = sizeof(inet6peer);
687 if ((msgsock = accept(tcpsock,
688 (struct sockaddr *)&inet6peer,
691 "accept failed: %m");
692 if (errno == ECONNABORTED ||
697 if (setsockopt(msgsock, SOL_SOCKET,
698 SO_KEEPALIVE, (char *)&on,
700 syslog(LOG_ERR, "setsockopt "
702 nfsdargs.sock = msgsock;
703 nfsdargs.name = (caddr_t)&inet6peer;
704 nfsdargs.namelen = len;
705 nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
706 (void)close(msgsock);
714 setbindhost(struct addrinfo **ai, const char *bindhost, struct addrinfo hints)
717 u_int32_t host_addr[4]; /* IPv4 or IPv6 */
720 if (bindhost == NULL || strcmp("*", bindhost) == 0)
725 if (hostptr != NULL) {
726 switch (hints.ai_family) {
728 if (inet_pton(AF_INET, hostptr, host_addr) == 1) {
729 hints.ai_flags = AI_NUMERICHOST;
731 if (inet_pton(AF_INET6, hostptr,
737 if (inet_pton(AF_INET6, hostptr, host_addr) == 1) {
738 hints.ai_flags = AI_NUMERICHOST;
740 if (inet_pton(AF_INET, hostptr,
750 ecode = getaddrinfo(hostptr, "nfs", &hints, ai);
752 syslog(LOG_ERR, "getaddrinfo %s: %s", bindhost,
753 gai_strerror(ecode));
762 (void)fprintf(stderr, "usage: nfsd %s\n", USAGE);
770 syslog(LOG_ERR, "missing system call: NFS not available");
780 while ((pid = wait3(NULL, WNOHANG, NULL)) > 0) {
781 for (i = 0; i < nfsdcnt; i++)
782 if (pid == children[i])
790 if ((!rpcb_unset(RPCPROG_NFS, 2, NULL)) ||
791 (!rpcb_unset(RPCPROG_NFS, 3, NULL)))
792 syslog(LOG_ERR, "rpcb_unset failed");
800 for (i = 0; i < nfsdcnt; i++) {
802 kill(children[i], SIGKILL);
807 * Cleanup master after SIGUSR1.
816 * Cleanup child after SIGUSR1.
825 nfsd_exit(int status)
833 start_server(int master)
838 if (nfssvc(NFSSVC_NFSD, NULL) < 0) {
839 syslog(LOG_ERR, "nfssvc: %m");