3
0
forked from pool/util-linux
util-linux/util-linux-2.12-mount_nfs_tcp.patch

66 lines
2.1 KiB
Diff

Index: util-linux-ng-2.12r+2.13pre7/mount/nfs.5
===================================================================
--- util-linux-ng-2.12r+2.13pre7.orig/mount/nfs.5
+++ util-linux-ng-2.12r+2.13pre7/mount/nfs.5
@@ -199,11 +199,11 @@ writing to common filesystem on the serv
.TP 1.5i
.I tcp
Mount the NFS filesystem using the TCP protocol instead of the
-default UDP protocol. Many NFS servers only support UDP.
+UDP protocol. This is the default, but in case it fails (many NFS servers only
+support UDP) it will fallback and try UDP.
.TP 1.5i
.I udp
-Mount the NFS filesystem using the UDP protocol. This
-is the default.
+Mount the NFS filesystem using the UDP protocol.
.TP 1.5i
.I noacl
Assume no extended access control mechanisms like POSIX ACLs are used
@@ -227,8 +227,5 @@ interrupted.
The posix, and nocto options are parsed by mount
but currently are silently ignored.
.P
-The tcp and namlen options are implemented but are not currently
-supported by the Linux kernel.
-.P
The umount command should notify the server
when an NFS filesystem is unmounted.
Index: util-linux-ng-2.12r+2.13pre7/mount/nfsmount.c
===================================================================
--- util-linux-ng-2.12r+2.13pre7.orig/mount/nfsmount.c
+++ util-linux-ng-2.12r+2.13pre7/mount/nfsmount.c
@@ -317,7 +317,7 @@ int nfsmount(const char *spec, const cha
noacl = 0;
noac = 0;
retry = 10000; /* 10000 minutes ~ 1 week */
- tcp = 0;
+ tcp = 2;
mountprog = MOUNTPROG;
mountvers = 0;
@@ -437,6 +437,8 @@ int nfsmount(const char *spec, const cha
}
}
}
+
+retry_udp:
proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
data.flags = (soft ? NFS_MOUNT_SOFT : 0)
@@ -740,7 +742,13 @@ int nfsmount(const char *spec, const cha
* '0' for port (service unavailable), we then exit,
* notifying the user, rather than hanging up mount.
*/
- if (port == 0 && tcp == 1) {
+ if (port == 0 && tcp) {
+ if (tcp == 2) {
+ fprintf(stderr, "nfs server reported tcp not available, falling back to udp\n");
+ close(fsock);
+ tcp = 0;
+ goto retry_udp;
+ }
perror(_("nfs server reported service unavailable"));
goto fail;
}