Skip to contentSkip to conversation

mount.nfs: Implement falling back to NFSv2 and UDP

PATCH New Chuck Lever 1 participant 1 message Sep 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 13/19 mount.nfs: Implement falling back to NFSv2 and UDP

If the initial user-specified options fail (with EOPNOTSUPP) then the server has rejected the requested NFS version or transport protocol.

In that case, probe the server, and construct a fresh set of mount options that ask for the specific mountd and NFS version and transport protocol that the server supports. Rewrite the mount options based on the results of the probe, then try the request again.

---

 utils/mount/stropts.c |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)
utils/mount/stropts.c +25 -7
index deaf9e1..99d48cf 100644
@@ -353,16 +353,15 @@ static int rewrite_mount_opts(struct mount_options *options)
  * Attempt an NFS mount via a mount(2) system call.
  *
  * Returns 1 if successful.  Otherwise, returns zero.
+ * "errno" is set to reflect the individual error.
  */
 static int try_nfsmount(const char *spec, const char *node,
 			int flags, struct mount_options *options,
 			int fake, char **extra_opts)
 {
 	*extra_opts = po_join(options);
-	if (!*extra_opts) {
-		nfs_error(_("%s: internal option parsing error"), progname);
-		return 0;
-	}
+	if (!*extra_opts)
+		goto parse_err;
 
 	if (verbose)
 		printf(_("%s: text-based options: '%s'\n"),
@@ -371,13 +370,32 @@ static int try_nfsmount(const char *spec, const char *node,
 	if (fake)
 		return 1;
 
-	if (mount(spec, node, "nfs",
-				flags & ~(MS_USER|MS_USERS), *extra_opts)) {
+	if (!mount(spec, node, "nfs",
+				flags & ~(MS_USER|MS_USERS), *extra_opts))
+		return 1;
+
+	if (errno != EOPNOTSUPP) {
 		mount_error(spec, node, errno);
 		return 0;
 	}
 
-	return 1;
+	if (!rewrite_mount_opts(options))
+		goto parse_err;
+	*extra_opts = po_join(options);
+	if (!*extra_opts)
+		goto parse_err;
+
+	if (!mount(spec, node, "nfs",
+				flags & ~(MS_USER|MS_USERS), *extra_opts))
+		return 1;
+
+	mount_error(spec, node, errno);
+	return 0;
+
+parse_err:
+	nfs_error(_("%s: internal option parsing error"), progname);
+	errno = EINVAL;
+	return 0;
 }
 
 /*

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs