Commit 0de1b7e8 authored by Mi Jinlong's avatar Mi Jinlong Committed by Trond Myklebust

nfs: kernel should return EPROTONOSUPPORT when not support NFSv4

  When nfs client(kernel) don't support NFSv4, maybe user build
  kernel without NFSv4, there is a problem.

  Using command "mount SERVER-IP:/nfsv3 /mnt/" to mount NFSv3
  filesystem, mount should should success, but fail and get error:

    "mount.nfs: an incorrect mount option was specified"

  System call mount "nfs"(not "nfs4") with "vers=4",
  if CONFIG_NFS_V4 is not defined, the "vers=4" will be parsed
  as invalid argument and kernel return EINVAL to nfs-utils.

  About that, we really want get EPROTONOSUPPORT rather than
  EINVAL. This path make sure kernel parses argument success,
  and return EPROTONOSUPPORT at nfs_validate_mount_data().
Signed-off-by: default avatarMi Jinlong <mijinlong@cn.fujitsu.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 21ac19d4
...@@ -1069,12 +1069,10 @@ static int nfs_parse_mount_options(char *raw, ...@@ -1069,12 +1069,10 @@ static int nfs_parse_mount_options(char *raw,
mnt->flags |= NFS_MOUNT_VER3; mnt->flags |= NFS_MOUNT_VER3;
mnt->version = 3; mnt->version = 3;
break; break;
#ifdef CONFIG_NFS_V4
case Opt_v4: case Opt_v4:
mnt->flags &= ~NFS_MOUNT_VER3; mnt->flags &= ~NFS_MOUNT_VER3;
mnt->version = 4; mnt->version = 4;
break; break;
#endif
case Opt_udp: case Opt_udp:
mnt->flags &= ~NFS_MOUNT_TCP; mnt->flags &= ~NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
...@@ -1286,12 +1284,10 @@ static int nfs_parse_mount_options(char *raw, ...@@ -1286,12 +1284,10 @@ static int nfs_parse_mount_options(char *raw,
mnt->flags |= NFS_MOUNT_VER3; mnt->flags |= NFS_MOUNT_VER3;
mnt->version = 3; mnt->version = 3;
break; break;
#ifdef CONFIG_NFS_V4
case NFS4_VERSION: case NFS4_VERSION:
mnt->flags &= ~NFS_MOUNT_VER3; mnt->flags &= ~NFS_MOUNT_VER3;
mnt->version = 4; mnt->version = 4;
break; break;
#endif
default: default:
goto out_invalid_value; goto out_invalid_value;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment