diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2017-02-22 18:35:33 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2017-02-27 18:04:17 -0500 |
commit | ff7d11797e728efbd1da8cfaa6f7c37585784ca5 (patch) | |
tree | 7ba761667ee270062c72519b07bb7b75c6a67e1e | |
parent | d3635ff07e8ca598d44f72bbf5d6c65b8ebeeb46 (diff) |
nfsd: Fix display of the version string
The current display code assumes that v4 minor version 0 is tracked by
the call to nfsd_vers(). Now it is tracked by nfsd_minorversion(), and
so we need to adjust the display code.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/nfsd/nfsctl.c | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 4bbba88416dc..73e75ac90525 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -536,6 +536,19 @@ out_free: | |||
536 | return rv; | 536 | return rv; |
537 | } | 537 | } |
538 | 538 | ||
539 | static ssize_t | ||
540 | nfsd_print_version_support(char *buf, int remaining, const char *sep, | ||
541 | unsigned vers, unsigned minor) | ||
542 | { | ||
543 | const char *format = (minor == 0) ? "%s%c%u" : "%s%c%u.%u"; | ||
544 | bool supported = !!nfsd_vers(vers, NFSD_TEST); | ||
545 | |||
546 | if (vers == 4 && !nfsd_minorversion(minor, NFSD_TEST)) | ||
547 | supported = false; | ||
548 | return snprintf(buf, remaining, format, sep, | ||
549 | supported ? '+' : '-', vers, minor); | ||
550 | } | ||
551 | |||
539 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) | 552 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) |
540 | { | 553 | { |
541 | char *mesg = buf; | 554 | char *mesg = buf; |
@@ -598,40 +611,23 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
598 | len = 0; | 611 | len = 0; |
599 | sep = ""; | 612 | sep = ""; |
600 | remaining = SIMPLE_TRANSACTION_LIMIT; | 613 | remaining = SIMPLE_TRANSACTION_LIMIT; |
601 | for (num=2 ; num <= 4 ; num++) | 614 | for (num=2 ; num <= 4 ; num++) { |
602 | if (nfsd_vers(num, NFSD_AVAIL)) { | 615 | if (!nfsd_vers(num, NFSD_AVAIL)) |
603 | len = snprintf(buf, remaining, "%s%c%d", sep, | 616 | continue; |
604 | nfsd_vers(num, NFSD_TEST)?'+':'-', | 617 | minor = 0; |
605 | num); | 618 | do { |
606 | sep = " "; | 619 | len = nfsd_print_version_support(buf, remaining, |
607 | 620 | sep, num, minor); | |
608 | if (len >= remaining) | ||
609 | break; | ||
610 | remaining -= len; | ||
611 | buf += len; | ||
612 | tlen += len; | ||
613 | } | ||
614 | if (nfsd_vers(4, NFSD_AVAIL)) | ||
615 | for (minor = 0; minor <= NFSD_SUPPORTED_MINOR_VERSION; | ||
616 | minor++) { | ||
617 | if (minor == 0 && nfsd_minorversion(minor, NFSD_TEST)) | ||
618 | /* for backward compatibility, don't report | ||
619 | * +4.0 | ||
620 | */ | ||
621 | continue; | ||
622 | len = snprintf(buf, remaining, " %c4.%u", | ||
623 | (nfsd_vers(4, NFSD_TEST) && | ||
624 | nfsd_minorversion(minor, NFSD_TEST)) ? | ||
625 | '+' : '-', | ||
626 | minor); | ||
627 | |||
628 | if (len >= remaining) | 621 | if (len >= remaining) |
629 | break; | 622 | goto out; |
630 | remaining -= len; | 623 | remaining -= len; |
631 | buf += len; | 624 | buf += len; |
632 | tlen += len; | 625 | tlen += len; |
633 | } | 626 | minor++; |
634 | 627 | sep = " "; | |
628 | } while (num == 4 && minor <= NFSD_SUPPORTED_MINOR_VERSION); | ||
629 | } | ||
630 | out: | ||
635 | len = snprintf(buf, remaining, "\n"); | 631 | len = snprintf(buf, remaining, "\n"); |
636 | if (len >= remaining) | 632 | if (len >= remaining) |
637 | return -EINVAL; | 633 | return -EINVAL; |