Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 169

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

diff --git a/CHANGELOG b/CHANGELOG
index c8724f0..8e46930 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
 - add additional check to prevent running of cancelled tasks.
 - fix potential file handle leakage in rpc_subs.c for some failure cases.
 - fix file handle leak in included map lookup.
+- fix "-fstype=nfs4" server probing.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/include/replicated.h b/include/replicated.h
index cc34755..00cf641 100644
--- a/include/replicated.h
+++ b/include/replicated.h
@@ -25,7 +25,8 @@ #define PROXIMITY_OTHER         0x0008
 #define NFS2_SUPPORTED		0x0010
 #define NFS3_SUPPORTED		0x0020
 #define NFS4_SUPPORTED		0x0040
-#define NFS_VERS_MASK		(NFS2_SUPPORTED|NFS3_SUPPORTED|NFS4_SUPPORTED)
+#define NFS_VERS_MASK		(NFS2_SUPPORTED|NFS3_SUPPORTED)
+#define NFS4_VERS_MASK		(NFS4_SUPPORTED)
 
 #define NFS2_REQUESTED		NFS2_SUPPORTED
 #define NFS3_REQUESTED		NFS3_SUPPORTED
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index ae6abb1..94c8e8b 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -125,7 +125,11 @@ int mount_mount(struct autofs_point *ap,
 		      nfsoptions, nosymlink, ro);
 	}
 
-	vers = NFS_VERS_MASK | NFS_PROTO_MASK;
+	if (strcmp(fstype, "nfs4") == 0)
+		vers = NFS4_VERS_MASK | NFS_PROTO_MASK;
+	else
+		vers = NFS_VERS_MASK | NFS_PROTO_MASK;
+
 	if (!parse_location(&hosts, what)) {
 		warn(ap->logopt, MODPREFIX "no hosts available");
 		return 1;
diff --git a/modules/replicated.c b/modules/replicated.c
index 27d3565..9b9a44b 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -355,44 +355,51 @@ static unsigned int get_nfs_info(struct 
 		return 0;
 
 	parms.pm_prot = rpc_info->proto->p_proto;
-#if 0
+
 	if (!(version & NFS4_REQUESTED))
 		goto v3_ver;
 
 	parms.pm_vers = NFS4_VERSION;
 	rpc_info->port = rpc_portmap_getport(pm_info, &parms);
-	if (rpc_info->port) {
+	if (!rpc_info->port)
+		goto v3_ver;
+
+	if (rpc_info->proto->p_proto == IPPROTO_UDP)
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
+	else
+		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
+	if (status) {
+		gettimeofday(&start, &tz);
+		status = rpc_ping_proto(rpc_info);
+		gettimeofday(&end, &tz);
 		if (status) {
-			gettimeofday(&start, &tz);
-			status = rpc_ping_proto(rpc_info);
-			gettimeofday(&end, &tz);
-			if (status) {
-				taken += elapsed(start, end);
-				count++;
-				supported = NFS4_SUPPORTED;
-			}
+			taken += elapsed(start, end);
+			count++;
+			supported = NFS4_SUPPORTED;
 		}
 	}
 
 v3_ver:
-#endif
 	if (!(version & NFS3_REQUESTED))
 		goto v2_ver;
 
 	parms.pm_vers = NFS3_VERSION;
 	rpc_info->port = rpc_portmap_getport(pm_info, &parms);
-	if (rpc_info->port) {
+	if (!rpc_info->port)
+		goto v2_ver;
+
+	if (rpc_info->proto->p_proto == IPPROTO_UDP)
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
+	else
+		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
+	if (status) {
+		gettimeofday(&start, &tz);
+		status = rpc_ping_proto(rpc_info);
+		gettimeofday(&end, &tz);
 		if (status) {
-			gettimeofday(&start, &tz);
-			status = rpc_ping_proto(rpc_info);
-			gettimeofday(&end, &tz);
-			if (status) {
-				taken += elapsed(start, end);
-				count++;
-				supported |= NFS3_SUPPORTED;
-			}
+			taken += elapsed(start, end);
+			count++;
+			supported |= NFS3_SUPPORTED;
 		}
 	}
 
@@ -402,17 +409,21 @@ v2_ver:
 
 	parms.pm_vers = NFS2_VERSION;
 	rpc_info->port = rpc_portmap_getport(pm_info, &parms);
-	if (rpc_info->port) {
+	if (!rpc_info->port)
+		goto done_ver;
+
+	if (rpc_info->proto->p_proto == IPPROTO_UDP)
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
+	else
+		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
+	if (status) {
+		gettimeofday(&start, &tz);
+		status = rpc_ping_proto(rpc_info);
+		gettimeofday(&end, &tz);
 		if (status) {
-			gettimeofday(&start, &tz);
-			status = rpc_ping_proto(rpc_info);
-			gettimeofday(&end, &tz);
-			if (status) {
-				taken += elapsed(start, end);
-				count++;
-				supported |= NFS2_SUPPORTED;
-			}
+			taken += elapsed(start, end);
+			count++;
+			supported |= NFS2_SUPPORTED;
 		}
 	}
 
@@ -444,7 +455,7 @@ static int get_vers_and_cost(struct host
 {
 	struct conn_info pm_info, rpc_info;
 	time_t timeout = RPC_TIMEOUT;
-	unsigned int supported, vers = NFS_VERS_MASK;
+	unsigned int supported, vers = (NFS_VERS_MASK | NFS4_VERS_MASK);
 	int ret = 0;
 
 	memset(&pm_info, 0, sizeof(struct conn_info));
@@ -533,17 +544,21 @@ static int get_supported_ver_and_cost(st
 	status = 0;
 	parms.pm_vers = vers;
 	rpc_info.port = rpc_portmap_getport(&pm_info, &parms);
-	if (rpc_info.port) {
+	if (!rpc_info.port)
+		goto done;
+
+	if (rpc_info.proto->p_proto == IPPROTO_UDP)
 		status = rpc_udp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers);
-		if (status) {
-			gettimeofday(&start, &tz);
-			status = rpc_ping_proto(&rpc_info);
-			gettimeofday(&end, &tz);
-			if (status)
-				taken = elapsed(start, end);
-		}
+	else
+		status = rpc_tcp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers);
+	if (status) {
+		gettimeofday(&start, &tz);
+		status = rpc_ping_proto(&rpc_info);
+		gettimeofday(&end, &tz);
+		if (status)
+			taken = elapsed(start, end);
 	}
-
+done:
 	if (rpc_info.proto->p_proto == IPPROTO_UDP) {
 		rpc_destroy_udp_client(&rpc_info);
 		rpc_destroy_udp_client(&pm_info);