2f9cba1
commit a709f25c1da4a2fb44a1f3fd060298fbbd88aa3c
2f9cba1
Author: Steve Dickson <steved@redhat.com>
2f9cba1
Date:   Tue May 14 15:52:50 2019 -0400
2f9cba1
2f9cba1
    mount: Report correct error in the fall_back cases.
2f9cba1
    
2f9cba1
    In mount auto negotiation, a v3 mount is tried
2f9cba1
    when the v4 fails with error that could mean
2f9cba1
    v4 is not supported.
2f9cba1
    
2f9cba1
    When the v3 mount fails, the original v4 failure
2f9cba1
    should be used to set the errno, not the v3 failure.
2f9cba1
    
2f9cba1
    Fixes:https://bugzilla.redhat.com/show_bug.cgi?id=1709961
2f9cba1
    Signed-off-by: Steve Dickson <steved@redhat.com>
2f9cba1
2f9cba1
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
2f9cba1
index 1bb7a73..901f995 100644
2f9cba1
--- a/utils/mount/stropts.c
2f9cba1
+++ b/utils/mount/stropts.c
2f9cba1
@@ -889,7 +889,7 @@ out:
2f9cba1
  */
2f9cba1
 static int nfs_autonegotiate(struct nfsmount_info *mi)
2f9cba1
 {
2f9cba1
-	int result;
2f9cba1
+	int result, olderrno;
2f9cba1
 
2f9cba1
 	result = nfs_try_mount_v4(mi);
2f9cba1
 check_result:
2f9cba1
@@ -949,7 +949,18 @@ fall_back:
2f9cba1
 	if (mi->version.v_mode == V_GENERAL)
2f9cba1
 		/* v2,3 fallback not allowed */
2f9cba1
 		return result;
2f9cba1
-	return nfs_try_mount_v3v2(mi, FALSE);
2f9cba1
+
2f9cba1
+	/*
2f9cba1
+	 * Save the original errno in case the v3 
2f9cba1
+	 * mount fails from one of the fall_back cases. 
2f9cba1
+	 * Report the first failure not the v3 mount failure
2f9cba1
+	 */
2f9cba1
+	olderrno = errno;
2f9cba1
+	if ((result = nfs_try_mount_v3v2(mi, FALSE)))
2f9cba1
+		return result;
2f9cba1
+
2f9cba1
+	errno = olderrno;
2f9cba1
+	return result;
2f9cba1
 }
2f9cba1
 
2f9cba1
 /*