walters / rpms / nfs-utils

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