]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/stropts.c
mount.nfs: Retry v4 mounts with v3 on ENOENT errors
[nfs-utils.git] / utils / mount / stropts.c
index 4c9ee17b95ba9554f00dfb77966bb34255bdd111..4007150103867590bee8c858b549d8a4a20ebd29 100644 (file)
@@ -611,6 +611,18 @@ static int nfs_try_mount_v4(struct nfsmount_info *mi)
        }
 
        if (mi->version == 0) {
+               if (po_contains(options, "mounthost") ||
+                       po_contains(options, "mountaddr") ||
+                       po_contains(options, "mountvers") ||
+                       po_contains(options, "mountproto")) {
+               /*
+                * Since these mountd options are set assume version 3
+                * is wanted so error out with EPROTONOSUPPORT so the
+                * protocol negation starts with v3.
+                */
+                       errno = EPROTONOSUPPORT;
+                       goto out_fail;
+               }
                if (po_append(options, "vers=4") == PO_FAILED) {
                        errno = EINVAL;
                        goto out_fail;
@@ -621,12 +633,13 @@ static int nfs_try_mount_v4(struct nfsmount_info *mi)
                errno = EINVAL;
                goto out_fail;
        }
+
        /*
         * Update option string to be recorded in /etc/mtab.
         */
        if (po_join(options, mi->extra_opts) == PO_FAILED) {
                errno = ENOMEM;
-               return 0;
+               goto out_fail;
        }
 
        result = nfs_sys_mount(mi, options);
@@ -655,9 +668,10 @@ static int nfs_try_mount(struct nfsmount_info *mi)
                                /* 
                                 * To deal with legacy Linux servers that don't
                                 * automatically export a pseudo root, retry
-                                * ENOENT errors using version 3
+                                * ENOENT errors using version 3. And for
+                                * Linux servers prior to 2.6.25, retry EPERM
                                 */
-                               if (errno != ENOENT)
+                               if (errno != ENOENT && errno != EPERM)
                                        break;
                        }
                }