summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-07-26 13:28:48 -0400
committerSteve Dickson <steved@redhat.com>2017-07-26 13:54:04 -0400
commitb5c2328971cdfd31340ff6190ea5b74b9010c160 (patch)
tree2d9a6042d76858cce9fa664143b76c371fe27968
parent8af595b79b0f9f1a11e15b3dd35082c377fe6ef4 (diff)
downloadnfs-utils-b5c2328971cdfd31340ff6190ea5b74b9010c160.tar.gz
mount: use version string that is supported by old kernels
All kernels which support NFSv4.2 understand "vers=4.2". Some kernels which support NFSv4.1 only understand "vers=4,minorversion=1". All later kernels also support this. Some kernels which support NFSv4.0 only understand "vers=4". All later kernels also support this. So use the string that is most appropriate for each version. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/mount/stropts.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index c2a739b..0a371bf 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -727,7 +727,7 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
{
struct mount_options *options = po_dup(mi->options);
int result = 0;
- char version_opt[16];
+ char version_opt[32];
char *extra_opts = NULL;
if (!options) {
@@ -749,8 +749,24 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
}
if (mi->version.v_mode != V_SPECIFIC) {
+ char *fmt;
+ switch (mi->version.minor) {
+ /* Old kernels don't support the new "vers=x.y"
+ * option, but do support old versions of NFS4.
+ * So use the format that is most widely understood.
+ */
+ case 0:
+ fmt = "vers=%lu";
+ break;
+ case 1:
+ fmt = "vers=%lu,minorversion=%lu";
+ break;
+ default:
+ fmt = "vers=%lu.%lu";
+ break;
+ }
snprintf(version_opt, sizeof(version_opt) - 1,
- "vers=%lu.%lu", mi->version.major,
+ fmt, mi->version.major,
mi->version.minor);
if (po_append(options, version_opt) == PO_FAILED) {