Module Name:    src
Committed By:   christos
Date:           Sat Jun 29 22:53:04 UTC 2013

Modified Files:
        src/sbin/umount: Makefile umount.c

Log Message:
Use the protocol we mounted the filesystem with instead of always udp.
(untested, but should fail back to udp).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/umount/Makefile
cvs rdiff -u -r1.43 -r1.44 src/sbin/umount/umount.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/umount/Makefile
diff -u src/sbin/umount/Makefile:1.16 src/sbin/umount/Makefile:1.17
--- src/sbin/umount/Makefile:1.16	Sat Jan 21 06:59:53 2006
+++ src/sbin/umount/Makefile	Sat Jun 29 18:53:04 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2006/01/21 11:59:53 dsl Exp $
+#	$NetBSD: Makefile,v 1.17 2013/06/29 22:53:04 christos Exp $
 #	@(#)Makefile	8.4 (Berkeley) 6/22/95
 
 .include <bsd.own.mk>
@@ -11,9 +11,9 @@ MAN=	umount.8
 CPPFLAGS+= -DSMALL
 .else
 MOUNT=	${NETBSDSRCDIR}/sbin/mount
-CPPFLAGS+= -I${MOUNT}
-.PATH:	${MOUNT}
-SRCS+=	vfslist.c
+CPPFLAGS+= -I${MOUNT} -I${MOUNT}_nfs
+.PATH:	${MOUNT} ${MOUNT}_nfs
+SRCS+=	vfslist.c getnfsargs.c
 .endif
 
 .include <bsd.prog.mk>

Index: src/sbin/umount/umount.c
diff -u src/sbin/umount/umount.c:1.43 src/sbin/umount/umount.c:1.44
--- src/sbin/umount/umount.c:1.43	Tue Aug  5 16:57:45 2008
+++ src/sbin/umount/umount.c	Sat Jun 29 18:53:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: umount.c,v 1.43 2008/08/05 20:57:45 pooka Exp $	*/
+/*	$NetBSD: umount.c,v 1.44 2013/06/29 22:53:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1989, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)umount.c	8.8 (Berkeley) 5/8/95";
 #else
-__RCSID("$NetBSD: umount.c,v 1.43 2008/08/05 20:57:45 pooka Exp $");
+__RCSID("$NetBSD: umount.c,v 1.44 2013/06/29 22:53:04 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,6 +67,7 @@ __RCSID("$NetBSD: umount.c,v 1.43 2008/0
 typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
 
 #ifndef SMALL
+#include "mount_nfs.h"
 #include "mountprog.h"
 
 static int	 fake, verbose;
@@ -76,6 +77,7 @@ static struct addrinfo *nfshost_ai = NUL
 static int	 namematch(const struct addrinfo *);
 static int	 sacmp(const struct sockaddr *, const struct sockaddr *);
 static int	 xdr_dir(XDR *, char *);
+static const char *getmntproto(const char *);
 #endif /* !SMALL */
 
 static int	 fflag;
@@ -273,7 +275,8 @@ umountfs(const char *name, const char **
 
 #ifndef SMALL
 	if (ai != NULL && !(fflag & MNT_FORCE)) {
-		clp = clnt_create(hostp, RPCPROG_MNT, RPCMNT_VER1, "udp");
+		clp = clnt_create(hostp, RPCPROG_MNT, RPCMNT_VER1,
+		    getmntproto(mntpt));
 		if (clp  == NULL) {
 			clnt_pcreateerror("Cannot MNT PRC");
 			return 1;
@@ -381,6 +384,28 @@ xdr_dir(XDR *xdrsp, char *dirp)
 {
 	return xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN);
 }
+
+static const char *
+getmntproto(const char *mntpt)
+{
+	struct nfs_args nfsargs;
+	struct sockaddr_storage sa;
+	int proto;
+
+	char *name = strdup(mntpt);
+	memset(&sa, 0, sizeof(sa));
+	nfsargs.addr = (struct sockaddr *)&sa; 
+	nfsargs.addrlen = sizeof(sa);
+	if ((name = strdup(mntpt)) == NULL)
+		err(EXIT_FAILURE, "strdup");
+	if (!getnfsargs(name, &nfsargs))
+		proto = IPPROTO_UDP;
+	else
+		proto = nfsargs.proto;
+
+	// XXX: Return udp6/tcp6 too?
+	return proto == IPPROTO_UDP ? "udp" : "tcp";
+}
 #endif /* !SMALL */
 
 static void

Reply via email to