[PATCH 4/4] mount: Fix problems with parsing minorversion=

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1/ minorversion=0 is not recognized, as errors from
   strtol() are not correctly detected.
2/ when there is an error in the minorversion= value,
   no message is presented.
3/ Current code recognizes "minorversion" and sets V_SPECIFIC,
   but then because *cptr == '\0', the v_mode is reset to V_GENERAL.
   This results in minorversion negotiation, which is not wanted.

This patch addresses all of these.

Signed-off-by: NeilBrown <neilb@xxxxxxxx>
---
 utils/mount/network.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/utils/mount/network.c b/utils/mount/network.c
index d673391b5fff..11ee818f9705 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -100,7 +100,6 @@ static const char *nfs_version_opttbl[] = {
 	"v4",
 	"vers",
 	"nfsvers",
-	"minorversion",
 	NULL,
 };
 
@@ -1291,17 +1290,19 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 	if (!version_val)
 		goto ret_error;
 
-	if (!(version->major = strtol(version_val, &cptr, 10)))
+	version->major = strtol(version_val, &cptr, 10);
+	if (cptr == version_val || (*cptr && *cptr != '.'))
 		goto ret_error;
-
-	if (strcmp(nfs_version_opttbl[i], "minorversion") == 0) {
+	if (version->major == 4 && *cptr != '.' &&
+	    (version_val = po_get(options, "minorversion")) != NULL) {
+		version->minor = strtol(version_val, &cptr, 10);
+		i = -1;
+		if (*cptr)
+			goto ret_error;
 		version->v_mode = V_SPECIFIC;
-		version->minor = version->major;
-		version->major = 4;
 	} else if (version->major < 4)
 		version->v_mode = V_SPECIFIC;
-
-	if (*cptr == '.') {
+	else if (*cptr == '.') {
 		version_val = ++cptr;
 		if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val)
 			goto ret_error;
@@ -1315,7 +1316,10 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 	return 1;
 
 ret_error:
-	if (i <= 2 ) {
+	if (i < 0) {
+		nfs_error(_("%s: parsing error on 'minorversion=' option"),
+			progname);
+	} else if (i <= 2 ) {
 		nfs_error(_("%s: parsing error on 'v' option"),
 			progname);
 	} else if (i == 3 ) {


--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux