aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfsctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfsctl.c')
-rw-r--r--fs/nfsd/nfsctl.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index c4843467cfd4..a152694e016e 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -793,7 +793,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
793{ 793{
794 char *mesg = buf; 794 char *mesg = buf;
795 char *vers, *minorp, sign; 795 char *vers, *minorp, sign;
796 int len, num; 796 int len, num, remaining;
797 unsigned minor; 797 unsigned minor;
798 ssize_t tlen = 0; 798 ssize_t tlen = 0;
799 char *sep; 799 char *sep;
@@ -840,32 +840,50 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
840 } 840 }
841 next: 841 next:
842 vers += len + 1; 842 vers += len + 1;
843 tlen += len;
844 } while ((len = qword_get(&mesg, vers, size)) > 0); 843 } while ((len = qword_get(&mesg, vers, size)) > 0);
845 /* If all get turned off, turn them back on, as 844 /* If all get turned off, turn them back on, as
846 * having no versions is BAD 845 * having no versions is BAD
847 */ 846 */
848 nfsd_reset_versions(); 847 nfsd_reset_versions();
849 } 848 }
849
850 /* Now write current state into reply buffer */ 850 /* Now write current state into reply buffer */
851 len = 0; 851 len = 0;
852 sep = ""; 852 sep = "";
853 remaining = SIMPLE_TRANSACTION_LIMIT;
853 for (num=2 ; num <= 4 ; num++) 854 for (num=2 ; num <= 4 ; num++)
854 if (nfsd_vers(num, NFSD_AVAIL)) { 855 if (nfsd_vers(num, NFSD_AVAIL)) {
855 len += sprintf(buf+len, "%s%c%d", sep, 856 len = snprintf(buf, remaining, "%s%c%d", sep,
856 nfsd_vers(num, NFSD_TEST)?'+':'-', 857 nfsd_vers(num, NFSD_TEST)?'+':'-',
857 num); 858 num);
858 sep = " "; 859 sep = " ";
860
861 if (len > remaining)
862 break;
863 remaining -= len;
864 buf += len;
865 tlen += len;
859 } 866 }
860 if (nfsd_vers(4, NFSD_AVAIL)) 867 if (nfsd_vers(4, NFSD_AVAIL))
861 for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION; minor++) 868 for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION;
862 len += sprintf(buf+len, " %c4.%u", 869 minor++) {
870 len = snprintf(buf, remaining, " %c4.%u",
863 (nfsd_vers(4, NFSD_TEST) && 871 (nfsd_vers(4, NFSD_TEST) &&
864 nfsd_minorversion(minor, NFSD_TEST)) ? 872 nfsd_minorversion(minor, NFSD_TEST)) ?
865 '+' : '-', 873 '+' : '-',
866 minor); 874 minor);
867 len += sprintf(buf+len, "\n"); 875
868 return len; 876 if (len > remaining)
877 break;
878 remaining -= len;
879 buf += len;
880 tlen += len;
881 }
882
883 len = snprintf(buf, remaining, "\n");
884 if (len > remaining)
885 return -EINVAL;
886 return tlen + len;
869} 887}
870 888
871/** 889/**