]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/nfsd/nfsd.c
Updated to nfs-utils 0.1.1.
[nfs-utils.git] / utils / nfsd / nfsd.c
1 /*
2  * nfsd
3  *
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.
6  *
7  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8  */
9
10 #include "config.h"
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <getopt.h>
15 #include "nfslib.h"
16
17 static void     usage(const char *);
18
19 int
20 main(int argc, char **argv)
21 {
22         int     count = 1, c, error, port;
23
24         port = 2049;
25
26         /* FIXME: Check for nfs in /etc/services */
27
28         while ((c = getopt(argc, argv, "hp:P:")) != EOF) {
29                 switch(c) {
30                 case 'P':       /* XXX for nfs-server compatibility */
31                 case 'p':
32                         port = atoi(optarg);
33                         if (port <= 0 || port > 65535) {
34                                 fprintf(stderr, "%s: bad port number: %s\n",
35                                         argv[0], optarg);
36                                 usage(argv [0]);
37                         }
38                         break;
39                         break;
40                 case 'h':
41                 default:
42                         usage(argv[0]);
43                 }
44         }
45
46         if (optind < argc) {
47                 if ((count = atoi(argv[optind])) < 0) {
48                         /* insane # of servers */
49                         fprintf(stderr,
50                                 "%s: invalid server count (%d), using 1\n",
51                                 argv[0], count);
52                         count = 1;
53                 }
54         }
55
56         if ((error = nfssvc(port, count)) < 0)
57                 perror("nfssvc");
58
59         return (error != 0);
60 }
61
62 static void
63 usage(const char *prog)
64 {
65         fprintf(stderr, "usage:\n"
66                         "%s nrservs\n", prog);
67         exit(2);
68 }