]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/nfsd/nfsd.c
Autogen update
[nfs-utils.git] / utils / nfsd / nfsd.c
index 772f72df54693751550eac1c9fbe978d427720b9..05506ee4ae6c2900fbd2fb4b62749f0789424959 100644 (file)
@@ -7,7 +7,9 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -17,6 +19,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <syslog.h>
+#include <netdb.h>
 #include "nfslib.h"
 
 static void    usage(const char *);
@@ -25,10 +28,13 @@ int
 main(int argc, char **argv)
 {
        int     count = 1, c, error, port, fd;
+       struct servent *ent;
 
-       port = 2049;
-
-       /* FIXME: Check for nfs in /etc/services */
+       ent = getservbyname ("nfs", "udp");
+       if (ent != NULL)
+               port = ntohs (ent->s_port);
+       else
+               port = 2049;
 
        while ((c = getopt(argc, argv, "hp:P:")) != EOF) {
                switch(c) {
@@ -76,9 +82,7 @@ main(int argc, char **argv)
                (void) dup2(fd, 1);
                (void) dup2(fd, 2);
        }
-       fd = sysconf(_SC_OPEN_MAX);
-       while (--fd > 2)
-               (void) close(fd);
+       closeall(3);
 
        if ((error = nfssvc(port, count)) < 0) {
                int e = errno;