[Midnightbsd-cvs] src [10476] trunk/sbin/umount/umount.c: try to figure out the protocol

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jun 6 20:29:22 EDT 2018


Revision: 10476
          http://svnweb.midnightbsd.org/src/?rev=10476
Author:   laffer1
Date:     2018-06-06 20:29:21 -0400 (Wed, 06 Jun 2018)
Log Message:
-----------
try to figure out the protocol

Modified Paths:
--------------
    trunk/sbin/umount/Makefile
    trunk/sbin/umount/umount.8
    trunk/sbin/umount/umount.c

Property Changed:
----------------
    trunk/sbin/umount/umount.8

Modified: trunk/sbin/umount/Makefile
===================================================================
--- trunk/sbin/umount/Makefile	2018-06-07 00:28:01 UTC (rev 10475)
+++ trunk/sbin/umount/Makefile	2018-06-07 00:29:21 UTC (rev 10476)
@@ -1,6 +1,7 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.4 (Berkeley) 6/22/95
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/umount/Makefile 201135 2009-12-28 17:57:37Z delphij $
 
 PROG=	umount
 SRCS=	umount.c vfslist.c mounttab.c

Modified: trunk/sbin/umount/umount.8
===================================================================
--- trunk/sbin/umount/umount.8	2018-06-07 00:28:01 UTC (rev 10475)
+++ trunk/sbin/umount/umount.8	2018-06-07 00:29:21 UTC (rev 10476)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1980, 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -26,9 +27,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)umount.8	8.2 (Berkeley) 5/8/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/umount/umount.8 284652 2015-06-20 23:15:57Z rmacklem $
 .\"
-.Dd May 31, 2011
+.Dd June 17, 2015
 .Dt UMOUNT 8
 .Os
 .Sh NAME
@@ -81,6 +82,9 @@
 For NFS, a forced dismount can take up to 1 minute or more to
 complete against an unresponsive server and may throw away
 data not yet written to the server for this case.
+Also, doing a forced dismount of an NFSv3 mount when
+.Xr rpc.lockd 8
+is running is unsafe and can result in a crash.
 .It Fl h Ar host
 Only file systems mounted from the specified host will be
 unmounted.
@@ -140,6 +144,7 @@
 .Sh SEE ALSO
 .Xr unmount 2 ,
 .Xr fstab 5 ,
+.Xr autounmountd 8 ,
 .Xr mount 8
 .Sh HISTORY
 A


Property changes on: trunk/sbin/umount/umount.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/umount/umount.c
===================================================================
--- trunk/sbin/umount/umount.c	2018-06-07 00:28:01 UTC (rev 10475)
+++ trunk/sbin/umount/umount.c	2018-06-07 00:29:21 UTC (rev 10476)
@@ -49,6 +49,7 @@
 #include <netdb.h>
 #include <rpc/rpc.h>
 #include <rpcsvc/mount.h>
+#include <nfs/nfssvc.h>
 
 #include <ctype.h>
 #include <err.h>
@@ -63,9 +64,9 @@
 
 typedef enum { FIND, REMOVE, CHECKUNIQUE } dowhat;
 
-struct  addrinfo *nfshost_ai = NULL;
-int	fflag, vflag;
-char   *nfshost;
+static struct addrinfo *nfshost_ai = NULL;
+static int	fflag, vflag;
+static char	*nfshost;
 
 struct statfs *checkmntlist(char *);
 int	 checkvfsname (const char *, char **);
@@ -317,6 +318,9 @@
 	CLIENT *clp;
 	char *nfsdirname, *orignfsdirname;
 	char *hostp, *delimp;
+	char buf[1024];
+	struct nfscl_dumpmntopts dumpmntopts;
+	const char *proto_ptr = NULL;
 
 	ai = NULL;
 	do_rpc = 0;
@@ -355,8 +359,24 @@
 		 * mount from mntfromname that is still mounted.
 		 */
 		if (getmntentry(sfs->f_mntfromname, NULL, NULL,
-		    CHECKUNIQUE) != NULL)
+		    CHECKUNIQUE) != NULL) {
 			do_rpc = 1;
+			proto_ptr = "udp";
+			/*
+			 * Try and find out whether this NFS mount is NFSv4 and
+			 * what protocol is being used. If this fails, the
+			 * default is NFSv2,3 and use UDP for the Unmount RPC.
+			 */
+			dumpmntopts.ndmnt_fname = sfs->f_mntonname;
+			dumpmntopts.ndmnt_buf = buf;
+			dumpmntopts.ndmnt_blen = sizeof(buf);
+			if (nfssvc(NFSSVC_DUMPMNTOPTS, &dumpmntopts) >= 0) {
+				if (strstr(buf, "nfsv4,") != NULL)
+					do_rpc = 0;
+				else if (strstr(buf, ",tcp,") != NULL)
+					proto_ptr = "tcp";
+			}
+		}
 	}
 
 	if (!namematch(ai)) {
@@ -394,7 +414,7 @@
 	 * has been unmounted.
 	 */
 	if (ai != NULL && !(fflag & MNT_FORCE) && do_rpc) {
-		clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS, "udp");
+		clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS3, proto_ptr);
 		if (clp  == NULL) {
 			warnx("%s: %s", hostp,
 			    clnt_spcreateerror("MOUNTPROG"));



More information about the Midnightbsd-cvs mailing list