diff options
author | Steve Dickson <SteveD@redhat.com> | 2006-06-26 15:23:19 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-06-26 15:23:19 +1000 |
commit | fde2ae7794047a698feeaf17963d690a1e660a80 (patch) | |
tree | 3fec36ef5414306769e9c0c9e0e7833636e30b87 /utils | |
parent | 0523fd513c6baa8dbf45d1a7afea2044262aeb3d (diff) | |
download | nfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.tar.gz nfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.tar.xz nfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.zip |
Add support for suppressing different NFS versions.
e.g. -N 2
means that NFSv2 won't be supported, just v3 and v4 (if the kernel
supports them).
Diffstat (limited to 'utils')
-rw-r--r-- | utils/nfsd/nfsd.c | 48 | ||||
-rw-r--r-- | utils/nfsd/nfsd.man | 11 |
2 files changed, 49 insertions, 10 deletions
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index 05506ee..fa6ee71 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -24,10 +24,18 @@ static void usage(const char *); +static struct option longopts[] = +{ + { "help", 0, 0, 'h' }, + { "no-nfs-version", 1, 0, 'N' }, + { NULL, 0, 0, 0 } +}; +unsigned int versbits = NFSCTL_ALLBITS; + int main(int argc, char **argv) { - int count = 1, c, error, port, fd; + int count = 1, c, error, port, fd, found_one; struct servent *ent; ent = getservbyname ("nfs", "udp"); @@ -36,7 +44,7 @@ main(int argc, char **argv) else port = 2049; - while ((c = getopt(argc, argv, "hp:P:")) != EOF) { + while ((c = getopt_long(argc, argv, "hN:p:P:", longopts, NULL)) != EOF) { switch(c) { case 'P': /* XXX for nfs-server compatibility */ case 'p': @@ -47,12 +55,36 @@ main(int argc, char **argv) usage(argv [0]); } break; + case 'N': + switch((c = atoi(optarg))) { + case 2: + case 3: + case 4: + NFSCTL_VERUNSET(versbits, c); + break; + default: + fprintf(stderr, "%c: Unsupported version\n", c); + exit(1); + } break; - case 'h': default: + fprintf(stderr, "Invalid argument: '%c'\n", c); + case 'h': usage(argv[0]); } } + /* + * Do some sanity checking, if the ctlbits are set + */ + found_one = 0; + for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) { + if (NFSCTL_VERISSET(versbits, c)) + found_one = 1; + } + if (!found_one) { + fprintf(stderr, "no version specified\n"); + exit(1); + } if (chdir(NFS_STATEDIR)) { fprintf(stderr, "%s: chdir(%s) failed: %s\n", @@ -69,7 +101,6 @@ main(int argc, char **argv) count = 1; } } - /* KLUDGE ALERT: Some kernels let nfsd kernel threads inherit open files from the program that spawns them (i.e. us). So close @@ -84,9 +115,9 @@ main(int argc, char **argv) } closeall(3); - if ((error = nfssvc(port, count)) < 0) { + openlog("nfsd", LOG_PID, LOG_DAEMON); + if ((error = nfssvc(port, count, versbits)) < 0) { int e = errno; - openlog("nfsd", LOG_PID, LOG_DAEMON); syslog(LOG_ERR, "nfssvc: %s", strerror(e)); closelog(); } @@ -97,7 +128,8 @@ main(int argc, char **argv) static void usage(const char *prog) { - fprintf(stderr, "usage:\n" - "%s nrservs\n", prog); + fprintf(stderr, "Usage:\n" + "%s [-p|-P|--port port] [-N|--no-nfs-version version ] nrservs\n", + prog); exit(2); } diff --git a/utils/nfsd/nfsd.man b/utils/nfsd/nfsd.man index a890ea6..d175d11 100644 --- a/utils/nfsd/nfsd.man +++ b/utils/nfsd/nfsd.man @@ -6,7 +6,7 @@ .SH NAME rpc.nfsd \- NFS server process .SH SYNOPSIS -.BI "/usr/sbin/rpc.nfsd [-p " port "] " nproc +.BI "/usr/sbin/rpc.nfsd [" options "]" " "nproc .SH DESCRIPTION The .B rpc.nfsd @@ -22,11 +22,18 @@ server provides an ancillary service needed to satisfy mount requests by NFS clients. .SH OPTIONS .TP -.BI \-p " port" +.B \-p " or " \-\-port port specify a diferent port to listen on for NFS requests. By default, .B rpc.nfsd will listen on port 2049. .TP +.B \-N " or " \-\-no-nfs-version vers +This option can be used to request that +.B rpc.nfsd +does not offer certain versions of NFS. The current version of +.B rpc.nfsd +can support both NFS version 2,3 and the newer version 4. +.TP .I nproc specify the number of NFS server threads. By default, just one thread is started. However, for optimum performance several threads |