]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
nfsd: allow choosing server 41 support at runtime
authorJ. Bruce Fields <bfields@citi.umich.edu>
Tue, 20 Sep 2011 11:40:15 +0000 (07:40 -0400)
committerLuk Claes <luk@debian.org>
Sun, 2 Oct 2011 14:16:48 +0000 (16:16 +0200)
In the case where -N 4.1 is left off the commandline, the current code
explicitly turns it on or off anyway, depending on configure options.

Instead, just leave 4.1 support alone.  This allows a user to add an
"echo +4.1 >/proc/fs/nfsd/versions" to their init scripts, if they want.
Otherwise they will get the kernel's default (currently to leave 4.1
off, as long as 4.1 support is experimental).

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/include/nfs/nfs.h
utils/nfsd/nfsd.c
utils/nfsd/nfssvc.c

index c939d78105b6599857d659b9ba99178e85c98aa4..320880ea7bc9c9f38d2f8a9dfa44ca744ed19c9d 100644 (file)
 #define NFSD_MINVERS 2
 #define NFSD_MAXVERS 4
 
-#define NFSD_MINMINORVERS4 1
-#ifdef  NFS41_SUPPORTED
-#define NFSD_MAXMINORVERS4 1
-#else
-#define NFSD_MAXMINORVERS4 0
-#endif
-
 struct nfs_fh_len {
        int             fh_size;
        u_int8_t        fh_handle[NFS3_FHSIZE];
index e7e1470d3c9ef2a9e20f8f915761d8eac4bf58ea..8bc5d3ad9afc5b962164d188354c8587d29b545c 100644 (file)
@@ -94,7 +94,7 @@ main(int argc, char **argv)
        char *p, *progname, *port;
        char *haddr = NULL;
        int     socket_up = 0;
-       int minorvers4 = NFSD_MAXMINORVERS4;    /* nfsv4 minor version */
+       int minorvers41 = 0;    /* nfsv4 minor version */
        unsigned int versbits = NFSCTL_ALLBITS;
        unsigned int protobits = NFSCTL_ALLBITS;
        unsigned int proto4 = 0;
@@ -154,7 +154,12 @@ main(int argc, char **argv)
                        switch((c = strtol(optarg, &p, 0))) {
                        case 4:
                                if (*p == '.') {
-                                       minorvers4 = -atoi(p + 1);
+                                       int i = atoi(p+1);
+                                       if (i != 1) {
+                                               fprintf(stderr, "%s: unsupported minor version\n", optarg);
+                                               exit(1);
+                                       }
+                                       minorvers41 = -1;
                                        break;
                                }
                        case 3:
@@ -251,7 +256,7 @@ main(int argc, char **argv)
         * registered with rpcbind. Note that on older kernels w/o the right
         * interfaces, these are a no-op.
         */
-       nfssvc_setvers(versbits, minorvers4);
+       nfssvc_setvers(versbits, minorvers41);
  
        error = nfssvc_set_sockets(AF_INET, proto4, haddr, port);
        if (!error)
index f60721450dc7b40054306d9717bff3417f04aa2a..683008e291c6bff1016b365789d3401b5380604c 100644 (file)
@@ -269,7 +269,7 @@ nfssvc_set_sockets(const int family, const unsigned int protobits,
 }
 
 void
-nfssvc_setvers(unsigned int ctlbits, int minorvers4)
+nfssvc_setvers(unsigned int ctlbits, int minorvers41)
 {
        int fd, n, off;
        char *ptr;
@@ -280,11 +280,9 @@ nfssvc_setvers(unsigned int ctlbits, int minorvers4)
        if (fd < 0)
                return;
 
-       n = minorvers4 >= 0 ? minorvers4 : -minorvers4;
-       if (n >= NFSD_MINMINORVERS4 && n <= NFSD_MAXMINORVERS4)
-                   off += snprintf(ptr+off, sizeof(buf) - off, "%c4.%d ",
-                                   minorvers4 > 0 ? '+' : '-',
-                                   n);
+       if (minorvers41)
+               off += snprintf(ptr+off, sizeof(buf) - off, "%c4.1",
+                               minorvers41 > 0 ? '+' : '-');
        for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
                if (NFSCTL_VERISSET(ctlbits, n))
                    off += snprintf(ptr+off, sizeof(buf) - off, "+%d ", n);