]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
utils/nfsd: add support for minorvers4
authorBenny Halevy <bhalevy@panasas.com>
Mon, 4 May 2009 15:44:49 +0000 (11:44 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 4 May 2009 15:44:49 +0000 (11:44 -0400)
minorvers4 can be used to either enable or disable nfsv4.x.

If minorvers4 is a positive integer n, in the allowed range (only
minorversion 1 is supported for now), the string "+4.n" is appended
to the versions string written onto /proc/fs/nfsd/versions.

Correspondingly, if minorver4 is a negative integer -n, the string
"-4.n" is written.

With the default value, minorvers4==0, the minor version
setting is not changed.

Note that unlike the protocol versions 2, 3, or 4.  The minor version
setting controls the *maximum* minor version nfsd supports.  Particular
minor version cannot be controlled on their own.  With only minor
version 1 supported at the moment the difference doesn't matter,
but for future minor versions greater than 1, enabling minor
version X will enable support for all minor versions 1 through X.
Disabling minor version X will disable support for minor
versions X and up, enabling 1 through X-1.

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/include/nfs/nfs.h
support/include/nfslib.h
support/nfs/nfssvc.c
utils/nfsd/nfsd.c

index fc26f4ec10a58500343455c59f5cbaaf27fde24b..00b00280fa0b87e18d5ef31989d481c50b6d30ec 100644 (file)
@@ -13,6 +13,9 @@
 #define NFSD_MINVERS 2
 #define NFSD_MAXVERS 4
 
 #define NFSD_MINVERS 2
 #define NFSD_MAXVERS 4
 
+#define NFSD_MINMINORVERS4 1
+#define NFSD_MAXMINORVERS4 1
+
 struct nfs_fh_len {
        int             fh_size;
        u_int8_t        fh_handle[NFS3_FHSIZE];
 struct nfs_fh_len {
        int             fh_size;
        u_int8_t        fh_handle[NFS3_FHSIZE];
index 9d0d39d438d2c19872c313d59529a06ebd639109..ae986509291baafd6a7ceeb261d6bfb73209aa5a 100644 (file)
@@ -130,7 +130,7 @@ int                 wildmat(char *text, char *pattern);
  * nfsd library functions.
  */
 int                    nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
  * nfsd library functions.
  */
 int                    nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
-int                    nfssvc(int port, int nrservs, unsigned int versbits, unsigned int portbits, char *haddr);
+int                    nfssvc(int port, int nrservs, unsigned int versbits, int minorvers4, unsigned int portbits, char *haddr);
 int                    nfsaddclient(struct nfsctl_client *clp);
 int                    nfsdelclient(struct nfsctl_client *clp);
 int                    nfsexport(struct nfsctl_export *exp);
 int                    nfsaddclient(struct nfsctl_client *clp);
 int                    nfsdelclient(struct nfsctl_client *clp);
 int                    nfsexport(struct nfsctl_export *exp);
index 9bbc9a5195d4ad4012bcd626977d321aa1c94c03..33c15a7acbdaf113daf1a47cd7952ccd5eaf62cd 100644 (file)
@@ -116,7 +116,7 @@ nfssvc_setfds(int port, unsigned int ctlbits, char *haddr)
        return;
 }
 static void
        return;
 }
 static void
-nfssvc_versbits(unsigned int ctlbits)
+nfssvc_versbits(unsigned int ctlbits, int minorvers4)
 {
        int fd, n, off;
        char buf[BUFSIZ], *ptr;
 {
        int fd, n, off;
        char buf[BUFSIZ], *ptr;
@@ -133,6 +133,11 @@ nfssvc_versbits(unsigned int ctlbits)
                else
                    off += snprintf(ptr+off, BUFSIZ - off, "-%d ", n);
        }
                else
                    off += snprintf(ptr+off, BUFSIZ - off, "-%d ", n);
        }
+       n = minorvers4 >= 0 ? minorvers4 : -minorvers4;
+       if (n >= NFSD_MINMINORVERS4 && n <= NFSD_MAXMINORVERS4)
+                   off += snprintf(ptr+off, BUFSIZ - off, "%c4.%d",
+                                   minorvers4 > 0 ? '+' : '-',
+                                   n);
        snprintf(ptr+off, BUFSIZ - off, "\n");
        if (write(fd, buf, strlen(buf)) != strlen(buf)) {
                syslog(LOG_ERR, "nfssvc: Setting version failed: errno %d (%s)", 
        snprintf(ptr+off, BUFSIZ - off, "\n");
        if (write(fd, buf, strlen(buf)) != strlen(buf)) {
                syslog(LOG_ERR, "nfssvc: Setting version failed: errno %d (%s)", 
@@ -143,8 +148,8 @@ nfssvc_versbits(unsigned int ctlbits)
        return;
 }
 int
        return;
 }
 int
-nfssvc(int port, int nrservs, unsigned int versbits, unsigned protobits,
-       char *haddr)
+nfssvc(int port, int nrservs, unsigned int versbits, int minorvers4,
+       unsigned protobits, char *haddr)
 {
        struct nfsctl_arg       arg;
        int fd;
 {
        struct nfsctl_arg       arg;
        int fd;
@@ -153,7 +158,7 @@ nfssvc(int port, int nrservs, unsigned int versbits, unsigned protobits,
         * the ports get registered with portmap against correct
         * versions
         */
         * the ports get registered with portmap against correct
         * versions
         */
-       nfssvc_versbits(versbits);
+       nfssvc_versbits(versbits, minorvers4);
        nfssvc_setfds(port, protobits, haddr);
 
        fd = open(NFSD_THREAD_FILE, O_WRONLY);
        nfssvc_setfds(port, protobits, haddr);
 
        fd = open(NFSD_THREAD_FILE, O_WRONLY);
index c97c81f83f919d414734739904c44470825ae067..ac264da28c6041cacf8ad0c2ab2c98c4e66782a7 100644 (file)
@@ -41,6 +41,7 @@ static struct option longopts[] =
 };
 unsigned int protobits = NFSCTL_ALLBITS;
 unsigned int versbits = NFSCTL_ALLBITS;
 };
 unsigned int protobits = NFSCTL_ALLBITS;
 unsigned int versbits = NFSCTL_ALLBITS;
+int minorvers4;                                /* nfsv4 minor version */
 char *haddr = NULL;
 
 int
 char *haddr = NULL;
 
 int
@@ -158,7 +159,7 @@ main(int argc, char **argv)
        closeall(3);
 
        openlog("nfsd", LOG_PID, LOG_DAEMON);
        closeall(3);
 
        openlog("nfsd", LOG_PID, LOG_DAEMON);
-       if ((error = nfssvc(port, count, versbits, protobits, haddr)) < 0) {
+       if ((error = nfssvc(port, count, versbits, minorvers4, protobits, haddr)) < 0) {
                int e = errno;
                syslog(LOG_ERR, "nfssvc: %s", strerror(e));
                closelog();
                int e = errno;
                syslog(LOG_ERR, "nfssvc: %s", strerror(e));
                closelog();