Module Name:    src
Committed By:   christos
Date:           Mon Jul  1 15:16:33 UTC 2013

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

Log Message:
Instead of borrowing the mount code to get the nfs arguments, just use
the system call directly. It is shorter and works...


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/umount/Makefile
cvs rdiff -u -r1.45 -r1.46 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.17 src/sbin/umount/Makefile:1.18
--- src/sbin/umount/Makefile:1.17	Sat Jun 29 18:53:04 2013
+++ src/sbin/umount/Makefile	Mon Jul  1 11:16:33 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2013/06/29 22:53:04 christos Exp $
+#	$NetBSD: Makefile,v 1.18 2013/07/01 15:16:33 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} -I${MOUNT}_nfs
-.PATH:	${MOUNT} ${MOUNT}_nfs
-SRCS+=	vfslist.c getnfsargs.c
+CPPFLAGS+= -I${MOUNT}
+.PATH:	${MOUNT}
+SRCS+=	vfslist.c
 .endif
 
 .include <bsd.prog.mk>

Index: src/sbin/umount/umount.c
diff -u src/sbin/umount/umount.c:1.45 src/sbin/umount/umount.c:1.46
--- src/sbin/umount/umount.c:1.45	Sat Jun 29 19:06:29 2013
+++ src/sbin/umount/umount.c	Mon Jul  1 11:16:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: umount.c,v 1.45 2013/06/29 23:06:29 christos Exp $	*/
+/*	$NetBSD: umount.c,v 1.46 2013/07/01 15:16:33 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.45 2013/06/29 23:06:29 christos Exp $");
+__RCSID("$NetBSD: umount.c,v 1.46 2013/07/01 15:16:33 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,6 +55,7 @@ __RCSID("$NetBSD: umount.c,v 1.45 2013/0
 #include <rpc/pmap_clnt.h>
 #include <rpc/pmap_prot.h>
 #include <nfs/rpcv2.h>
+#include <nfs/nfsmount.h>
 #endif /* !SMALL */
 
 #include <err.h>
@@ -67,7 +68,6 @@ __RCSID("$NetBSD: umount.c,v 1.45 2013/0
 typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
 
 #ifndef SMALL
-#include "mount_nfs.h"
 #include "mountprog.h"
 
 static int	 fake, verbose;
@@ -186,6 +186,7 @@ umountfs(const char *name, const char **
 #endif /* !SMALL */
 	const char *mntpt;
 	char *type, rname[MAXPATHLEN];
+	const char *proto = NULL;
 	mntwhat what;
 	struct stat sb;
 
@@ -243,6 +244,7 @@ umountfs(const char *name, const char **
 		if (!strncmp(type, MOUNT_NFS,
 		    sizeof(((struct statvfs *)NULL)->f_fstypename))) {
 			char *delimp;
+			proto = getmntproto(mntpt);
 			/* look for host:mountpoint */
 			if ((delimp = strrchr(name, ':')) != NULL) {
 				int len = delimp - name;
@@ -275,8 +277,7 @@ umountfs(const char *name, const char **
 
 #ifndef SMALL
 	if (ai != NULL && !(fflag & MNT_FORCE)) {
-		clp = clnt_create(hostp, RPCPROG_MNT, RPCMNT_VER1,
-		    getmntproto(mntpt));
+		clp = clnt_create(hostp, RPCPROG_MNT, RPCMNT_VER1, proto);
 		if (clp  == NULL) {
 			clnt_pcreateerror("Cannot MNT PRC");
 			return 1;
@@ -386,26 +387,16 @@ xdr_dir(XDR *xdrsp, char *dirp)
 }
 
 static const char *
-getmntproto(const char *mntpt)
+getmntproto(const char *name)
 {
 	struct nfs_args nfsargs;
-	struct sockaddr_storage sa;
-	int proto;
-	char *name;
-
-	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;
-	free(name);
+	struct sockaddr_storage ss;
 
-	// XXX: Return udp6/tcp6 too?
-	return proto == IPPROTO_UDP ? "udp" : "tcp";
+	nfsargs.sotype = SOCK_DGRAM;
+	nfsargs.addr = (struct sockaddr *)&ss; 
+	nfsargs.addrlen = sizeof(ss);
+	(void)mount("nfs", name, MNT_GETARGS, &nfsargs, sizeof(nfsargs));
+	return nfsargs.sotype == SOCK_STREAM ? "tcp" : "udp";
 }
 #endif /* !SMALL */
 

Reply via email to