diff -up nfs-utils-1.2.0/utils/mount/configfile.c.orig nfs-utils-1.2.0/utils/mount/configfile.c --- nfs-utils-1.2.0/utils/mount/configfile.c.orig 2009-09-30 13:57:48.647286000 -0400 +++ nfs-utils-1.2.0/utils/mount/configfile.c 2009-09-30 14:50:05.365468000 -0400 @@ -198,6 +198,15 @@ int inline check_vers(char *mopt, char * } return 0; } +int inline vers_is_set(char *mopt) +{ + int i; + + for (i=0; versions[i]; i++) + if (strncasecmp(mopt, versions[i], strlen(versions[i])) == 0) + return 1; + return 0; +} /* * Parse the given section of the configuration * file to if there are any mount options set. @@ -256,6 +265,8 @@ conf_parse_mntopts(char *section, char * conf_free_list(list); } +int do_version_negation; + /* * Concatenate options from the configuration file with the * given options by building a link list of options from the @@ -326,6 +337,8 @@ char *conf_get_mntopts(char *spec, char strcat(config_opts, ","); } SLIST_FOREACH(entry, &head, entries) { + if (vers_is_set(entry->opt)) + do_version_negation = 1; strcat(config_opts, entry->opt); strcat(config_opts, ","); } diff -up nfs-utils-1.2.0/utils/mount/stropts.c.orig nfs-utils-1.2.0/utils/mount/stropts.c --- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-30 13:57:48.613288000 -0400 +++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-30 14:59:56.716461000 -0400 @@ -588,6 +588,7 @@ out_fail: po_destroy(options); return result; } +extern int do_version_negation; /* * This is a single pass through the fg/bg loop. @@ -607,12 +608,20 @@ static int nfs_try_mount(struct nfsmount if (errno != EPROTONOSUPPORT) break; } - case 2: case 3: + if (do_version_negation) + po_remove_all(mi->options, "nfsvers"); + case 2: result = nfs_try_mount_v3v2(mi); break; case 4: result = nfs_try_mount_v4(mi); + if (do_version_negation && !result) { + if (errno == EPROTONOSUPPORT) { + po_remove_all(mi->options, "nfsvers"); + result = nfs_try_mount_v3v2(mi); + } + } break; default: errno = EIO;