]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfsumount.c
NFS man page: update nfs(5) with details about IPv6 support
[nfs-utils.git] / utils / mount / nfsumount.c
index 9b48cc9a63239d9c92eb89edf31cdfd56476ae72..9d798a2ff347513779b646b88692ae873844b158 100644 (file)
@@ -169,12 +169,24 @@ out:
 static int nfs_umount_do_umnt(struct mount_options *options,
                              char **hostname, char **dirname)
 {
-       struct sockaddr_storage address;
-       struct sockaddr *sap = (struct sockaddr *)&address;
+       union {
+               struct sockaddr         sa;
+               struct sockaddr_in      s4;
+               struct sockaddr_in6     s6;
+       } address;
+       struct sockaddr *sap = &address.sa;
        socklen_t salen = sizeof(address);
        struct pmap nfs_pmap, mnt_pmap;
+       sa_family_t family;
 
-       nfs_options2pmap(options, &nfs_pmap, &mnt_pmap);
+       if (!nfs_options2pmap(options, &nfs_pmap, &mnt_pmap)) {
+               nfs_error(_("%s: bad mount options"), progname);
+               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) {
@@ -182,8 +194,10 @@ static int nfs_umount_do_umnt(struct mount_options *options,
                return EX_FAIL;
        }
 
-       if (nfs_name_to_address(*hostname, sap, &salen) == 0)
-               /* nfs_name_to_address reports any errors */
+       if (!nfs_mount_proto_family(options, &family))
+               return 0;
+       if (!nfs_lookup(*hostname, family, sap, &salen))
+               /* nfs_lookup reports any errors */
                return EX_FAIL;
 
        if (nfs_advise_umount(sap, salen, &mnt_pmap, dirname) == 0)
@@ -333,7 +347,7 @@ int nfsumount(int argc, char *argv[])
                        char *opt = hasmntopt(&mc->m, "user");
                        struct passwd *pw;
                        char *comma;
-                       int len;
+                       size_t len;
                        if (!opt)
                                goto only_root;
                        if (opt[4] != '=')