|
|
6006dc |
diff -up nfs-utils-1.3.0/support/include/nfs/nfs.h.orig nfs-utils-1.3.0/support/include/nfs/nfs.h
|
|
|
6006dc |
--- nfs-utils-1.3.0/support/include/nfs/nfs.h.orig 2018-08-20 14:18:13.975034097 -0400
|
|
|
6006dc |
+++ nfs-utils-1.3.0/support/include/nfs/nfs.h 2018-08-20 14:18:29.624303893 -0400
|
|
|
6006dc |
@@ -16,8 +16,8 @@
|
|
|
6006dc |
#define NFSD_MINVERS 2
|
|
|
6006dc |
#define NFSD_MAXVERS 4
|
|
|
6006dc |
|
|
|
6006dc |
-#define NFS4_MINMINOR 1
|
|
|
6006dc |
-#define NFS4_MAXMINOR WORD_BIT
|
|
|
6006dc |
+#define NFS4_MINMINOR 0
|
|
|
6006dc |
+#define NFS4_MAXMINOR (WORD_BIT-1)
|
|
|
6006dc |
|
|
|
6006dc |
struct nfs_fh_len {
|
|
|
6006dc |
int fh_size;
|
|
|
6006dc |
@@ -49,16 +49,19 @@ struct nfs_fh_old {
|
|
|
6006dc |
#define NFSCTL_TCPBIT (1 << (18 - 1))
|
|
|
6006dc |
|
|
|
6006dc |
#define NFSCTL_VERUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1)))
|
|
|
6006dc |
+#define NFSCTL_MINORUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << (_v)))
|
|
|
6006dc |
#define NFSCTL_UDPUNSET(_cltbits) ((_cltbits) &= ~NFSCTL_UDPBIT)
|
|
|
6006dc |
#define NFSCTL_TCPUNSET(_cltbits) ((_cltbits) &= ~NFSCTL_TCPBIT)
|
|
|
6006dc |
|
|
|
6006dc |
#define NFSCTL_VERISSET(_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1)))
|
|
|
6006dc |
+#define NFSCTL_MINORISSET(_cltbits, _v) ((_cltbits) & (1 << (_v)))
|
|
|
6006dc |
#define NFSCTL_UDPISSET(_cltbits) ((_cltbits) & NFSCTL_UDPBIT)
|
|
|
6006dc |
#define NFSCTL_TCPISSET(_cltbits) ((_cltbits) & NFSCTL_TCPBIT)
|
|
|
6006dc |
|
|
|
6006dc |
#define NFSCTL_VERDEFAULT (0xc) /* versions 3 and 4 */
|
|
|
6006dc |
#define NFSCTL_MINDEFAULT (0x7) /* minor versions 4.1 and 4.2 */
|
|
|
6006dc |
#define NFSCTL_VERSET(_cltbits, _v) ((_cltbits) |= (1 << ((_v) - 1)))
|
|
|
6006dc |
+#define NFSCTL_MINORSET(_cltbits, _v) ((_cltbits) |= (1 << (_v)))
|
|
|
6006dc |
#define NFSCTL_UDPSET(_cltbits) ((_cltbits) |= NFSCTL_UDPBIT)
|
|
|
6006dc |
#define NFSCTL_TCPSET(_cltbits) ((_cltbits) |= NFSCTL_TCPBIT)
|
|
|
6006dc |
|
|
|
6006dc |
diff -up nfs-utils-1.3.0/utils/nfsd/nfsd.c.orig nfs-utils-1.3.0/utils/nfsd/nfsd.c
|
|
|
6006dc |
--- nfs-utils-1.3.0/utils/nfsd/nfsd.c.orig 2018-08-20 14:18:13.975034097 -0400
|
|
|
6006dc |
+++ nfs-utils-1.3.0/utils/nfsd/nfsd.c 2018-08-20 14:18:58.023793505 -0400
|
|
|
6006dc |
@@ -66,10 +66,12 @@ main(int argc, char **argv)
|
|
|
6006dc |
int socket_up = 0;
|
|
|
6006dc |
unsigned int minorvers = NFSCTL_MINDEFAULT;
|
|
|
6006dc |
unsigned int minorversset = NFSCTL_MINDEFAULT;
|
|
|
6006dc |
+ unsigned int minormask = 0;
|
|
|
6006dc |
unsigned int versbits = NFSCTL_VERDEFAULT;
|
|
|
6006dc |
unsigned int protobits = NFSCTL_ALLBITS;
|
|
|
6006dc |
int grace = -1;
|
|
|
6006dc |
int lease = -1;
|
|
|
6006dc |
+ int force4dot0 = 0;
|
|
|
6006dc |
|
|
|
6006dc |
progname = basename(argv[0]);
|
|
|
6006dc |
haddr = xmalloc(sizeof(char *));
|
|
|
6006dc |
@@ -103,6 +105,8 @@ main(int argc, char **argv)
|
|
|
6006dc |
else
|
|
|
6006dc |
NFSCTL_VERUNSET(versbits, i);
|
|
|
6006dc |
}
|
|
|
6006dc |
+
|
|
|
6006dc |
+ nfssvc_get_minormask(&minormask);
|
|
|
6006dc |
/* We assume the kernel will default all minor versions to 'on',
|
|
|
6006dc |
* and allow the config file to disable some.
|
|
|
6006dc |
*/
|
|
|
6006dc |
@@ -118,12 +122,16 @@ main(int argc, char **argv)
|
|
|
6006dc |
* (i.e. don't set the bit in minorversset).
|
|
|
6006dc |
*/
|
|
|
6006dc |
if (!conf_get_bool("nfsd", tag, 1)) {
|
|
|
6006dc |
- NFSCTL_VERSET(minorversset, i);
|
|
|
6006dc |
- NFSCTL_VERUNSET(minorvers, i);
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorversset, i);
|
|
|
6006dc |
+ NFSCTL_MINORUNSET(minorvers, i);
|
|
|
6006dc |
+ if (i == 0)
|
|
|
6006dc |
+ force4dot0 = 1;
|
|
|
6006dc |
}
|
|
|
6006dc |
if (conf_get_bool("nfsd", tag, 0)) {
|
|
|
6006dc |
- NFSCTL_VERSET(minorversset, i);
|
|
|
6006dc |
- NFSCTL_VERSET(minorvers, i);
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorversset, i);
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorvers, i);
|
|
|
6006dc |
+ if (i == 0)
|
|
|
6006dc |
+ force4dot0 = 1;
|
|
|
6006dc |
}
|
|
|
6006dc |
}
|
|
|
6006dc |
|
|
|
6006dc |
@@ -178,13 +186,19 @@ main(int argc, char **argv)
|
|
|
6006dc |
case 4:
|
|
|
6006dc |
if (*p == '.') {
|
|
|
6006dc |
int i = atoi(p+1);
|
|
|
6006dc |
- if (i < NFS4_MINMINOR || i > NFS4_MAXMINOR) {
|
|
|
6006dc |
+ if (i < 0 || i > NFS4_MAXMINOR) {
|
|
|
6006dc |
fprintf(stderr, "%s: unsupported minor version\n", optarg);
|
|
|
6006dc |
exit(1);
|
|
|
6006dc |
}
|
|
|
6006dc |
- NFSCTL_VERSET(minorversset, i);
|
|
|
6006dc |
- NFSCTL_VERUNSET(minorvers, i);
|
|
|
6006dc |
- break;
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorversset, i);
|
|
|
6006dc |
+ NFSCTL_MINORUNSET(minorvers, i);
|
|
|
6006dc |
+ if (i == 0)
|
|
|
6006dc |
+ force4dot0 = 1;
|
|
|
6006dc |
+ if (minorvers != 0)
|
|
|
6006dc |
+ break;
|
|
|
6006dc |
+ } else {
|
|
|
6006dc |
+ minorvers = 0;
|
|
|
6006dc |
+ minorversset = minormask;
|
|
|
6006dc |
}
|
|
|
6006dc |
case 3:
|
|
|
6006dc |
case 2:
|
|
|
6006dc |
@@ -200,14 +214,16 @@ main(int argc, char **argv)
|
|
|
6006dc |
case 4:
|
|
|
6006dc |
if (*p == '.') {
|
|
|
6006dc |
int i = atoi(p+1);
|
|
|
6006dc |
- if (i < NFS4_MINMINOR || i > NFS4_MAXMINOR) {
|
|
|
6006dc |
+ if (i < 0 || i > NFS4_MAXMINOR) {
|
|
|
6006dc |
fprintf(stderr, "%s: unsupported minor version\n", optarg);
|
|
|
6006dc |
exit(1);
|
|
|
6006dc |
}
|
|
|
6006dc |
- NFSCTL_VERSET(minorversset, i);
|
|
|
6006dc |
- NFSCTL_VERSET(minorvers, i);
|
|
|
6006dc |
- break;
|
|
|
6006dc |
- }
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorversset, i);
|
|
|
6006dc |
+ NFSCTL_MINORSET(minorvers, i);
|
|
|
6006dc |
+ if (i == 0)
|
|
|
6006dc |
+ force4dot0 = 1;
|
|
|
6006dc |
+ } else
|
|
|
6006dc |
+ minorvers = minorversset = minormask;
|
|
|
6006dc |
case 3:
|
|
|
6006dc |
case 2:
|
|
|
6006dc |
NFSCTL_VERSET(versbits, c);
|
|
|
6006dc |
@@ -305,7 +321,7 @@ main(int argc, char **argv)
|
|
|
6006dc |
* Timeouts must also be set before ports are created else we get
|
|
|
6006dc |
* EBUSY.
|
|
|
6006dc |
*/
|
|
|
6006dc |
- nfssvc_setvers(versbits, minorvers, minorversset);
|
|
|
6006dc |
+ nfssvc_setvers(versbits, minorvers, minorversset, force4dot0);
|
|
|
6006dc |
if (grace > 0)
|
|
|
6006dc |
nfssvc_set_time("grace", grace);
|
|
|
6006dc |
if (lease > 0)
|
|
|
6006dc |
diff -up nfs-utils-1.3.0/utils/nfsd/nfsd.man.orig nfs-utils-1.3.0/utils/nfsd/nfsd.man
|
|
|
6006dc |
--- nfs-utils-1.3.0/utils/nfsd/nfsd.man.orig 2018-08-20 14:18:13.934033391 -0400
|
|
|
6006dc |
+++ nfs-utils-1.3.0/utils/nfsd/nfsd.man 2018-08-20 14:18:29.625303910 -0400
|
|
|
6006dc |
@@ -57,7 +57,7 @@ This option can be used to request that
|
|
|
6006dc |
.B rpc.nfsd
|
|
|
6006dc |
does not offer certain versions of NFS. The current version of
|
|
|
6006dc |
.B rpc.nfsd
|
|
|
6006dc |
-can support major NFS versions 2,3,4 and the minor versions 4.1 and 4.2.
|
|
|
6006dc |
+can support major NFS versions 2,3,4 and the minor versions 4.0, 4.1 and 4.2.
|
|
|
6006dc |
.TP
|
|
|
6006dc |
.B \-s " or " \-\-syslog
|
|
|
6006dc |
By default,
|
|
|
6006dc |
@@ -82,7 +82,7 @@ This option can be used to request that
|
|
|
6006dc |
.B rpc.nfsd
|
|
|
6006dc |
offer certain versions of NFS. The current version of
|
|
|
6006dc |
.B rpc.nfsd
|
|
|
6006dc |
-can support major NFS versions 2,3,4 and the minor versions 4.1 and 4.2.
|
|
|
6006dc |
+can support major NFS versions 2,3,4 and the minor versions 4.0, 4.1 and 4.2.
|
|
|
6006dc |
.TP
|
|
|
6006dc |
.B \-L " or " \-\-lease-time seconds
|
|
|
6006dc |
Set the lease-time used for NFSv4. This corresponds to how often
|
|
|
6006dc |
diff -up nfs-utils-1.3.0/utils/nfsd/nfssvc.c.orig nfs-utils-1.3.0/utils/nfsd/nfssvc.c
|
|
|
6006dc |
--- nfs-utils-1.3.0/utils/nfsd/nfssvc.c.orig 2018-08-20 14:18:13.963033891 -0400
|
|
|
6006dc |
+++ nfs-utils-1.3.0/utils/nfsd/nfssvc.c 2018-08-20 14:18:58.023793505 -0400
|
|
|
6006dc |
@@ -24,6 +24,7 @@
|
|
|
6006dc |
#include "nfslib.h"
|
|
|
6006dc |
#include "xlog.h"
|
|
|
6006dc |
#include "nfssvc.h"
|
|
|
6006dc |
+#include "../mount/version.h"
|
|
|
6006dc |
|
|
|
6006dc |
#ifndef NFSD_FS_DIR
|
|
|
6006dc |
#define NFSD_FS_DIR "/proc/fs/nfsd"
|
|
|
6006dc |
@@ -333,36 +334,81 @@ nfssvc_set_time(const char *type, const
|
|
|
6006dc |
}
|
|
|
6006dc |
|
|
|
6006dc |
void
|
|
|
6006dc |
-nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset)
|
|
|
6006dc |
+nfssvc_get_minormask(unsigned int *mask)
|
|
|
6006dc |
+{
|
|
|
6006dc |
+ int fd;
|
|
|
6006dc |
+ char *ptr = buf;
|
|
|
6006dc |
+ ssize_t size;
|
|
|
6006dc |
+
|
|
|
6006dc |
+ fd = open(NFSD_VERS_FILE, O_RDONLY);
|
|
|
6006dc |
+ if (fd < 0)
|
|
|
6006dc |
+ return;
|
|
|
6006dc |
+
|
|
|
6006dc |
+ size = read(fd, buf, sizeof(buf));
|
|
|
6006dc |
+ if (size < 0) {
|
|
|
6006dc |
+ xlog(L_ERROR, "Getting versions failed: errno %d (%m)", errno);
|
|
|
6006dc |
+ goto out;
|
|
|
6006dc |
+ }
|
|
|
6006dc |
+ ptr[size] = '\0';
|
|
|
6006dc |
+ for (;;) {
|
|
|
6006dc |
+ unsigned vers, minor = 0;
|
|
|
6006dc |
+ char *token = strtok(ptr, " ");
|
|
|
6006dc |
+
|
|
|
6006dc |
+ if (!token)
|
|
|
6006dc |
+ break;
|
|
|
6006dc |
+ ptr = NULL;
|
|
|
6006dc |
+ if (*token != '+' && *token != '-')
|
|
|
6006dc |
+ continue;
|
|
|
6006dc |
+ if (sscanf(++token, "%u.%u", &vers, &minor) > 0 &&
|
|
|
6006dc |
+ vers == 4 && minor <= NFS4_MAXMINOR)
|
|
|
6006dc |
+ NFSCTL_MINORSET(*mask, minor);
|
|
|
6006dc |
+ }
|
|
|
6006dc |
+out:
|
|
|
6006dc |
+ close(fd);
|
|
|
6006dc |
+ return;
|
|
|
6006dc |
+}
|
|
|
6006dc |
+
|
|
|
6006dc |
+static int
|
|
|
6006dc |
+nfssvc_print_vers(char *ptr, unsigned size, unsigned vers, unsigned minorvers,
|
|
|
6006dc |
+ int isset, int force4dot0)
|
|
|
6006dc |
+{
|
|
|
6006dc |
+ char sign = isset ? '+' : '-';
|
|
|
6006dc |
+ if (minorvers == 0)
|
|
|
6006dc |
+ if (linux_version_code() < MAKE_VERSION(4, 11, 0) || !force4dot0)
|
|
|
6006dc |
+ return snprintf(ptr, size, "%c%u ", sign, vers);
|
|
|
6006dc |
+ return snprintf(ptr, size, "%c%u.%u ", sign, vers, minorvers);
|
|
|
6006dc |
+}
|
|
|
6006dc |
+
|
|
|
6006dc |
+void
|
|
|
6006dc |
+nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers, unsigned int minorversset,
|
|
|
6006dc |
+ int force4dot0)
|
|
|
6006dc |
{
|
|
|
6006dc |
int fd, n, off;
|
|
|
6006dc |
- char *ptr;
|
|
|
6006dc |
|
|
|
6006dc |
- ptr = buf;
|
|
|
6006dc |
off = 0;
|
|
|
6006dc |
fd = open(NFSD_VERS_FILE, O_WRONLY);
|
|
|
6006dc |
if (fd < 0)
|
|
|
6006dc |
return;
|
|
|
6006dc |
|
|
|
6006dc |
- for (n = NFS4_MINMINOR; n <= NFS4_MAXMINOR; n++) {
|
|
|
6006dc |
- if (NFSCTL_VERISSET(minorversset, n)) {
|
|
|
6006dc |
- if (NFSCTL_VERISSET(minorvers, n))
|
|
|
6006dc |
- off += snprintf(ptr+off, sizeof(buf) - off, "+4.%d ", n);
|
|
|
6006dc |
- else
|
|
|
6006dc |
- off += snprintf(ptr+off, sizeof(buf) - off, "-4.%d ", n);
|
|
|
6006dc |
- }
|
|
|
6006dc |
- }
|
|
|
6006dc |
- for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
|
|
|
6006dc |
- if (NFSCTL_VERISSET(ctlbits, n))
|
|
|
6006dc |
- off += snprintf(ptr+off, sizeof(buf) - off, "+%d ", n);
|
|
|
6006dc |
- else
|
|
|
6006dc |
- off += snprintf(ptr+off, sizeof(buf) - off, "-%d ", n);
|
|
|
6006dc |
+ for (n = NFSD_MINVERS; n <= ((NFSD_MAXVERS < 3) ? NFSD_MAXVERS : 3); n++)
|
|
|
6006dc |
+ off += nfssvc_print_vers(&buf[off], sizeof(buf) - off,
|
|
|
6006dc |
+ n, 0, NFSCTL_VERISSET(ctlbits, n), 0);
|
|
|
6006dc |
+
|
|
|
6006dc |
+ for (n = 0; n <= NFS4_MAXMINOR; n++) {
|
|
|
6006dc |
+ if (!NFSCTL_MINORISSET(minorversset, n))
|
|
|
6006dc |
+ continue;
|
|
|
6006dc |
+ off += nfssvc_print_vers(&buf[off], sizeof(buf) - off,
|
|
|
6006dc |
+ 4, n, NFSCTL_MINORISSET(minorvers, n),
|
|
|
6006dc |
+ (n == 0) ? force4dot0 : 0);
|
|
|
6006dc |
}
|
|
|
6006dc |
+ if (!off--)
|
|
|
6006dc |
+ goto out;
|
|
|
6006dc |
+ buf[off] = '\0';
|
|
|
6006dc |
xlog(D_GENERAL, "Writing version string to kernel: %s", buf);
|
|
|
6006dc |
- snprintf(ptr+off, sizeof(buf) - off, "\n");
|
|
|
6006dc |
+ snprintf(&buf[off], sizeof(buf) - off, "\n");
|
|
|
6006dc |
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
|
|
|
6006dc |
xlog(L_ERROR, "Setting version failed: errno %d (%m)", errno);
|
|
|
6006dc |
-
|
|
|
6006dc |
+out:
|
|
|
6006dc |
close(fd);
|
|
|
6006dc |
|
|
|
6006dc |
return;
|
|
|
6006dc |
diff -up nfs-utils-1.3.0/utils/nfsd/nfssvc.h.orig nfs-utils-1.3.0/utils/nfsd/nfssvc.h
|
|
|
6006dc |
--- nfs-utils-1.3.0/utils/nfsd/nfssvc.h.orig 2018-08-20 14:18:13.934033391 -0400
|
|
|
6006dc |
+++ nfs-utils-1.3.0/utils/nfsd/nfssvc.h 2018-08-20 14:18:58.023793505 -0400
|
|
|
6006dc |
@@ -26,5 +26,7 @@ int nfssvc_set_sockets(const unsigned in
|
|
|
6006dc |
const char *host, const char *port);
|
|
|
6006dc |
void nfssvc_set_time(const char *type, const int seconds);
|
|
|
6006dc |
int nfssvc_set_rdmaport(const char *port);
|
|
|
6006dc |
-void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, unsigned int minorvers4set);
|
|
|
6006dc |
-int nfssvc_threads(unsigned short port, int nrservs);
|
|
|
6006dc |
+void nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4,
|
|
|
6006dc |
+ unsigned int minorvers4set, int force4dot0);
|
|
|
6006dc |
+int nfssvc_threads(unsigned short port, int nrservs);
|
|
|
6006dc |
+void nfssvc_get_minormask(unsigned int *mask);
|