4 * This is the user level part of nfsd. This is very primitive, because
5 * all the work is now done in the kernel module.
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
25 static void usage(const char *);
27 static struct option longopts[] =
29 { "help", 0, 0, 'h' },
30 { "no-nfs-version", 1, 0, 'N' },
33 unsigned int versbits = NFSCTL_ALLBITS;
36 main(int argc, char **argv)
38 int count = 1, c, error, port, fd, found_one;
41 ent = getservbyname ("nfs", "udp");
43 port = ntohs (ent->s_port);
47 while ((c = getopt_long(argc, argv, "hN:p:P:", longopts, NULL)) != EOF) {
49 case 'P': /* XXX for nfs-server compatibility */
52 if (port <= 0 || port > 65535) {
53 fprintf(stderr, "%s: bad port number: %s\n",
59 switch((c = atoi(optarg))) {
63 NFSCTL_VERUNSET(versbits, c);
66 fprintf(stderr, "%c: Unsupported version\n", c);
71 fprintf(stderr, "Invalid argument: '%c'\n", c);
77 * Do some sanity checking, if the ctlbits are set
80 for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) {
81 if (NFSCTL_VERISSET(versbits, c))
85 fprintf(stderr, "no version specified\n");
89 if (chdir(NFS_STATEDIR)) {
90 fprintf(stderr, "%s: chdir(%s) failed: %s\n",
91 argv [0], NFS_STATEDIR, strerror(errno));
96 if ((count = atoi(argv[optind])) < 0) {
97 /* insane # of servers */
99 "%s: invalid server count (%d), using 1\n",
105 Some kernels let nfsd kernel threads inherit open files
106 from the program that spawns them (i.e. us). So close
107 everything before spawning kernel threads. --Chip */
108 fd = open("/dev/null", O_RDWR);
118 openlog("nfsd", LOG_PID, LOG_DAEMON);
119 if ((error = nfssvc(port, count, versbits)) < 0) {
121 syslog(LOG_ERR, "nfssvc: %s", strerror(e));
129 usage(const char *prog)
131 fprintf(stderr, "Usage:\n"
132 "%s [-p|-P|--port port] [-N|--no-nfs-version version ] nrservs\n",