Skip to contentSkip to conversation

minorversion= is being ignored

PATCH In review Steve Dickson 1 participant 3 messages Feb 27, 2018 – Mar 1, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover minorversion= is being ignored

This patch ensure "mount -t" mounts that have the minorversion= flag set, the given minor version is used.

There has been some talk about deprecating the minorversion option which it appears to be fairly simple in the kernel, but I think would be pretty difficult in the userland, do to all the per-existing scripts that used the option.

To make the deprecation possible in the kernel, code was added to convert minorversion= into vers=4.x in the string that passed to the kernel when the kernel is later than v3.4

Steve Dickson (1):
mount.nfs: minorversion setting is being ignored with the -t flag

 utils/mount/network.c | 15 ++++++++++-----
 utils/mount/stropts.c | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/1 mount.nfs: minorversion setting is being ignored with the -t flag

mount -t nfs or mount -t nfs4 and setting minorversion should set the v4 minor version. This patch adds a few checks to make sure the minor version is set.

The patch also translate the minorversion= option to vers=4.x in the arguments passed to the kernel when the kernel is later then v3.4.

---
 utils/mount/network.c | 15 ++++++++++-----
 utils/mount/stropts.c | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

v1:
Added kernel version check

utils/mount/network.c +10 -5
index 8ab5be8..8d6e4c6 100644
@@ -1275,8 +1275,8 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 		}
 	}
 
-	if (!found && strcmp(type, "nfs4") == 0)
-		version_val = type + 3;
+	if (!found && strncmp(type, "nfs", 3) == 0)
+		version_val = "4";
 	else if (!found)
 		return 1;
 	else if (i <= 2 ) {
@@ -1308,9 +1308,14 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 		if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val)
 			goto ret_error;
 		version->v_mode = V_SPECIFIC;
-	} else if (version->major > 3 && *cptr == '\0')
-		version->v_mode = V_GENERAL;
-
+	} else if (version->major > 3 && *cptr == '\0') {
+		version_val = po_get(options, "minorversion");
+		if (version_val != NULL) {
+			version->minor = strtol(version_val, &cptr, 10);
+			version->v_mode = V_SPECIFIC;
+		} else 
+			version->v_mode = V_GENERAL;
+	}
 	if (*cptr != '\0')
 		goto ret_error;
 
utils/mount/stropts.c +15 -0
index 777de39..d1b0708 100644
@@ -767,6 +767,21 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
 			mi->version.minor);
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
 
+		if (po_append(options, version_opt) == PO_FAILED) {
+			errno = EINVAL;
+			goto out_fail;
+		}
+	} else if (po_get(options, "minorversion") &&
+		linux_version_code() > MAKE_VERSION(3, 4, 0)) {
+		/*
+	 	 * convert minorversion= into vers=4.x
+	 	 */
+		po_remove_all(options, "minorversion");
+
+		snprintf(version_opt, sizeof(version_opt) - 1,
+			"vers=%lu.%lu", mi->version.major,
+			mi->version.minor);
+
 		if (po_append(options, version_opt) == PO_FAILED) {
 			errno = EINVAL;
 			goto out_fail;
Signature · 1 line
2.14.3
#2 lore raw

Re: [PATCH 1/1 V2] mount.nfs: minorversion setting is being ignored with the -t flag

Quoted 9 lines · Steve Dickson

mount -t nfs or mount -t nfs4 and setting minorversion should set the v4 minor version. This patch adds a few checks to make sure the minor version is set.

The patch also translate the minorversion= option to vers=4.x in the arguments passed to the kernel when the kernel is later then v3.4.

Committed...

steved.

Quoted 68 lines
---
 utils/mount/network.c | 15 ++++++++++-----
 utils/mount/stropts.c | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

v1:
Added kernel version check

utils/mount/network.c +10 -5
index 8ab5be8..8d6e4c6 100644
@@ -1275,8 +1275,8 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 		}
 	}
 
-	if (!found && strcmp(type, "nfs4") == 0)
-		version_val = type + 3;
+	if (!found && strncmp(type, "nfs", 3) == 0)
+		version_val = "4";
 	else if (!found)
 		return 1;
 	else if (i <= 2 ) {
@@ -1308,9 +1308,14 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 		if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val)
 			goto ret_error;
 		version->v_mode = V_SPECIFIC;
-	} else if (version->major > 3 && *cptr == '\0')
-		version->v_mode = V_GENERAL;
-
+	} else if (version->major > 3 && *cptr == '\0') {
+		version_val = po_get(options, "minorversion");
+		if (version_val != NULL) {
+			version->minor = strtol(version_val, &cptr, 10);
+			version->v_mode = V_SPECIFIC;
+		} else 
+			version->v_mode = V_GENERAL;
+	}
 	if (*cptr != '\0')
 		goto ret_error;
 
utils/mount/stropts.c +15 -0
index 777de39..d1b0708 100644
@@ -767,6 +767,21 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
 			mi->version.minor);
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
 
+		if (po_append(options, version_opt) == PO_FAILED) {
+			errno = EINVAL;
+			goto out_fail;
+		}
+	} else if (po_get(options, "minorversion") &&
+		linux_version_code() > MAKE_VERSION(3, 4, 0)) {
+		/*
+	 	 * convert minorversion= into vers=4.x
+	 	 */
+		po_remove_all(options, "minorversion");
+
+		snprintf(version_opt, sizeof(version_opt) - 1,
+			"vers=%lu.%lu", mi->version.major,
+			mi->version.minor);
+
 		if (po_append(options, version_opt) == PO_FAILED) {
 			errno = EINVAL;
 			goto out_fail;