Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/umount Instead of borrowing the mount code to get the n...
details: https://anonhg.NetBSD.org/src/rev/619611a5a67e
branches: trunk
changeset: 787752:619611a5a67e
user: christos <christos%NetBSD.org@localhost>
date: Mon Jul 01 15:16:33 2013 +0000
description:
Instead of borrowing the mount code to get the nfs arguments, just use
the system call directly. It is shorter and works...
diffstat:
sbin/umount/Makefile | 8 ++++----
sbin/umount/umount.c | 35 +++++++++++++----------------------
2 files changed, 17 insertions(+), 26 deletions(-)
diffs (116 lines):
diff -r 371fa5c873ac -r 619611a5a67e sbin/umount/Makefile
--- a/sbin/umount/Makefile Mon Jul 01 12:48:03 2013 +0000
+++ b/sbin/umount/Makefile Mon Jul 01 15:16:33 2013 +0000
@@ -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 @@
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>
diff -r 371fa5c873ac -r 619611a5a67e sbin/umount/umount.c
--- a/sbin/umount/umount.c Mon Jul 01 12:48:03 2013 +0000
+++ b/sbin/umount/umount.c Mon Jul 01 15:16:33 2013 +0000
@@ -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 @@
#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 @@
#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 @@
typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
#ifndef SMALL
-#include "mount_nfs.h"
#include "mountprog.h"
static int fake, verbose;
@@ -186,6 +186,7 @@
#endif /* !SMALL */
const char *mntpt;
char *type, rname[MAXPATHLEN];
+ const char *proto = NULL;
mntwhat what;
struct stat sb;
@@ -243,6 +244,7 @@
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 @@
#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 @@
}
static const char *
-getmntproto(const char *mntpt)
+getmntproto(const char *name)
{
struct nfs_args nfsargs;
- struct sockaddr_storage sa;
- int proto;
- char *name;
+ struct sockaddr_storage ss;
- 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);
-
- // 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 */
Home |
Main Index |
Thread Index |
Old Index