]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/stropts.c
mount.nfs: Support "-t nfs,vers=4" mounts in the kernel
[nfs-utils.git] / utils / mount / stropts.c
index 9d82bb141d37fbea3052c5ee02b0c5eb9cc6d75f..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 {
@@ -420,11 +426,11 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options)
 {
        struct sockaddr_storage nfs_address;
        struct sockaddr *nfs_saddr = (struct sockaddr *)&nfs_address;
-       socklen_t nfs_salen;
+       socklen_t nfs_salen = sizeof(nfs_address);
        struct pmap nfs_pmap;
        struct sockaddr_storage mnt_address;
        struct sockaddr *mnt_saddr = (struct sockaddr *)&mnt_address;
-       socklen_t mnt_salen;
+       socklen_t mnt_salen = sizeof(mnt_address);
        struct pmap mnt_pmap;
        char *option;
 
@@ -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;
        }