Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/umount Use the protocol we mounted the filesystem with ...
details: https://anonhg.NetBSD.org/src/rev/76d4de4131ce
branches: trunk
changeset: 787728:76d4de4131ce
user: christos <christos%NetBSD.org@localhost>
date: Sat Jun 29 22:53:04 2013 +0000
description:
Use the protocol we mounted the filesystem with instead of always udp.
(untested, but should fail back to udp).
diffstat:
sbin/umount/Makefile | 8 ++++----
sbin/umount/umount.c | 31 ++++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 7 deletions(-)
diffs (95 lines):
diff -r a79f06e180ca -r 76d4de4131ce sbin/umount/Makefile
--- a/sbin/umount/Makefile Sat Jun 29 21:06:57 2013 +0000
+++ b/sbin/umount/Makefile Sat Jun 29 22:53:04 2013 +0000
@@ -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 @@
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>
diff -r a79f06e180ca -r 76d4de4131ce sbin/umount/umount.c
--- a/sbin/umount/umount.c Sat Jun 29 21:06:57 2013 +0000
+++ b/sbin/umount/umount.c Sat Jun 29 22:53:04 2013 +0000
@@ -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 @@
#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 @@
typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
#ifndef SMALL
+#include "mount_nfs.h"
#include "mountprog.h"
static int fake, verbose;
@@ -76,6 +77,7 @@
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 @@
#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 @@
{
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
Home |
Main Index |
Thread Index |
Old Index