linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: fanchaoting <fanchaoting@cn.fujitsu.com>
To: "bfields@fieldses.org" <bfields@fieldses.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: [PATCH] nfsd: Check the nfsd support version when enable or disable the minorversion
Date: Wed, 23 Jan 2013 17:58:18 +0800	[thread overview]
Message-ID: <50FFB43A.8030105@cn.fujitsu.com> (raw)

when enable or disable the minorversion throw /proc/fs/nfsd/versions,it
should check the support version.

for example
if we do like following:

echo "+2 +3 +4 +7.1">/proc/fs/nfsd/versions
echo "+2 +3 +4 -7.1">/proc/fs/nfsd/versions
it will enable or disable nfs4.1, but now the number nfs7 didn't support.

Signed-off-by: Fan Chaoting <fanchaoting@cn.fujitsu.com>

---
 fs/nfsd/nfsctl.c |    2 +-
 fs/nfsd/nfsd.h   |    1 +
 fs/nfsd/nfssvc.c |    4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index dab350d..1a6e89c 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -532,7 +532,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
 			else
 				num = simple_strtol(vers, &minorp, 0);
 			if (*minorp == '.') {
-				if (num < 4)
+				if (num < 4 || num >= nfsd_number_vers())
 					return -EINVAL;
 				minor = simple_strtoul(minorp+1, NULL, 0);
 				if (minor == 0)
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 80d5ce4..c9d7203 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -104,6 +104,7 @@ int nfsd_vers(int vers, enum vers_op change);
 int nfsd_minorversion(u32 minorversion, enum vers_op change);
 void nfsd_reset_versions(void);
 int nfsd_create_serv(void);
+int nfsd_number_vers(void);
 
 extern int nfsd_max_blksize;
 
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 2013aa00..072cdb9 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -670,3 +670,7 @@ int nfsd_pool_stats_release(struct inode *inode, struct file *file)
 	mutex_unlock(&nfsd_mutex);
 	return ret;
 }
+
+int nfsd_number_vers(void) {
+	return NFSD_NRVERS;
+}
-- 
1.7.10.1


             reply	other threads:[~2013-01-23  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  9:58 fanchaoting [this message]
2013-01-23 23:24 ` [PATCH] nfsd: Check the nfsd support version when enable or disable the minorversion bfields
2013-01-24  1:22   ` fanchaoting
2013-01-25  8:52   ` fanchaoting
2013-01-29 18:13     ` bfields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50FFB43A.8030105@cn.fujitsu.com \
    --to=fanchaoting@cn.fujitsu.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).