[Midnightbsd-cvs] src [11111] trunk/sbin/mount_nfs/mount_nfs.c: sync mount with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jun 19 14:58:22 EDT 2018


Revision: 11111
          http://svnweb.midnightbsd.org/src/?rev=11111
Author:   laffer1
Date:     2018-06-19 14:58:21 -0400 (Tue, 19 Jun 2018)
Log Message:
-----------
sync mount with freebsd

Modified Paths:
--------------
    trunk/sbin/mount/Makefile
    trunk/sbin/mount/extern.h
    trunk/sbin/mount/getmntopts.3
    trunk/sbin/mount/getmntopts.c
    trunk/sbin/mount/mntopts.h
    trunk/sbin/mount/mount.8
    trunk/sbin/mount/mount.c
    trunk/sbin/mount/mount_fs.c
    trunk/sbin/mount/pathnames.h
    trunk/sbin/mount/vfslist.c
    trunk/sbin/mount_cd9660/Makefile
    trunk/sbin/mount_cd9660/mount_cd9660.8
    trunk/sbin/mount_cd9660/mount_cd9660.c
    trunk/sbin/mount_msdosfs/Makefile
    trunk/sbin/mount_msdosfs/mount_msdosfs.8
    trunk/sbin/mount_msdosfs/mount_msdosfs.c
    trunk/sbin/mount_nfs/Makefile
    trunk/sbin/mount_nfs/mount_nfs.8
    trunk/sbin/mount_nfs/mount_nfs.c

Added Paths:
-----------
    trunk/sbin/mount/mount.conf.8

Property Changed:
----------------
    trunk/sbin/mount/getmntopts.3
    trunk/sbin/mount/mount.8
    trunk/sbin/mount_cd9660/mount_cd9660.8
    trunk/sbin/mount_msdosfs/mount_msdosfs.8
    trunk/sbin/mount_nfs/mount_nfs.8

Modified: trunk/sbin/mount/Makefile
===================================================================
--- trunk/sbin/mount/Makefile	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/Makefile	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,9 +1,10 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.6 (Berkeley) 5/8/95
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/mount/Makefile 253433 2013-07-17 19:32:07Z rodrigc $
 
 PROG=	mount
 SRCS=	mount.c mount_fs.c getmntopts.c vfslist.c
-MAN=	mount.8
+MAN=	mount.8 mount.conf.8
 # We do NOT install the getmntopts.3 man page.
 
 DPADD=	${LIBUTIL}

Modified: trunk/sbin/mount/extern.h
===================================================================
--- trunk/sbin/mount/extern.h	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/extern.h	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997 FreeBSD Inc.
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sbin/mount/extern.h 152738 2005-11-23 23:22:56Z rodrigc $
  */
 
 /* vfslist.c */

Modified: trunk/sbin/mount/getmntopts.3
===================================================================
--- trunk/sbin/mount/getmntopts.3	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/getmntopts.3	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1994
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -26,7 +27,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)getmntopts.3	8.3 (Berkeley) 3/30/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/mount/getmntopts.3 241581 2012-10-15 13:20:08Z eadler $
 .\"
 .Dd February 17, 2008
 .Dt GETMNTOPTS 3


Property changes on: trunk/sbin/mount/getmntopts.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/mount/getmntopts.c
===================================================================
--- trunk/sbin/mount/getmntopts.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/getmntopts.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -33,7 +34,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/mount/getmntopts.c 310378 2016-12-21 23:16:58Z brooks $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -46,7 +47,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sysexits.h>
 
 #include "mntopts.h"
 
@@ -124,16 +124,18 @@
 		*rrpout = '\0';
 }
 
-void
+int
 checkpath(const char *path, char *resolved)
 {
 	struct stat sb;
 
-	if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
-		if (!S_ISDIR(sb.st_mode))
-			errx(EX_USAGE, "%s: not a directory", resolved);
-	} else
-		errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
+	if (realpath(path, resolved) == NULL || stat(resolved, &sb) != 0)
+		return (1);
+	if (!S_ISDIR(sb.st_mode)) {
+		errno = ENOTDIR;
+		return (1);
+	}
+	return (0);
 }
 
 void
@@ -180,3 +182,17 @@
 	va_end(ap);
 	build_iovec(iov, iovlen, name, strdup(val), (size_t)-1);
 }
+
+/*
+ * Free the iovec and reset to NULL with zero length.  Useful for calling
+ * nmount in a loop.
+ */
+void
+free_iovec(struct iovec **iov, int *iovlen)
+{
+	int i;
+
+	for (i = 0; i < *iovlen; i++)
+		free((*iov)[i].iov_base);
+	free(*iov);
+}

Modified: trunk/sbin/mount/mntopts.h
===================================================================
--- trunk/sbin/mount/mntopts.h	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/mntopts.h	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994
  *      The Regents of the University of California.  All rights reserved.
@@ -27,13 +28,13 @@
  * SUCH DAMAGE.
  *
  *	@(#)mntopts.h	8.7 (Berkeley) 3/29/95
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sbin/mount/mntopts.h 310378 2016-12-21 23:16:58Z brooks $
  */
 
 struct mntopt {
 	const char *m_option;	/* option name */
 	int m_inverse;		/* if a negative option, e.g. "atime" */
-	int m_flag;		/* bit to set, e.g. MNT_RDONLY */
+	long long m_flag;	/* bit to set, e.g. MNT_RDONLY */
 	int m_altloc;		/* 1 => set bit in altflags */
 };
 
@@ -55,6 +56,7 @@
 #define MOPT_MULTILABEL		{ "multilabel",	0, MNT_MULTILABEL, 0 }
 #define MOPT_ACLS		{ "acls",	0, MNT_ACLS, 0 }
 #define MOPT_NFS4ACLS		{ "nfsv4acls",	0, MNT_NFS4ACLS, 0 }
+#define MOPT_AUTOMOUNTED	{ "automounted",0, MNT_AUTOMOUNTED, 0 }
 
 /* Control flags. */
 #define MOPT_FORCE		{ "force",	0, MNT_FORCE, 0 }
@@ -89,11 +91,13 @@
 	MOPT_NOCLUSTERW,						\
 	MOPT_MULTILABEL,						\
 	MOPT_ACLS,							\
-	MOPT_NFS4ACLS
+	MOPT_NFS4ACLS,							\
+	MOPT_AUTOMOUNTED
 
 void getmntopts(const char *, const struct mntopt *, int *, int *);
 void rmslashes(char *, char *);
-void checkpath(const char *, char resolved_path[]);
+int checkpath(const char *, char resolved_path[]);
 extern int getmnt_silent;
 void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len);
 void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...);
+void free_iovec(struct iovec **iovec, int *iovlen);

Modified: trunk/sbin/mount/mount.8
===================================================================
--- trunk/sbin/mount/mount.8	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/mount.8	2018-06-19 18:58:21 UTC (rev 11111)
@@ -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.
 .\"
 .\"     @(#)mount.8	8.8 (Berkeley) 6/16/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/mount/mount.8 332754 2018-04-19 05:52:47Z avg $
 .\"
-.Dd July 12, 2012
+.Dd March 22, 2017
 .Dt MOUNT 8
 .Os
 .Sh NAME
@@ -106,11 +107,21 @@
 Also
 forces the R/W mount of an unclean file system (dangerous; use with
 caution).
+.It Fl L
+When used in conjunction with the
+.Fl a
+option, mount
+.Em only
+those file systems which are marked as
+.Dq Li late .
 .It Fl l
 When used in conjunction with the
 .Fl a
 option, also mount those file systems which are marked as
 .Dq Li late .
+.It Fl n
+For compatibility with some other implementations, this flag is
+currently a no-op.
 .It Fl o
 Options are specified with a
 .Fl o
@@ -140,16 +151,20 @@
 .Cm async
 flag should be used sparingly, and only when some data recovery
 mechanism is present.
+.It Cm automounted
+This flag indicates that the file system was mounted by
+.Xr automountd 8 .
+Automounted file systems are automatically unmounted by
+.Xr autounmountd 8 .
+.It Cm autoro
+Mount the file system read-write.
+If that fails with an error that suggests that the media could be read-only,
+then automatically try to mount the file system read-only.
 .It Cm current
 When used with the
 .Fl u
 flag, this is the same as specifying the options currently in effect for
 the mounted file system.
-.It Cm failok
-If this option is specified,
-.Nm
-will return 0 even if an error occurs
-during the mount of the filesystem.
 .It Cm force
 The same as
 .Fl f ;
@@ -179,7 +194,7 @@
 directly.
 For example:
 .Bd -literal
-mount -t foofs -o mountprog=/mydir/fooprog /dev/acd0 /mnt
+mount -t foofs -o mountprog=/mydir/fooprog /dev/cd0 /mnt
 .Ed
 .It Cm multilabel
 Enable multi-label Mandatory Access Control, or MAC, on the specified file
@@ -446,11 +461,8 @@
 .Cm mfs ,
 .Cm msdosfs ,
 .Cm nfs ,
-.Cm ntfs ,
-.Cm nwfs ,
 .Cm nullfs ,
 .Cm oldnfs ,
-.Cm portalfs ,
 .Cm smbfs ,
 .Cm udf ,
 and
@@ -537,21 +549,22 @@
 .Xr nmount 2 ,
 .Xr acl 3 ,
 .Xr mac 4 ,
+.Xr cd9660 5 ,
 .Xr devfs 5 ,
 .Xr ext2fs 5 ,
 .Xr fstab 5 ,
 .Xr procfs 5 ,
+.Xr automount 8 ,
+.Xr fstyp 8 ,
 .Xr kldload 8 ,
 .Xr mount_cd9660 8 ,
 .Xr mount_msdosfs 8 ,
 .Xr mount_nfs 8 ,
-.Xr mount_ntfs 8 ,
 .Xr mount_nullfs 8 ,
-.Xr mount_nwfs 8 ,
-.Xr mount_portalfs 8 ,
 .Xr mount_smbfs 8 ,
 .Xr mount_udf 8 ,
 .Xr mount_unionfs 8 ,
+.Xr tmpfs 5 ,
 .Xr umount 8 ,
 .Xr zfs 8 ,
 .Xr zpool 8


Property changes on: trunk/sbin/mount/mount.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/mount/mount.c
===================================================================
--- trunk/sbin/mount/mount.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/mount.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -37,7 +38,7 @@
 #endif /* not lint */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/mount/mount.c 319261 2017-05-30 22:36:24Z asomers $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -66,7 +67,7 @@
 #define MOUNT_META_OPTION_FSTAB		"fstab"
 #define MOUNT_META_OPTION_CURRENT	"current"
 
-int debug, fstab_style, verbose;
+static int debug, fstab_style, verbose;
 
 struct cpa {
 	char	**a;
@@ -114,6 +115,7 @@
 	{ MNT_ACLS,		"acls" },
 	{ MNT_NFS4ACLS,		"nfsv4acls" },
 	{ MNT_GJOURNAL,		"gjournal" },
+	{ MNT_AUTOMOUNTED,	"automounted" },
 	{ 0, NULL }
 };
 
@@ -142,8 +144,8 @@
 	 */
 	unsigned int i;
 	const char *fs[] = {
-	"cd9660", "mfs", "msdosfs", "nfs", "ntfs",
-	"nwfs", "nullfs", "oldnfs", "portalfs", "smbfs", "udf", "unionfs",
+	"cd9660", "mfs", "msdosfs", "nfs",
+	"nullfs", "oldnfs", "smbfs", "udf", "unionfs",
 	NULL
 	};
 
@@ -245,14 +247,15 @@
 	struct fstab *fs;
 	struct statfs *mntbuf;
 	int all, ch, i, init_flags, late, failok, mntsize, rval, have_fstab, ro;
+	int onlylate;
 	char *cp, *ep, *options;
 
-	all = init_flags = late = 0;
+	all = init_flags = late = onlylate = 0;
 	ro = 0;
 	options = NULL;
 	vfslist = NULL;
 	vfstype = "ufs";
-	while ((ch = getopt(argc, argv, "adF:flo:prt:uvw")) != -1)
+	while ((ch = getopt(argc, argv, "adF:fLlno:prt:uvw")) != -1)
 		switch (ch) {
 		case 'a':
 			all = 1;
@@ -266,9 +269,16 @@
 		case 'f':
 			init_flags |= MNT_FORCE;
 			break;
+		case 'L':
+			onlylate = 1;
+			late = 1;
+			break;
 		case 'l':
 			late = 1;
 			break;
+		case 'n':
+			/* For compatibility with the Linux version of mount. */
+			break;
 		case 'o':
 			if (*optarg) {
 				options = catopt(options, optarg);
@@ -327,6 +337,8 @@
 					continue;
 				if (hasopt(fs->fs_mntops, "noauto"))
 					continue;
+				if (!hasopt(fs->fs_mntops, "late") && onlylate)
+					continue;
 				if (hasopt(fs->fs_mntops, "late") && !late)
 					continue;
 				if (hasopt(fs->fs_mntops, "failok"))
@@ -474,10 +486,18 @@
 		strlcpy(realfsfile, fs->fs_file, sizeof(realfsfile));
 	}
 
+	/* 
+	 * Consider the filesystem to be mounted if:
+	 * It has the same mountpoint as a mounted filesytem, and
+	 * It has the same type as that same mounted filesystem, and
+	 * It has the same device name as that same mounted filesystem, OR
+	 *     It is a nonremountable filesystem
+	 */
 	for (i = mntsize - 1; i >= 0; --i)
 		if (strcmp(realfsfile, mntbuf[i].f_mntonname) == 0 &&
+		    strcmp(fs->fs_vfstype, mntbuf[i].f_fstypename) == 0 && 
 		    (!isremountable(fs->fs_vfstype) ||
-		     strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
+		     (strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0)))
 			return (1);
 	return (0);
 }
@@ -539,7 +559,10 @@
 	static struct cpa mnt_argv;
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(name, mntpath);
+	if (checkpath(name, mntpath) != 0) {
+		warn("%s", mntpath);
+		return (1);
+	}
 	name = mntpath;
 
 	if (mntopts == NULL)
@@ -575,7 +598,7 @@
 	append_arg(&mnt_argv, execname);
 	mangle(optbuf, &mnt_argv);
 	if (mountprog != NULL)
-		strcpy(execname, mountprog);
+		strlcpy(execname, mountprog, sizeof(execname));
 
 	append_arg(&mnt_argv, strdup(spec));
 	append_arg(&mnt_argv, strdup(name));
@@ -883,8 +906,9 @@
 
 	if (strncmp(ent->f_mntfromname, "<below>", 7) == 0 ||
 	    strncmp(ent->f_mntfromname, "<above>", 7) == 0) {
-		strcpy(ent->f_mntfromname, (strnstr(ent->f_mntfromname, ":", 8)
-		    +1));
+		strlcpy(ent->f_mntfromname,
+		    (strnstr(ent->f_mntfromname, ":", 8) +1),
+		    sizeof(ent->f_mntfromname));
 	}
 
 	l = strlen(ent->f_mntfromname);

Added: trunk/sbin/mount/mount.conf.8
===================================================================
--- trunk/sbin/mount/mount.conf.8	                        (rev 0)
+++ trunk/sbin/mount/mount.conf.8	2018-06-19 18:58:21 UTC (rev 11111)
@@ -0,0 +1,253 @@
+.\" $MidnightBSD$
+.\" Copyright (c) 2013 Marcel Moolenaar
+.\" Copyright (c) 2013 Craig Rodrigues
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: stable/10/sbin/mount/mount.conf.8 316221 2017-03-30 05:17:23Z ngie $
+.\"
+.\"
+.Dd July 7, 2013
+.Dt MOUNT.CONF 8
+.Os
+.Sh NAME
+.Nm mount.conf
+.Nd root file system mount configuration file
+.Sh SYNOPSIS
+.Pa /.mount.conf
+.Sh DESCRIPTION
+During the bootup process, the
+.Fx
+kernel will try to mount the root file system
+using the logic in the
+.Fn vfs_mountroot
+function in
+.Pa src/sys/kern/vfs_mountroot.c .
+The root mount logic can be described as follows:
+.Bl -enum
+.It
+The kernel will synthesize in memory a config file
+with default directives for mounting
+the root file system.
+The logic for this is in
+.Fn vfs_mountroot_conf0 .
+.It
+The kernel will first mount
+.Xr devfs 8
+as the root file system.
+.It
+Next, the kernel will parse the in-memory config file created in step 1
+and try to mount the actual root file system.
+See
+.Sx FILE FORMAT
+for the format of the config file.
+.It
+When the actual root file system is mounted,
+.Xr devfs 5
+will be re-mounted on the
+.Pa /dev
+directory.
+.It
+If a
+.Pa /.mount.conf
+file does not exist in the root file system which was
+just mounted, the root mount logic stops here.
+.It
+If a
+.Pa /.mount.conf
+file exists in the root file system which was just mounted,
+this file will be parsed, and the kernel will use this new config
+file to try to re-mount the root file system.
+See
+.Sx FILE FORMAT
+for the format of the config file.
+.It
+If the new root file system has a
+.Pa /.mount
+directory, the old root file system will be re-mounted
+on
+.Pa /.mount .
+.It
+The root mount logic will go back to step 4.
+.El
+.Pp
+The root mount logic is recursive, and step 8 will
+be repeated as long as each new root file system
+which is mounted has a
+.Pa /.mount.conf
+file.
+.Sh FILE FORMAT
+The kernel parses each line in
+.Pa .mount.conf
+and then tries to perform the action specified on that line as soon as it is parsed.
+.Bl -tag -width "XXXXXXXXXX"
+.It Ic #
+A line beginning with a # is a comment and is ignored.
+.It Ic {FS}:{MOUNTPOINT} {OPTIONS}
+The kernel will try to mount this in an
+operation equivalent to:
+.Bd -literal -offset indent
+mount -t {FS} -o {OPTIONS} {MOUNTPOINT} /
+.Ed
+.Pp
+If this is successfully mounted,
+further lines in
+.Pa .mount.conf
+are ignored.
+If all lines in
+.Pa .mount.conf
+have been processed and no root file system has been successfully
+mounted, then the action specified by
+.Ic .onfail
+is performed.
+.It Ic .ask
+When the kernel processes this line, a
+.Li mountroot>
+command-line prompt is displayed.
+At this prompt, the operator can enter the
+the root mount.
+.It Ic .md Ar file
+Create a memory backed
+.Xr md 4
+virtual disk, using
+.Ar file
+as the backing store.
+.It Ic .onfail Ar [panic|reboot|retry|continue]
+If after parsing all the lines in
+.Pa .mount.conf
+the kernel is unable to mount a root file system,
+the
+.Ic .onfail
+directive tells the kernel what action to perform.
+.It Ic .timeout Ar N
+Before trying to mount a root file system,
+if the root mount device does not exist, wait at most
+.Ar N
+seconds for the device to appear before trying to mount it.
+If
+.Ic .timeout
+is not specified, the default timeout is 3 seconds.
+.El
+.Sh EXAMPLES
+The following example
+.Pa .mount.conf
+will direct the kernel to try mounting the root file system
+first as an ISO CD9660 file system on
+.Pa /dev/cd0 ,
+then if that does not work, as an ISO CD9660 file system on
+.Pa /dev/acd0 ,
+and then if that does not work, as a UFS file system on
+.Pa /dev/ada0s1a .
+If that does not work, a
+.Li mountroot>
+command-line prompt will be displayed where the operator
+can manually enter the root file system to mount.
+Finally if that does not work, the kernel will panic.
+.Bd -literal -offset indent
+.Li .onfail panic
+.Li .timeout 3
+cd9660:/dev/cd0 ro
+.Li .timeout 0
+cd9660:/dev/acd0 ro
+.Li .timeout 3
+ufs:/dev/ada0s1a
+.Li .ask
+.Ed
+.Pp
+The following example
+.Pa .mount.conf
+will direct the kernel to create a
+.Xr md 4
+memory disk attached to the file
+.Pa /data/OS-1.0.iso
+and then mount the ISO CD9660 file system
+on the md device which was just created.
+The last line is a comment which is ignored.
+.Bd -literal -offset indent
+.Li .timeout 3
+.Li .md /data/OS-1.0.iso
+.Li cd9600:/dev/md# ro
+.Li # Can also use cd9660:/dev/md0 ro
+.Ed
+.Pp
+The following example
+.Pa .mount.conf
+will direct the kernel to create a
+.Xr md 4
+memory disk attached to the file
+.Pa /data/base.ufs.uzip
+and then mount the UFS file system
+on the md uzip device which was just created
+by the
+.Xr geom_uzip 4
+driver.
+.Bd -literal -offset indent
+.Li .md /data/base.ufs.uzip
+.Li ufs:/dev/md#.uzip ro
+.Li # Can also use ufs:/dev/md0.uzip ro
+.Ed
+.Pp
+The following example
+.Pa .mount.conf
+will direct the kernel to do a unionfs
+mount on a directory
+.Pa /jail/freebsd-8-stable
+which has a
+.Xr chroot 2
+environment.
+.Bd -literal -offset indent
+.Li .timeout 3
+.Li unionfs:/jail/freebsd-8-stable
+.Ed
+.Sh NOTES
+For each root file system which is mounted, a
+.Pa /dev
+directory
+.Em must
+exist so that the root mount logic can properly re-mount
+.Xr devfs 8 .
+If this directory does not exist, the system
+may hang during the bootup process.
+.Sh SEE ALSO
+.Xr nmount 2 ,
+.Xr md 4 ,
+.Xr boot.config 5 ,
+.Xr fstab 5 ,
+.Xr boot 8 ,
+.Xr loader 8 ,
+.Xr mount 8
+.Sh HISTORY
+The
+.Nm
+file first appeared in
+.Fx 9.0 .
+.Sh AUTHORS
+.An -nosplit
+The root mount logic in the
+.Fx
+kernel which parses
+.Pa /.mount.conf
+was written by
+.An Marcel Moolenaar Aq Mt marcel at FreeBSD.org .
+This man page was written by
+.An Craig Rodrigues Aq Mt rodrigc at FreeBSD.org .


Property changes on: trunk/sbin/mount/mount.conf.8
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sbin/mount/mount_fs.c
===================================================================
--- trunk/sbin/mount/mount_fs.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/mount_fs.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -41,7 +42,7 @@
 static char sccsid[] = "@(#)mount_fs.c	8.6 (Berkeley) 4/26/95";
 #endif
 static const char rcsid[] =
-	"$MidnightBSD$";
+	"$FreeBSD: stable/10/sbin/mount/mount_fs.c 230377 2012-01-20 12:59:12Z jh $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -58,7 +59,7 @@
 #include "extern.h"
 #include "mntopts.h"
 
-struct mntopt mopts[] = {
+static struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_END
 };
@@ -117,7 +118,10 @@
 	dev = argv[0];
 	dir = argv[1];
 
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0) {
+		warn("%s", mntpath);
+		return (1);
+	}
 	(void)rmslashes(dev, dev);
 
 	build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);

Modified: trunk/sbin/mount/pathnames.h
===================================================================
--- trunk/sbin/mount/pathnames.h	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/pathnames.h	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1989, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -27,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)pathnames.h	8.2 (Berkeley) 3/27/94
- *	$MidnightBSD$
+ *	$FreeBSD: stable/10/sbin/mount/pathnames.h 128073 2004-04-09 19:58:40Z markm $
  */
 
 #define	_PATH_MOUNTDPID	"/var/run/mountd.pid"

Modified: trunk/sbin/mount/vfslist.c
===================================================================
--- trunk/sbin/mount/vfslist.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount/vfslist.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -33,7 +34,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/mount/vfslist.c 201227 2009-12-29 22:53:27Z ed $");
 
 #include <err.h>
 #include <stdlib.h>

Modified: trunk/sbin/mount_cd9660/Makefile
===================================================================
--- trunk/sbin/mount_cd9660/Makefile	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_cd9660/Makefile	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.3 (Berkeley) 3/27/94
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/mount_cd9660/Makefile 198236 2009-10-19 16:00:24Z ru $
 
 PROG=	mount_cd9660
 SRCS=	mount_cd9660.c getmntopts.c

Modified: trunk/sbin/mount_cd9660/mount_cd9660.8
===================================================================
--- trunk/sbin/mount_cd9660/mount_cd9660.8	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_cd9660/mount_cd9660.8	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1993, 1994
 .\"     The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
@@ -30,9 +31,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)mount_cd9660.8	8.3 (Berkeley) 3/27/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/mount_cd9660/mount_cd9660.8 318623 2017-05-22 06:20:58Z ngie $
 .\"
-.Dd March 5, 2013
+.Dd March 22, 2017
 .Dt MOUNT_CD9660 8
 .Os
 .Sh NAME
@@ -138,6 +139,7 @@
 .Xr cdcontrol 1 ,
 .Xr mount 2 ,
 .Xr unmount 2 ,
+.Xr cd9660 5 ,
 .Xr fstab 5 ,
 .Xr mount 8
 .Sh HISTORY
@@ -147,7 +149,7 @@
 .Bx 4.4 .
 .Pp
 The Unicode conversion routine was added by
-.An Ryuichiro Imura Aq imura at ryu16.org
+.An Ryuichiro Imura Aq Mt imura at ryu16.org
 in 2003.
 .Sh BUGS
 POSIX device node mapping is currently not supported.


Property changes on: trunk/sbin/mount_cd9660/mount_cd9660.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/mount_cd9660/mount_cd9660.c
===================================================================
--- trunk/sbin/mount_cd9660/mount_cd9660.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_cd9660/mount_cd9660.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1992, 1993, 1994
  *      The Regents of the University of California.  All rights reserved.
@@ -45,7 +46,7 @@
 static char sccsid[] = "@(#)mount_cd9660.c	8.7 (Berkeley) 5/1/95";
 */
 static const char rcsid[] =
-  "$MidnightBSD$";
+  "$FreeBSD: stable/10/sbin/mount_cd9660/mount_cd9660.c 247856 2013-03-05 22:41:35Z jkim $";
 #endif /* not lint */
 
 #include <sys/cdio.h>
@@ -68,7 +69,7 @@
 
 #include "mntopts.h"
 
-struct mntopt mopts[] = {
+static struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_UPDATE,
 	MOPT_END
@@ -83,7 +84,7 @@
 {
 	struct iovec *iov;
 	int iovlen;
-	int ch, mntflags, opts;
+	int ch, mntflags;
 	char *dev, *dir, *p, *val, mntpath[MAXPATHLEN];
 	int verbose;
 	int ssector;		/* starting sector, 0 for 1st session */
@@ -91,7 +92,7 @@
 
 	iov = NULL;
 	iovlen = 0;
-	mntflags = opts = verbose = 0;
+	mntflags = verbose = 0;
 	ssector = -1;
 
 	while ((ch = getopt(argc, argv, "begjo:rs:vC:")) != -1)
@@ -109,7 +110,7 @@
 			build_iovec(&iov, &iovlen, "nojoliet", NULL, (size_t)-1);
 			break;
 		case 'o':
-			getmntopts(optarg, mopts, &mntflags, &opts);
+			getmntopts(optarg, mopts, &mntflags, NULL);
 			p = strchr(optarg, '=');
 			val = NULL;
 			if (p != NULL) {
@@ -149,7 +150,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(1, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	if (ssector == -1) {

Modified: trunk/sbin/mount_msdosfs/Makefile
===================================================================
--- trunk/sbin/mount_msdosfs/Makefile	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_msdosfs/Makefile	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,6 +1,7 @@
-#
 # $MidnightBSD$
 #
+# $FreeBSD: stable/10/sbin/mount_msdosfs/Makefile 198236 2009-10-19 16:00:24Z ru $
+#
 
 PROG=	mount_msdosfs
 SRCS=	mount_msdosfs.c getmntopts.c

Modified: trunk/sbin/mount_msdosfs/mount_msdosfs.8
===================================================================
--- trunk/sbin/mount_msdosfs/mount_msdosfs.8	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_msdosfs/mount_msdosfs.8	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"	$NetBSD: mount_msdos.8,v 1.13 1998/02/06 05:57:00 perry Exp $
 .\"
 .\" Copyright (c) 1993,1994 Christopher G. Demetriou
@@ -28,9 +29,9 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 331516 2018-03-25 01:31:16Z sevan $
 .\"
-.Dd December 23, 2008
+.Dd April 3, 2017
 .Dt MOUNT_MSDOSFS 8
 .Os
 .Sh NAME
@@ -142,15 +143,8 @@
 nor
 .Fl l
 are given,
-.Nm
-searches the root directory of the file system to
-be mounted for any existing Win'95 long filenames.
-If no such entries are found, but short DOS filenames are found,
-.Fl s
+.Fl l
 is the default.
-Otherwise
-.Fl l
-is assumed.
 .It Fl 9
 Ignore the special Win'95 directory entries even
 if deleting or renaming a file.
@@ -182,14 +176,14 @@
 .El
 .Sh EXAMPLES
 To mount a Russian MS-DOS file system located in
-.Pa /dev/ad1s1 :
+.Pa /dev/ada1s1 :
 .Pp
-.Dl "mount_msdosfs -L ru_RU.KOI8-R -D CP866 /dev/ad1s1 /mnt"
+.Dl "mount_msdosfs -L ru_RU.KOI8-R -D CP866 /dev/ada1s1 /mnt"
 .Pp
 To mount a Japanese MS-DOS file system located in
-.Pa /dev/ad1s1 :
+.Pa /dev/ada1s1 :
 .Pp
-.Dl "mount_msdosfs -L ja_JP.eucJP -D CP932 /dev/ad1s1 /mnt"
+.Dl "mount_msdosfs -L ja_JP.eucJP -D CP932 /dev/ada1s1 /mnt"
 .Sh SEE ALSO
 .Xr mount 2 ,
 .Xr unmount 2 ,
@@ -200,21 +194,32 @@
 List of Localized MS Operating Systems:
 .Pa http://www.microsoft.com/globaldev/reference/oslocversion.mspx .
 .Sh HISTORY
-The
+The predecessor to
+.Nm mount_msdos
+utility named
+.Nm mount_pcfs
+appeared in
+.Nx 0.8 .
+It was rewritten in
+.Nx 1.0
+and first appeared in
+.Fx 2.0 .
+.Nm mount_msdos
+was renamed to the more aptly-named
 .Nm
-utility first appeared in
-.Fx 2.0 .
-Its predecessor, the
+in
+.Fx 5.0.
+The character code conversion routine was added in 2003.
+.Sh AUTHORS
+Initial implementation as
 .Nm mount_pcfs
-utility appeared in
-.Fx 1.0 ,
-and was abandoned in favor
-of the more aptly-named
-.Nm .
-.Pp
+was written by
+.An -nosplit
+.An Paul Popelka Aq Mt paulp at uts.amdahl.com .
+It was rewritten by
+.An Christopher G. Demetriou Aq Mt cgd at NetBSD.org .
 The character code conversion routine was added by
-.An Ryuichiro Imura Aq imura at ryu16.org
-at 2003.
+.An Ryuichiro Imura Aq Mt imura at ryu16.org .
 .Sh CAVEATS
 The use of the
 .Fl 9


Property changes on: trunk/sbin/mount_msdosfs/mount_msdosfs.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/mount_msdosfs/mount_msdosfs.c
===================================================================
--- trunk/sbin/mount_msdosfs/mount_msdosfs.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_msdosfs/mount_msdosfs.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: mount_msdos.c,v 1.18 1997/09/16 12:24:18 lukem Exp $	*/
 
 /*
@@ -32,7 +33,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-  "$MidnightBSD$";
+  "$FreeBSD: stable/10/sbin/mount_msdosfs/mount_msdosfs.c 247856 2013-03-05 22:41:35Z jkim $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -69,7 +70,7 @@
 	struct iovec *iov = NULL;
 	int iovlen = 0;
 	struct stat sb;
-	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
+	int c, set_gid, set_uid, set_mask, set_dirmask;
 	char *dev, *dir, mntpath[MAXPATHLEN], *csp;
 	char fstype[] = "msdosfs";
 	char errmsg[255] = {0};
@@ -78,9 +79,8 @@
 	mode_t mask = 0, dirmask = 0;
 	uid_t uid = 0;
 	gid_t gid = 0;
-	getmnt_silent = 1;
 
-	mntflags = set_gid = set_uid = set_mask = set_dirmask = 0;
+	set_gid = set_uid = set_mask = set_dirmask = 0;
 
 	while ((c = getopt(argc, argv, "sl9u:g:m:M:o:L:D:W:")) != -1) {
 		switch (c) {
@@ -193,7 +193,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	if (!set_gid || !set_uid || !set_mask) {
@@ -218,7 +219,7 @@
 	build_iovec_argf(&iov, &iovlen, "mask", "%u", mask);
 	build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask);
 
-	if (nmount(iov, iovlen, mntflags) < 0) {
+	if (nmount(iov, iovlen, 0) < 0) {
 		if (errmsg[0])
 			err(1, "%s: %s", dev, errmsg);
 		else

Modified: trunk/sbin/mount_nfs/Makefile
===================================================================
--- trunk/sbin/mount_nfs/Makefile	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_nfs/Makefile	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,6 +1,7 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/mount_nfs/Makefile 275257 2014-11-29 15:57:31Z trasz $
 
 PROG=	mount_nfs
 SRCS=	mount_nfs.c getmntopts.c mounttab.c
@@ -10,7 +11,6 @@
 MOUNT=	${.CURDIR}/../mount
 UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
 CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL}
-WARNS?=	3
 
 LINKS=	${BINDIR}/mount_nfs ${BINDIR}/mount_oldnfs
 

Modified: trunk/sbin/mount_nfs/mount_nfs.8
===================================================================
--- trunk/sbin/mount_nfs/mount_nfs.8	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_nfs/mount_nfs.8	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1992, 1993, 1994, 1995
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -26,9 +27,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)mount_nfs.8	8.3 (Berkeley) 3/29/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/mount_nfs/mount_nfs.8 317526 2017-04-27 21:45:50Z rmacklem $
 .\"
-.Dd May 3, 2011
+.Dd April 13, 2017
 .Dt MOUNT_NFS 8
 .Os
 .Sh NAME
@@ -118,6 +119,15 @@
 The algorithm to calculate the timeout is based on the age of the file.
 The older the file,
 the longer the cache is considered valid, subject to the limits above.
+.It Cm actimeo Ns = Ns Aq Ar seconds
+Set four cache timeouts above to specified value.
+.It Cm allgssname
+This option can be used along with
+.Fl o Cm gssname
+to specify that all operations should use the host-based initiator
+credential.
+This may be used for clients that run system daemons that need to
+access files on the NFSv4 mounted volume.
 .It Cm bg
 If an initial attempt to contact the server fails, fork off a child to keep
 trying the mount in the background.
@@ -138,6 +148,23 @@
 .It Cm fg
 Same as not specifying
 .Cm bg .
+.It Cm gssname Ns = Ns Aq Ar service-principal-name
+This option can be used with the KerberosV security flavors for NFSv4 mounts
+to specify the
+.Dq "service-principal-name"
+of a host-based entry in the default
+keytab file that is used for system operations.
+It allows the mount to be performed by
+.Dq "root"
+and avoids problems with
+cached credentials for the system operations expiring.
+The
+.Dq "service-prinicpal-name"
+should be specified without instance or domain and is typically
+.Dq "host" ,
+.Dq "nfs"
+or
+.Dq "root" .
 .It Cm hard
 Same as not specifying
 .Cm soft .
@@ -175,6 +202,28 @@
 Use the NFS Version 4 protocol.
 This option will force the mount to use
 TCP transport.
+.It Cm minorversion Ns = Ns Aq Ar value
+Override the default of 0 for the minor version of the NFS Version 4 protocol.
+The only minor version currently supported is 1.
+This option is only meaningful when used with the
+.Cm nfsv4
+option.
+.It Cm oneopenown
+Make a minor version 1 of the NFS Version 4 protocol mount use a single OpenOwner
+for all Opens.
+This may be useful for a server with a very low limit on OpenOwners, such as
+AmazonEFS.
+It can only be used with an NFSv4.1 mount.
+It may not work correctly when Delegations are being issued by a server,
+but note that the AmazonEFS server does not issued delegations at this time.
+.It Cm pnfs
+Enable support for parallel NFS (pNFS) for minor version 1 of the
+NFS Version 4 protocol.
+This option is only meaningful when used with the
+.Cm minorversion
+option.
+.It Cm noac
+Disable attribute caching.
 .It Cm noconn
 For UDP mount points, do not do a
 .Xr connect 2 .
@@ -221,6 +270,19 @@
 Note that this option will only be honored when performing the
 initial mount, it will be silently ignored if used while updating
 the mount options.
+.It Cm noncontigwr
+This mount option allows the NFS client to
+combine non-contiguous byte ranges being written
+such that the dirty byte range becomes a superset of the bytes
+that are dirty.
+This reduces the number of writes significantly for software
+builds.
+The merging of byte ranges isn't done if the file has been file
+locked, since most applications modifying a file from multiple
+clients will use file locking.
+As such, this option could result in a corrupted file for the
+rare case of an application modifying the file from multiple
+clients concurrently without using file locking.
 .It Cm principal
 For the RPCSEC_GSS security flavors, such as krb5, krb5i and krb5p,
 this option sets the name of the host based principal name expected
@@ -233,6 +295,15 @@
 .It Cm port Ns = Ns Aq Ar port_number
 Use specified port number for NFS requests.
 The default is to query the portmapper for the NFS port.
+.It Cm proto Ns = Ns Aq Ar protocol
+Specify transport protocol version to use.
+Currently, they are:
+.Bd -literal
+udp -   Use UDP over IPv4
+tcp -   Use TCP over IPv4
+udp6 -  Use UDP over IPv6
+tcp6 -  Use TCP over IPv6
+.Ed
 .It Cm rdirplus
 Used with NFSV3 to specify that the \fBReaddirPlus\fR RPC should
 be used.
@@ -308,7 +379,8 @@
 Some old NFS servers do not support this method; UDP mounts may be required
 for interoperability.
 .It Cm timeout Ns = Ns Aq Ar value
-Set the initial retransmit timeout to the specified value.
+Set the initial retransmit timeout to the specified value,
+expressed in tenths of a second.
 May be useful for fine tuning UDP mounts over internetworks
 with high packet loss rates or an overloaded server.
 Try increasing the interval if
@@ -320,8 +392,19 @@
 option should be specified when using this option to manually
 tune the timeout
 interval.)
+.It Cm timeo Ns = Ns Aq Ar value
+Alias for
+.Cm timeout .
 .It Cm udp
 Use UDP transport.
+.It Cm vers Ns = Ns Aq Ar vers_number
+Use the specified version number for NFS requests.
+See the
+.Cm nfsv2 ,
+.Cm nfsv3 ,
+and 
+.Cm nfsv4
+options for details.
 .It Cm wcommitsize Ns = Ns Aq Ar value
 Set the maximum pending write commit size to the specified value.
 This determines the maximum amount of pending write data that the NFS
@@ -417,6 +500,26 @@
 Same as
 .Fl o Cm retrans Ns = Ns Aq Ar value
 .El
+.Pp
+The following
+.Fl o
+named options are equivalent to other
+.Fl o
+named options and are supported for compatibility with other
+operating systems (e.g., Linux, Solaris, and OSX) to ease usage of
+.Xr autofs 5
+support.
+.Bl -tag -width indent
+.It Fl o Cm vers Ns = Ns 2
+Same as
+.Fl o Cm nfsv2
+.It Fl o Cm vers Ns = Ns 3
+Same as
+.Fl o Cm nfsv3
+.It Fl o Cm vers Ns = Ns 4
+Same as
+.Fl o Cm nfsv4
+.El
 .Sh SEE ALSO
 .Xr nmount 2 ,
 .Xr unmount 2 ,


Property changes on: trunk/sbin/mount_nfs/mount_nfs.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/mount_nfs/mount_nfs.c
===================================================================
--- trunk/sbin/mount_nfs/mount_nfs.c	2018-06-19 18:42:20 UTC (rev 11110)
+++ trunk/sbin/mount_nfs/mount_nfs.c	2018-06-19 18:58:21 UTC (rev 11111)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -42,7 +43,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/mount_nfs/mount_nfs.c 318683 2017-05-22 21:52:06Z rmacklem $");
 
 #include <sys/param.h>
 #include <sys/linker.h>
@@ -79,7 +80,7 @@
 #include "mounttab.h"
 
 /* Table for af,sotype -> netid conversions. */
-struct nc_protos {
+static struct nc_protos {
 	const char *netid;
 	int af;
 	int sotype;
@@ -102,20 +103,21 @@
 #define	ISBGRND	2
 #define	OF_NOINET4	4
 #define	OF_NOINET6	8
-int retrycnt = -1;
-int opflags = 0;
-int nfsproto = IPPROTO_TCP;
-int mnttcp_ok = 1;
-int noconn = 0;
-char *portspec = NULL;	/* Server nfs port; NULL means look up via rpcbind. */
-struct sockaddr *addr;
-int addrlen = 0;
-u_char *fh = NULL;
-int fhsize = 0;
-int secflavor = -1;
-int got_principal = 0;
+static int retrycnt = -1;
+static int opflags = 0;
+static int nfsproto = IPPROTO_TCP;
+static int mnttcp_ok = 1;
+static int noconn = 0;
+/* The 'portspec' is the server nfs port; NULL means look up via rpcbind. */
+static const char *portspec = NULL;
+static struct sockaddr *addr;
+static int addrlen = 0;
+static u_char *fh = NULL;
+static int fhsize = 0;
+static int secflavor = -1;
+static int got_principal = 0;
 
-enum mountmode {
+static enum mountmode {
 	ANY,
 	V2,
 	V3,
@@ -130,9 +132,8 @@
 	TRYRET_LOCALERR		/* Local failure. */
 };
 
-static int	fallback_mount(struct iovec *iov, int iovlen, int mntflags);
-static int	sec_name_to_num(char *sec);
-static char	*sec_num_to_name(int num);
+static int	sec_name_to_num(const char *sec);
+static const char	*sec_num_to_name(int num);
 static int	getnfsargs(char *, struct iovec **iov, int *iovlen);
 /* void	set_rpc_maxgrouplist(int); */
 static struct netconfig *getnetconf_cached(const char *netid);
@@ -149,13 +150,12 @@
 {
 	int c;
 	struct iovec *iov;
-	int mntflags, num, iovlen;
-	int osversion;
-	char *name, *p, *spec, *fstype;
+	int num, iovlen;
+	char *mntname, *p, *spec, *tmp;
 	char mntpath[MAXPATHLEN], errmsg[255];
-	char hostname[MAXHOSTNAMELEN + 1], *gssname, gssn[MAXHOSTNAMELEN + 50];
+	char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50];
+	const char *fstype, *gssname;
 
-	mntflags = 0;
 	iov = NULL;
 	iovlen = 0;
 	memset(errmsg, 0, sizeof(errmsg));
@@ -229,7 +229,7 @@
 			while (opt) {
 				char *pval = NULL;
 				char *pnextopt = NULL;
-				char *val = "";
+				const char *val = "";
 				pass_flag_to_nmount = 1;
 				pnextopt = strchr(opt, ',');
 				if (pnextopt != NULL) {
@@ -279,12 +279,41 @@
 						portspec = "2049";
 				} else if (strcmp(opt, "port") == 0) {
 					pass_flag_to_nmount=0;
-					asprintf(&portspec, "%d",
-					    atoi(val));
-					if (portspec == NULL)
+					asprintf(&tmp, "%d", atoi(val));
+					if (tmp == NULL)
 						err(1, "asprintf");
+					portspec = tmp;
 				} else if (strcmp(opt, "principal") == 0) {
 					got_principal = 1;
+				} else if (strcmp(opt, "proto") == 0) {
+					pass_flag_to_nmount=0;
+					if (strcmp(val, "tcp") == 0) {
+						nfsproto = IPPROTO_TCP;
+						opflags |= OF_NOINET6;
+						build_iovec(&iov, &iovlen,
+						    "tcp", NULL, 0);
+					} else if (strcmp(val, "udp") == 0) {
+						mnttcp_ok = 0;
+						nfsproto = IPPROTO_UDP;
+						opflags |= OF_NOINET6;
+						build_iovec(&iov, &iovlen,
+						    "udp", NULL, 0);
+					} else if (strcmp(val, "tcp6") == 0) {
+						nfsproto = IPPROTO_TCP;
+						opflags |= OF_NOINET4;
+						build_iovec(&iov, &iovlen,
+						    "tcp", NULL, 0);
+					} else if (strcmp(val, "udp6") == 0) {
+						mnttcp_ok = 0;
+						nfsproto = IPPROTO_UDP;
+						opflags |= OF_NOINET4;
+						build_iovec(&iov, &iovlen,
+						    "udp", NULL, 0);
+					} else {
+						errx(1,
+						    "illegal proto value -- %s",
+						    val);
+					}
 				} else if (strcmp(opt, "sec") == 0) {
 					/*
 					 * Don't add this option to
@@ -311,10 +340,38 @@
 					if (*p || num <= 0)
 						errx(1, "illegal maxgroups value -- %s", val);
 					//set_rpc_maxgrouplist(num);
+				} else if (strcmp(opt, "vers") == 0) {
+					num = strtol(val, &p, 10);
+					if (*p || num <= 0)
+						errx(1, "illegal vers value -- "
+						    "%s", val);
+					switch (num) {
+					case 2:
+						mountmode = V2;
+						break;
+					case 3:
+						mountmode = V3;
+						build_iovec(&iov, &iovlen,
+						    "nfsv3", NULL, 0);
+						break;
+					case 4:
+						mountmode = V4;
+						fstype = "nfs";
+						nfsproto = IPPROTO_TCP;
+						if (portspec == NULL)
+							portspec = "2049";
+						break;
+					default:
+						errx(1, "illegal nfs version "
+						    "value -- %s", val);
+					}
+					pass_flag_to_nmount=0;
 				}
-				if (pass_flag_to_nmount)
-					build_iovec(&iov, &iovlen, opt, val,
+				if (pass_flag_to_nmount) {
+					build_iovec(&iov, &iovlen, opt,
+					    __DECONST(void *, val),
 					    strlen(val) + 1);
+				}
 				opt = pnextopt;
 			}
 			}
@@ -374,7 +431,7 @@
 	}
 
 	spec = *argv++;
-	name = *argv;
+	mntname = *argv;
 
 	if (retrycnt == -1)
 		/* The default is to keep retrying forever. */
@@ -403,8 +460,8 @@
 			    hostname);
 			gssname = gssn;
 		}
-		build_iovec(&iov, &iovlen, "gssname", gssname,
-		    strlen(gssname) + 1);
+		build_iovec(&iov, &iovlen, "gssname",
+		    __DECONST(void *, gssname), strlen(gssname) + 1);
 	}
 
 	if (!getnfsargs(spec, &iov, &iovlen))
@@ -411,263 +468,23 @@
 		exit(1);
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(name, mntpath);
+	if (checkpath(mntname, mntpath) != 0)
+		err(1, "%s", mntpath);
 
-	build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
+	build_iovec(&iov, &iovlen, "fstype", 
+	    __DECONST(void *, fstype), (size_t)-1);
 	build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
 	build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
 
-	/*
-	 * XXX:
-	 * Backwards compatibility routines for older kernels.
-	 * Remove this and fallback_mount() code when we do not need to support
-	 * NFS mounts against older kernels which still need
-	 * struct nfs_args to be passed in via nmount().
-	 */
-	osversion = getosreldate();
-	if (osversion >= 702100) {
-		if (nmount(iov, iovlen, mntflags))
-			err(1, "%s, %s", mntpath, errmsg);
-	} else {
-		if (fallback_mount(iov, iovlen, mntflags))
-			err(1, "%s, %s", mntpath, errmsg);
-	}
+	if (nmount(iov, iovlen, 0))
+		err(1, "%s, %s", mntpath, errmsg);
 
 	exit(0);
 }
 
 static int
-findopt(struct iovec *iov, int iovlen, const char *name,
-    char **valuep, int *lenp)
+sec_name_to_num(const char *sec)
 {
-	int i;
-
-	for (i = 0; i < iovlen/2; i++, iov += 2) {
-		if (strcmp(name, iov[0].iov_base) == 0) {
-			if (valuep)
-				*valuep = iov[1].iov_base;
-			if (lenp)
-				*lenp = iov[1].iov_len;
-			return (0);
-		}
-	}
-	return (ENOENT);
-}
-
-static void
-copyopt(struct iovec **newiov, int *newiovlen,
-    struct iovec *iov, int iovlen, const char *name)
-{
-	char *value;
-	int len;
-
-	if (findopt(iov, iovlen, name, &value, &len) == 0)
-		build_iovec(newiov, newiovlen, name, value, len);
-}
-
-/*
- * XXX: This function is provided for backwards
- *      compatibility with older kernels which did not support
- *      passing NFS mount options to nmount() as individual
- *      parameters.  It should be eventually be removed.
- */
-static int
-fallback_mount(struct iovec *iov, int iovlen, int mntflags)
-{
-	struct nfs_args args = {
-	    .version = NFS_ARGSVERSION,
-	    .addr = NULL,
-	    .addrlen = sizeof (struct sockaddr_in),
-	    .sotype = SOCK_STREAM,
-	    .proto = 0,
-	    .fh = NULL,
-	    .fhsize = 0,
-	    .flags = NFSMNT_RESVPORT,
-	    .wsize = NFS_WSIZE,
-	    .rsize = NFS_RSIZE,
-	    .readdirsize = NFS_READDIRSIZE,
-	    .timeo = 10,
-	    .retrans = NFS_RETRANS,
-	    .maxgrouplist = NFS_MAXGRPS,
-	    .readahead = NFS_DEFRAHEAD,
-	    .wcommitsize = 0,			/* was: NQ_DEFLEASE */
-	    .deadthresh = NFS_MAXDEADTHRESH,	/* was: NQ_DEADTHRESH */
-	    .hostname = NULL,
-	    /* args version 4 */
-	    .acregmin = NFS_MINATTRTIMO,
-	    .acregmax = NFS_MAXATTRTIMO,
-	    .acdirmin = NFS_MINDIRATTRTIMO,
-	    .acdirmax = NFS_MAXDIRATTRTIMO,
-	};
-	int ret;
-	char *opt;
-	struct iovec *newiov;
-	int newiovlen;
-
-	if (findopt(iov, iovlen, "dumbtimer", NULL, NULL) == 0)
-		args.flags |= NFSMNT_DUMBTIMR;
-	if (findopt(iov, iovlen, "noconn", NULL, NULL) == 0)
-		args.flags |= NFSMNT_NOCONN;
-	if (findopt(iov, iovlen, "conn", NULL, NULL) == 0)
-		args.flags |= NFSMNT_NOCONN;
-	if (findopt(iov, iovlen, "nolockd", NULL, NULL) == 0)
-		args.flags |= NFSMNT_NOLOCKD;
-	if (findopt(iov, iovlen, "lockd", NULL, NULL) == 0)
-		args.flags &= ~NFSMNT_NOLOCKD;
-	if (findopt(iov, iovlen, "intr", NULL, NULL) == 0)
-		args.flags |= NFSMNT_INT;
-	if (findopt(iov, iovlen, "rdirplus", NULL, NULL) == 0)
-		args.flags |= NFSMNT_RDIRPLUS;
-	if (findopt(iov, iovlen, "resvport", NULL, NULL) == 0)
-		args.flags |= NFSMNT_RESVPORT;
-	if (findopt(iov, iovlen, "noresvport", NULL, NULL) == 0)
-		args.flags &= ~NFSMNT_RESVPORT;
-	if (findopt(iov, iovlen, "soft", NULL, NULL) == 0)
-		args.flags |= NFSMNT_SOFT;
-	if (findopt(iov, iovlen, "hard", NULL, NULL) == 0)
-		args.flags &= ~NFSMNT_SOFT;
-	if (findopt(iov, iovlen, "mntudp", NULL, NULL) == 0)
-		args.sotype = SOCK_DGRAM;
-	if (findopt(iov, iovlen, "udp", NULL, NULL) == 0)
-		args.sotype = SOCK_DGRAM;
-	if (findopt(iov, iovlen, "tcp", NULL, NULL) == 0)
-		args.sotype = SOCK_STREAM;
-	if (findopt(iov, iovlen, "nfsv3", NULL, NULL) == 0)
-		args.flags |= NFSMNT_NFSV3;
-	if (findopt(iov, iovlen, "readdirsize", &opt, NULL) == 0) {
-		if (opt == NULL) { 
-			errx(1, "illegal readdirsize");
-		}
-		ret = sscanf(opt, "%d", &args.readdirsize);
-		if (ret != 1 || args.readdirsize <= 0) {
-			errx(1, "illegal readdirsize: %s", opt);
-		}
-		args.flags |= NFSMNT_READDIRSIZE;
-	}
-	if (findopt(iov, iovlen, "readahead", &opt, NULL) == 0) {
-		if (opt == NULL) { 
-			errx(1, "illegal readahead");
-		}
-		ret = sscanf(opt, "%d", &args.readahead);
-		if (ret != 1 || args.readahead <= 0) {
-			errx(1, "illegal readahead: %s", opt);
-		}
-		args.flags |= NFSMNT_READAHEAD;
-	}
-	if (findopt(iov, iovlen, "wsize", &opt, NULL) == 0) {
-		if (opt == NULL) { 
-			errx(1, "illegal wsize");
-		}
-		ret = sscanf(opt, "%d", &args.wsize);
-		if (ret != 1 || args.wsize <= 0) {
-			errx(1, "illegal wsize: %s", opt);
-		}
-		args.flags |= NFSMNT_WSIZE;
-	}
-	if (findopt(iov, iovlen, "rsize", &opt, NULL) == 0) {
-		if (opt == NULL) { 
-			errx(1, "illegal rsize");
-		}
-		ret = sscanf(opt, "%d", &args.rsize);
-		if (ret != 1 || args.rsize <= 0) {
-			errx(1, "illegal wsize: %s", opt);
-		}
-		args.flags |= NFSMNT_RSIZE;
-	}
-	if (findopt(iov, iovlen, "retrans", &opt, NULL) == 0) {
-		if (opt == NULL) { 
-			errx(1, "illegal retrans");
-		}
-		ret = sscanf(opt, "%d", &args.retrans);
-		if (ret != 1 || args.retrans <= 0) {
-			errx(1, "illegal retrans: %s", opt);
-		}
-		args.flags |= NFSMNT_RETRANS;
-	}
-	if (findopt(iov, iovlen, "acregmin", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.acregmin);
-		if (ret != 1 || args.acregmin < 0) {
-			errx(1, "illegal acregmin: %s", opt);
-		}
-		args.flags |= NFSMNT_ACREGMIN;
-	}
-	if (findopt(iov, iovlen, "acregmax", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.acregmax);
-		if (ret != 1 || args.acregmax < 0) {
-			errx(1, "illegal acregmax: %s", opt);
-		}
-		args.flags |= NFSMNT_ACREGMAX;
-	}
-	if (findopt(iov, iovlen, "acdirmin", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.acdirmin);
-		if (ret != 1 || args.acdirmin < 0) {
-			errx(1, "illegal acdirmin: %s", opt);
-		}
-		args.flags |= NFSMNT_ACDIRMIN;
-	}
-	if (findopt(iov, iovlen, "acdirmax", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.acdirmax);
-		if (ret != 1 || args.acdirmax < 0) {
-			errx(1, "illegal acdirmax: %s", opt);
-		}
-		args.flags |= NFSMNT_ACDIRMAX;
-	}
-	if (findopt(iov, iovlen, "wcommitsize", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.wcommitsize);
-		if (ret != 1 || args.wcommitsize < 0) {
-			errx(1, "illegal wcommitsize: %s", opt);
-		}
-		args.flags |= NFSMNT_WCOMMITSIZE;
-	}
-	if (findopt(iov, iovlen, "deadthresh", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.deadthresh);
-		if (ret != 1 || args.deadthresh <= 0) {
-			errx(1, "illegal deadthresh: %s", opt);
-		}
-		args.flags |= NFSMNT_DEADTHRESH;
-	}
-	if (findopt(iov, iovlen, "timeout", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.timeo);
-		if (ret != 1 || args.timeo <= 0) {
-			errx(1, "illegal timeout: %s", opt);
-		}
-		args.flags |= NFSMNT_TIMEO;
-	}
-	if (findopt(iov, iovlen, "maxgroups", &opt, NULL) == 0) {
-		ret = sscanf(opt, "%d", &args.maxgrouplist);
-		if (ret != 1 || args.timeo <= 0) {
-			errx(1, "illegal maxgroups: %s", opt);
-		}
-		args.flags |= NFSMNT_MAXGRPS;
-	}
-	if (findopt(iov, iovlen, "addr", &opt,
-		&args.addrlen) == 0) {
-		args.addr = (struct sockaddr *) opt;
-	}
-	if (findopt(iov, iovlen, "fh", &opt, &args.fhsize) == 0) {
-		args.fh = opt;
-	}
-	if (findopt(iov, iovlen, "hostname", &args.hostname,
-		NULL) == 0) {
-	}
-	if (args.hostname == NULL) {
-		errx(1, "Invalid hostname");
-	}
-
-	newiov = NULL;
-	newiovlen = 0;
-
-	build_iovec(&newiov, &newiovlen, "nfs_args", &args, sizeof(args));
-	copyopt(&newiov, &newiovlen, iov, iovlen, "fstype");
-	copyopt(&newiov, &newiovlen, iov, iovlen, "fspath");
-	copyopt(&newiov, &newiovlen, iov, iovlen, "errmsg");
-
-	return nmount(newiov, newiovlen, mntflags);
-}
-
-static int
-sec_name_to_num(char *sec)
-{
 	if (!strcmp(sec, "krb5"))
 		return (RPCSEC_GSS_KRB5);
 	if (!strcmp(sec, "krb5i"))
@@ -679,7 +496,7 @@
 	return (-1);
 }
 
-static char *
+static const char *
 sec_num_to_name(int flavor)
 {
 	switch (flavor) {
@@ -775,8 +592,8 @@
 		 * For a Kerberized nfs mount where the "principal"
 		 * argument has not been set, add it here.
 		 */
-		if (got_principal == 0 && secflavor >= 0 &&
-		    secflavor != AUTH_SYS && ai_nfs->ai_canonname != NULL) {
+		if (got_principal == 0 && secflavor != AUTH_SYS &&
+		    ai_nfs->ai_canonname != NULL) {
 			snprintf(pname, sizeof (pname), "nfs@%s",
 			    ai_nfs->ai_canonname);
 			build_iovec(iov, iovlen, "principal", pname,
@@ -788,7 +605,7 @@
 	for (;;) {
 		/*
 		 * Try each entry returned by getaddrinfo(). Note the
-		 * occurence of remote errors by setting `remoteerr'.
+		 * occurrence of remote errors by setting `remoteerr'.
 		 */
 		remoteerr = 0;
 		for (ai = ai_nfs; ai != NULL; ai = ai->ai_next) {
@@ -834,7 +651,7 @@
 
 	build_iovec(iov, iovlen, "hostname", nam, (size_t)-1);
 	/* Add mounted file system to PATH_MOUNTTAB */
-	if (!add_mtab(hostp, spec))
+	if (mountmode != V4 && !add_mtab(hostp, spec))
 		warnx("can't update %s for %s:%s", PATH_MOUNTTAB, hostp, spec);
 	return (1);
 }
@@ -863,10 +680,9 @@
 	struct rpc_err rpcerr;
 	CLIENT *clp;
 	struct netconfig *nconf, *nconf_mnt;
-	const char *netid, *netid_mnt;
-	char *secname;
+	const char *netid, *netid_mnt, *secname;
 	int doconnect, nfsvers, mntvers, sotype;
-	enum clnt_stat stat;
+	enum clnt_stat clntstat;
 	enum mountmode trymntmode;
 
 	sotype = 0;
@@ -910,6 +726,7 @@
 tryagain:
 	if (trymntmode == V4) {
 		nfsvers = 4;
+		mntvers = 3; /* Workaround for GCC. */
 	} else if (trymntmode == V2) {
 		nfsvers = 2;
 		mntvers = 1;
@@ -969,10 +786,10 @@
 
 	try.tv_sec = 10;
 	try.tv_usec = 0;
-	stat = clnt_call(clp, NFSPROC_NULL, (xdrproc_t)xdr_void, NULL,
+	clntstat = clnt_call(clp, NFSPROC_NULL, (xdrproc_t)xdr_void, NULL,
 			 (xdrproc_t)xdr_void, NULL, try);
-	if (stat != RPC_SUCCESS) {
-		if (stat == RPC_PROGVERSMISMATCH && trymntmode == ANY) {
+	if (clntstat != RPC_SUCCESS) {
+		if (clntstat == RPC_PROGVERSMISMATCH && trymntmode == ANY) {
 			clnt_destroy(clp);
 			trymntmode = V2;
 			goto tryagain;
@@ -981,7 +798,7 @@
 		snprintf(errbuf, sizeof errbuf, "[%s] %s:%s: %s", netid,
 		    hostp, spec, clnt_sperror(clp, "NFSPROC_NULL"));
 		clnt_destroy(clp);
-		return (returncode(stat, &rpcerr));
+		return (returncode(clntstat, &rpcerr));
 	}
 	clnt_destroy(clp);
 
@@ -1001,8 +818,10 @@
 
 		build_iovec(iov, iovlen, "addr", addr, addrlen);
 		secname = sec_num_to_name(secflavor);
-		if (secname != NULL)
-			build_iovec(iov, iovlen, "sec", secname, (size_t)-1);
+		if (secname != NULL) {
+			build_iovec(iov, iovlen, "sec",
+			    __DECONST(void *, secname), (size_t)-1);
+		}
 		build_iovec(iov, iovlen, "nfsv4", NULL, 0);
 		build_iovec(iov, iovlen, "dirpath", spec, (size_t)-1);
 
@@ -1022,12 +841,12 @@
 	clp->cl_auth = authsys_create_default();
 	nfhret.auth = secflavor;
 	nfhret.vers = mntvers;
-	stat = clnt_call(clp, MOUNTPROC_MNT, (xdrproc_t)xdr_dir, spec, 
+	clntstat = clnt_call(clp, MOUNTPROC_MNT, (xdrproc_t)xdr_dir, spec, 
 			 (xdrproc_t)xdr_fh, &nfhret,
 	    try);
 	auth_destroy(clp->cl_auth);
-	if (stat != RPC_SUCCESS) {
-		if (stat == RPC_PROGVERSMISMATCH && trymntmode == ANY) {
+	if (clntstat != RPC_SUCCESS) {
+		if (clntstat == RPC_PROGVERSMISMATCH && trymntmode == ANY) {
 			clnt_destroy(clp);
 			trymntmode = V2;
 			goto tryagain;
@@ -1036,7 +855,7 @@
 		snprintf(errbuf, sizeof errbuf, "[%s] %s:%s: %s", netid_mnt,
 		    hostp, spec, clnt_sperror(clp, "RPCPROG_MNT"));
 		clnt_destroy(clp);
-		return (returncode(stat, &rpcerr));
+		return (returncode(clntstat, &rpcerr));
 	}
 	clnt_destroy(clp);
 
@@ -1062,8 +881,10 @@
 	build_iovec(iov, iovlen, "addr", addr, addrlen);
 	build_iovec(iov, iovlen, "fh", fh, fhsize);
 	secname = sec_num_to_name(nfhret.auth);
-	if (secname)
-		build_iovec(iov, iovlen, "sec", secname, (size_t)-1);
+	if (secname) {
+		build_iovec(iov, iovlen, "sec",
+		    __DECONST(void *, secname), (size_t)-1);
+	}
 	if (nfsvers == 3)
 		build_iovec(iov, iovlen, "nfsv3", NULL, 0);
 
@@ -1075,9 +896,10 @@
  * return code.
  */
 static enum tryret
-returncode(enum clnt_stat stat, struct rpc_err *rpcerr)
+returncode(enum clnt_stat clntstat, struct rpc_err *rpcerr)
 {
-	switch (stat) {
+
+	switch (clntstat) {
 	case RPC_TIMEDOUT:
 		return (TRYRET_TIMEOUT);
 	case RPC_PMAPFAILURE:



More information about the Midnightbsd-cvs mailing list