]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mount.nfs: Support "-t nfs,vers=4" mounts in the kernel
authorChuck Lever <chuck.lever@oracle.com>
Mon, 14 Sep 2009 17:55:36 +0000 (13:55 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 14 Sep 2009 17:55:36 +0000 (13:55 -0400)
    Support "vers=4" in nfs_nfs_version()

    Skip UMNT call for "-t nfs -o vers=4" mounts

For "-t nfs -o vers=4" mounts, we want to skip v2/v3
version/transport negotiation, but be sure to append
the "clientaddr" option.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Tested-by: Steve Dickson <steved@redhat.com>
utils/mount/network.c
utils/mount/network.h
utils/mount/nfsumount.c
utils/mount/stropts.c

index f6fa5fd340ec353d4e9cc8155569babdaeef8806..bd621befb7e00f1c0a8603657290e132aef9a2b3 100644 (file)
@@ -90,6 +90,7 @@ static const char *nfs_transport_opttbl[] = {
 static const char *nfs_version_opttbl[] = {
        "v2",
        "v3",
+       "v4",
        "vers",
        "nfsvers",
        NULL,
@@ -1203,7 +1204,7 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)
  * Returns TRUE if @version contains a valid value for this option,
  * or FALSE if the option was specified with an invalid value.
  */
-static int
+int
 nfs_nfs_version(struct mount_options *options, unsigned long *version)
 {
        long tmp;
@@ -1215,10 +1216,13 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version)
        case 1: /* v3 */
                *version = 3;
                return 1;
-       case 2: /* vers */
+       case 2: /* v4 */
+               *version = 4;
+               return 1;
+       case 3: /* vers */
                switch (po_get_numeric(options, "vers", &tmp)) {
                case PO_FOUND:
-                       if (tmp >= 2 && tmp <= 3) {
+                       if (tmp >= 2 && tmp <= 4) {
                                *version = tmp;
                                return 1;
                        }
@@ -1229,10 +1233,10 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version)
                case PO_BAD_VALUE:
                        return 0;
                }
-       case 3: /* nfsvers */
+       case 4: /* nfsvers */
                switch (po_get_numeric(options, "nfsvers", &tmp)) {
                case PO_FOUND:
-                       if (tmp >= 2 && tmp <= 3) {
+                       if (tmp >= 2 && tmp <= 4) {
                                *version = tmp;
                                return 1;
                        }
index db5134c2fcc8edb1e5bde5f7226766df353b1082..402e0a50c9977cde5e7b4b7e28296b1451645875 100644 (file)
@@ -56,6 +56,7 @@ int clnt_ping(struct sockaddr_in *, const unsigned long,
 
 struct mount_options;
 
+int nfs_nfs_version(struct mount_options *options, unsigned long *version);
 int nfs_options2pmap(struct mount_options *,
                      struct pmap *, struct pmap *);
 
index f81db14e4d43e53ddebb7af98d73be4048ac7956..c5505b1edf6d436532f93310f0d2a433e70c19a2 100644 (file)
@@ -179,6 +179,10 @@ static int nfs_umount_do_umnt(struct mount_options *options,
                return EX_FAIL;
        }
 
+       /* Skip UMNT call for vers=4 mounts */
+       if (nfs_pmap.pm_vers == 4)
+               return EX_SUCCESS;
+
        *hostname = nfs_umount_hostname(options, *hostname);
        if (!*hostname) {
                nfs_error(_("%s: out of memory"), progname);
index a12ace7f9f480cd42863843bb32c51f8aaaa4b20..3eb661e2e6ccc6b6e4a012a95ff097aa8cdfaf81 100644 (file)
@@ -84,6 +84,7 @@ struct nfsmount_info {
        struct mount_options    *options;       /* parsed mount options */
        char                    **extra_opts;   /* string for /etc/mtab */
 
+       unsigned long           version;        /* NFS version */
        int                     flags,          /* MS_ flags */
                                fake,           /* actually do the mount? */
                                child;          /* forked bg child? */
@@ -272,7 +273,12 @@ static int nfs_validate_options(struct nfsmount_info *mi)
        if (!nfs_name_to_address(mi->hostname, sap, &salen))
                return 0;
 
-       if (strncmp(mi->type, "nfs4", 4) == 0) {
+       if (!nfs_nfs_version(mi->options, &mi->version))
+               return 0;
+       if (strncmp(mi->type, "nfs4", 4) == 0)
+               mi->version = 4;
+
+       if (mi->version == 4) {
                if (!nfs_append_clientaddr_option(sap, salen, mi->options))
                        return 0;
        } else {
@@ -488,7 +494,7 @@ static int nfs_try_mount(struct nfsmount_info *mi)
        char *options = NULL;
        int result;
 
-       if (strncmp(mi->type, "nfs4", 4) != 0) {
+       if (mi->version != 4) {
                if (!nfs_rewrite_pmap_mount_options(mi->options))
                        return 0;
        }