From: J. Bruce Fields Date: Thu, 4 Feb 2010 22:03:53 +0000 (-0500) Subject: nfsd: fix version-setting regression on old kernels X-Git-Tag: nfs-utils-1-2-2~16 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=f808c94e8abb104e5248ee92acf6aeaf2e06e76a;p=nfs-utils.git nfsd: fix version-setting regression on old kernels /proc/fs/nfsd/versions was extended to allow turning on/off minor versions by echoing "+4.1" or "-4.1" to /proc/fs/nsfd/versions. Unfortunately, pre-2.6.30 kernels just stop parsing at first non-digit, so "-4.1" is interpreted as "-4". If new nfs-utils (on old kernel) writes "+2", "+3", "+4", then "-4.1", result therefore is to turn off 4.1. Given that historical behavior, it may have been a mistake to extend the interface the way we did; but at this point we're probably stuck with it. So, just reverse the order we write versions in. Signed-off-by: J. Bruce Fields Signed-off-by: Steve Dickson --- diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c index b8028bb..60232b8 100644 --- a/utils/nfsd/nfssvc.c +++ b/utils/nfsd/nfssvc.c @@ -238,17 +238,17 @@ 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); for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) { if (NFSCTL_VERISSET(ctlbits, n)) off += snprintf(ptr+off, sizeof(buf) - off, "+%d ", n); else off += snprintf(ptr+off, sizeof(buf) - off, "-%d ", n); } - n = minorvers4 >= 0 ? minorvers4 : -minorvers4; - if (n >= NFSD_MINMINORVERS4 && n <= NFSD_MAXMINORVERS4) - off += snprintf(ptr+off, sizeof(buf) - off, "%c4.%d", - minorvers4 > 0 ? '+' : '-', - n); xlog(D_GENERAL, "Writing version string to kernel: %s", buf); snprintf(ptr+off, sizeof(buf) - off, "\n"); if (write(fd, buf, strlen(buf)) != strlen(buf))