Module Name: src Committed By: martin Date: Fri Sep 27 09:18:38 UTC 2019
Modified Files: src/distrib/sets/lists/base [netbsd-9]: mi src/distrib/sets/lists/etc [netbsd-9]: mi src/distrib/sets/lists/man [netbsd-9]: mi src/etc/defaults [netbsd-9]: rc.conf src/etc/rc.d [netbsd-9]: Makefile mountall src/external/cddl/osnet/dist/cmd/zfs [netbsd-9]: zfs_main.c src/external/cddl/osnet/sbin/zfs [netbsd-9]: Makefile Added Files: src/etc/rc.d [netbsd-9]: zfs src/external/cddl/osnet/sbin/zfs [netbsd-9]: mount_zfs.8 Log Message: Pull up following revision(s) (requested by brad in ticket #250): external/cddl/osnet/sbin/zfs/mount_zfs.8: revision 1.2 external/cddl/osnet/sbin/zfs/mount_zfs.8: revision 1.3 external/cddl/osnet/sbin/zfs/mount_zfs.8: revision 1.4 external/cddl/osnet/sbin/zfs/mount_zfs.8: revision 1.5 distrib/sets/lists/man/mi: revision 1.1652 distrib/sets/lists/man/mi: revision 1.1653 distrib/sets/lists/etc/mi: revision 1.259 etc/rc.d/mountall: revision 1.11 external/cddl/osnet/sbin/zfs/Makefile: revision 1.5 external/cddl/osnet/dist/cmd/zfs/zfs_main.c: revision 1.7 etc/rc.d/Makefile: revision 1.105 distrib/sets/lists/base/mi: revision 1.1217 etc/rc.d/Makefile: revision 1.106 etc/rc.d/zfs: revision 1.1 etc/defaults/rc.conf: revision 1.152 external/cddl/osnet/sbin/zfs/mount_zfs.8: revision 1.1 Add support for legacy ZFS filesystems, specified by mountpoint=legacy in the ZFS properties of the dataset and a simple man page for mount_zfs. With this, it is possible to put ZFS filesystems in /etc/fstab as file system type zfs. Add a rc.d script that kicks the module ZFS load mostly before mountall runs simular to what LVM does. This allows for any legacy mounts to be specified in critical_local_filesystems and allows for ZFS pools on top of cgd (probably among other things). Introduce a rc.conf variable called zfs which needs to be set to YES, in the usual manor of things, to get zvols and ZFS dataset support rather then just assume that 'zfs mount' does that in mountall. Fix a problem in mountall if ZFS is not compiled into the system. mount_zfs.8: add xref to fstab(5) Use more markup. Include mount_zfs man pages only for MKZFS builds. Moved zfs out of MKX11 block. Fix build failure without X11. Add a copyright to the man page and a bit of history. Use Pa macro for path new sentence, new line To generate a diff of this commit: cvs rdiff -u -r1.1209.2.3 -r1.1209.2.4 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.258 -r1.258.2.1 src/distrib/sets/lists/etc/mi cvs rdiff -u -r1.1649.2.1 -r1.1649.2.2 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.151 -r1.151.2.1 src/etc/defaults/rc.conf cvs rdiff -u -r1.104 -r1.104.2.1 src/etc/rc.d/Makefile cvs rdiff -u -r1.10 -r1.10.4.1 src/etc/rc.d/mountall cvs rdiff -u -r0 -r1.1.2.2 src/etc/rc.d/zfs cvs rdiff -u -r1.6 -r1.6.4.1 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c cvs rdiff -u -r1.4 -r1.4.4.1 src/external/cddl/osnet/sbin/zfs/Makefile cvs rdiff -u -r0 -r1.5.2.2 src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.1209.2.3 src/distrib/sets/lists/base/mi:1.1209.2.4 --- src/distrib/sets/lists/base/mi:1.1209.2.3 Thu Sep 26 19:04:00 2019 +++ src/distrib/sets/lists/base/mi Fri Sep 27 09:18:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1209.2.3 2019/09/26 19:04:00 martin Exp $ +# $NetBSD: mi,v 1.1209.2.4 2019/09/27 09:18:37 martin Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -567,6 +567,7 @@ ./sbin/mount_umap base-miscfs-root ./sbin/mount_union base-miscfs-root ./sbin/mount_v7fs base-sysutil-root +./sbin/mount_zfs base-zfs-root zfs ./sbin/mountd base-obsolete obsolete ./sbin/newbtconf base-sysutil-root ./sbin/newfs base-sysutil-root Index: src/distrib/sets/lists/etc/mi diff -u src/distrib/sets/lists/etc/mi:1.258 src/distrib/sets/lists/etc/mi:1.258.2.1 --- src/distrib/sets/lists/etc/mi:1.258 Sat May 11 19:31:03 2019 +++ src/distrib/sets/lists/etc/mi Fri Sep 27 09:18:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.258 2019/05/11 19:31:03 maxv Exp $ +# $NetBSD: mi,v 1.258.2.1 2019/09/27 09:18:37 martin Exp $ # # Note: end-user configuration files that are moved to another location # should not be marked "obsolete"; they should just be removed from @@ -323,6 +323,7 @@ ./etc/rc.d/yppasswdd etc-nis-rc yp ./etc/rc.d/ypserv etc-nis-rc yp ./etc/rc.d/ypset etc-obsolete obsolete +./etc/rc.d/zfs etc-sys-rc zfs ./etc/rc.lkm etc-obsolete obsolete ./etc/rc.local etc-sys-rc ./etc/rc.shutdown etc-sys-rc Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1649.2.1 src/distrib/sets/lists/man/mi:1.1649.2.2 --- src/distrib/sets/lists/man/mi:1.1649.2.1 Mon Sep 23 07:04:40 2019 +++ src/distrib/sets/lists/man/mi Fri Sep 27 09:18:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1649.2.1 2019/09/23 07:04:40 martin Exp $ +# $NetBSD: mi,v 1.1649.2.2 2019/09/27 09:18:37 martin Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2794,6 +2794,7 @@ ./usr/share/man/cat8/mount_umap.0 man-miscfs-catman .cat ./usr/share/man/cat8/mount_union.0 man-miscfs-catman .cat ./usr/share/man/cat8/mount_v7fs.0 man-sysutil-catman .cat +./usr/share/man/cat8/mount_zfs.0 man-sysutil-catman zfs,.cat ./usr/share/man/cat8/mountd.0 man-nfsserver-catman .cat ./usr/share/man/cat8/moused.0 man-sysutil-catman .cat ./usr/share/man/cat8/mrinfo.0 man-netutil-catman .cat @@ -5759,6 +5760,7 @@ ./usr/share/man/html8/mount_umap.html man-miscfs-htmlman html ./usr/share/man/html8/mount_union.html man-miscfs-htmlman html ./usr/share/man/html8/mount_v7fs.html man-sysutil-htmlman html +./usr/share/man/html8/mount_zfs.html man-sysutil-htmlman zfs,html ./usr/share/man/html8/mountd.html man-nfsserver-htmlman html ./usr/share/man/html8/moused.html man-sysutil-htmlman html ./usr/share/man/html8/mrinfo.html man-netutil-htmlman html @@ -8906,6 +8908,7 @@ ./usr/share/man/man8/mount_umap.8 man-miscfs-man .man ./usr/share/man/man8/mount_union.8 man-miscfs-man .man ./usr/share/man/man8/mount_v7fs.8 man-sysutil-man .man +./usr/share/man/man8/mount_zfs.8 man-sysutil-man zfs,.man ./usr/share/man/man8/mountd.8 man-nfsserver-man .man ./usr/share/man/man8/moused.8 man-sysutil-man .man ./usr/share/man/man8/mrinfo.8 man-netutil-man .man Index: src/etc/defaults/rc.conf diff -u src/etc/defaults/rc.conf:1.151 src/etc/defaults/rc.conf:1.151.2.1 --- src/etc/defaults/rc.conf:1.151 Wed Jul 24 02:37:17 2019 +++ src/etc/defaults/rc.conf Fri Sep 27 09:18:38 2019 @@ -1,4 +1,4 @@ -# $NetBSD: rc.conf,v 1.151 2019/07/24 02:37:17 msaitoh Exp $ +# $NetBSD: rc.conf,v 1.151.2.1 2019/09/27 09:18:38 martin Exp $ # # /etc/defaults/rc.conf -- # default configuration of /etc/rc.conf @@ -405,3 +405,6 @@ unbound_chrootdir=/var/chroot/unbound nsd=NO nsd_chrootdir=/var/chroot/nsd nsd_flags="-t ${nsd_chrootdir}" + +# ZFS +zfs=NO Index: src/etc/rc.d/Makefile diff -u src/etc/rc.d/Makefile:1.104 src/etc/rc.d/Makefile:1.104.2.1 --- src/etc/rc.d/Makefile:1.104 Sun May 12 01:50:14 2019 +++ src/etc/rc.d/Makefile Fri Sep 27 09:18:37 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.104 2019/05/12 01:50:14 kre Exp $ +# $NetBSD: Makefile,v 1.104.2.1 2019/09/27 09:18:37 martin Exp $ .include <bsd.own.mk> @@ -60,4 +60,8 @@ FILESBUILD_fccache= yes ${TOOL_SED} -e 's,@X11ROOTDIR@,${X11ROOTDIR},g' < ${.IMPSRC} > ${.TARGET} .endif +.if ${MKZFS} != "no" +CONFIGFILES+= zfs +.endif + .include <bsd.prog.mk> Index: src/etc/rc.d/mountall diff -u src/etc/rc.d/mountall:1.10 src/etc/rc.d/mountall:1.10.4.1 --- src/etc/rc.d/mountall:1.10 Fri Jun 8 14:44:21 2018 +++ src/etc/rc.d/mountall Fri Sep 27 09:18:37 2019 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: mountall,v 1.10 2018/06/08 14:44:21 sevan Exp $ +# $NetBSD: mountall,v 1.10.4.1 2019/09/27 09:18:37 martin Exp $ # # REQUIRE: mountcritremote named ypbind @@ -15,33 +15,23 @@ stop_cmd="mountall_stop" mountall_start() { echo 'Mounting all file systems...' - if [ -f /etc/zfs/zpool.cache ]; then - # Get ZFS module loaded (and thereby, zvols created). - zfs list > /dev/null 2>&1 - # Mount file systems noted in fstab. - mount -a + # Mount file systems noted in fstab. + mount -a + if checkyesno zfs && [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then # Mount ZFS file systems. zfs mount -a - else - # Mount file systems noted in fstab. - mount -a fi } mountall_stop() { echo 'Unmounting all file systems...' - if [ -f /etc/zfs/zpool.cache ]; then + if checkyesno zfs && [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then # Unmount ZFS file systems. zfs unmount -a - # Unmount file systems noted in fstab. - umount -a - # Unload ZFS module, so disk devices are closed. - modunload zfs - else - # Otherwise, just deal with fstab. - umount -a fi + # Unmount file systems noted in fstab. + umount -a } load_rc_config $name Index: src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c diff -u src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.6 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.6.4.1 --- src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.6 Mon May 28 21:05:04 2018 +++ src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c Fri Sep 27 09:18:37 2019 @@ -7135,8 +7135,13 @@ main(int argc, char **argv) * This command also doubles as the /etc/fs mount and unmount program. * Determine if we should take this behavior based on argv[0]. */ +#ifdef __NetBSD__ +#define LEGACYPROGNAME "mount_zfs" +#else +#define LEGACYPROGNAME "mount" +#endif progname = basename(argv[0]); - if (strcmp(progname, "mount") == 0) { + if (strcmp(progname, LEGACYPROGNAME) == 0) { ret = manual_mount(argc, argv); } else if (strcmp(progname, "umount") == 0) { ret = manual_unmount(argc, argv); Index: src/external/cddl/osnet/sbin/zfs/Makefile diff -u src/external/cddl/osnet/sbin/zfs/Makefile:1.4 src/external/cddl/osnet/sbin/zfs/Makefile:1.4.4.1 --- src/external/cddl/osnet/sbin/zfs/Makefile:1.4 Mon May 28 21:05:09 2018 +++ src/external/cddl/osnet/sbin/zfs/Makefile Fri Sep 27 09:18:37 2019 @@ -1,11 +1,12 @@ -# $NetBSD: Makefile,v 1.4 2018/05/28 21:05:09 chs Exp $ +# $NetBSD: Makefile,v 1.4.4.1 2019/09/27 09:18:37 martin Exp $ .include "../../Makefile.zfs" PROG= zfs -MAN= zfs.8 +MAN= zfs.8 mount_zfs.8 USETBL= yes SRCS= zfs_main.c zfs_iter.c +LINKS= ${BINDIR}/zfs ${BINDIR}/mount_zfs DPADD= ${LIBZFS} ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL} @@ -26,6 +27,7 @@ LDADD+= -L${LIBUMEM_OBJDIR} -lum LDADD+= -lm -lutil -lpthread +.PATH: ${.CURDIR} .PATH: ${ZFSDIR}/dist/cmd/zfs .include <bsd.prog.mk> Added files: Index: src/etc/rc.d/zfs diff -u /dev/null src/etc/rc.d/zfs:1.1.2.2 --- /dev/null Fri Sep 27 09:18:38 2019 +++ src/etc/rc.d/zfs Fri Sep 27 09:18:37 2019 @@ -0,0 +1,38 @@ +#!/bin/sh +# +# $NetBSD: zfs,v 1.1.2.2 2019/09/27 09:18:37 martin Exp $ +# + +# PROVIDE: zfs +# REQUIRE: root +# BEFORE: DISKS + +$_rc_subr_loaded . /etc/rc.subr + +name="zfs" +start_cmd="zfs_start" +stop_cmd="zfs_stop" + +zfs_start() +{ + if [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then + # Get ZFS module loaded (and thereby, zvols created). + /sbin/zfs list > /dev/null 2>&1 + if [ $? -ne 0 ]; then + warn "zfs module may not have loaded, may not be present in the kernel, or /dev/zfs may be missing" + return 1; + fi + fi +} + +zfs_stop() +{ + if [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then + zfs unmount -a + modunload zfs + fi + return 0; +} + +load_rc_config $name +run_rc_command "$1" Index: src/external/cddl/osnet/sbin/zfs/mount_zfs.8 diff -u /dev/null src/external/cddl/osnet/sbin/zfs/mount_zfs.8:1.5.2.2 --- /dev/null Fri Sep 27 09:18:38 2019 +++ src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Fri Sep 27 09:18:37 2019 @@ -0,0 +1,54 @@ +.\" $NetBSD: mount_zfs.8,v 1.5.2.2 2019/09/27 09:18:37 martin Exp $ +.\" +.\" Copyright (c) 2012, Martin Matuska <m...@freebsd.org>. +.\" Copyright (c) 2013-2014, Xin Li <delp...@freebsd.org>. +.\" All Rights Reserved. +.\" +.\" The contents of this file are subject to the terms of the +.\" Common Development and Distribution License (the "License"). +.\" You may not use this file except in compliance with the License. +.\" +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +.\" or http://www.opensolaris.org/os/licensing. +.\" See the License for the specific language governing permissions +.\" and limitations under the License. +.\" +.\" When distributing Covered Code, include this CDDL HEADER in each +.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. +.\" If applicable, add the following below this CDDL HEADER, with the +.\" fields enclosed by brackets "[]" replaced with your own identifying +.\" information: Portions Copyright [yyyy] [name of copyright owner] +.\" +.\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2011, Nexenta Systems, Inc. All Rights Reserved. +.\" Copyright (c) 2011, Justin T. Gibbs <gi...@freebsd.org> +.\" Copyright (c) 2013 by Delphix. All Rights Reserved. +.\" Copyright (c) 2012, Glen Barber <g...@freebsd.org> +.\" +.Dd September 15, 2019 +.Dt MOUNT_ZFS 8 +.Os +.Sh NAME +.Nm mount_zfs +.Nd helper utility for mounting legacy ZFS mounts +.Sh SYNOPSIS +.Nm +.Ar ZFS_dataset +.Ar mount_point +.Sh DESCRIPTION +The +.Nm +utility supports mounting ZFS filesystems via +.Pa /etc/fstab +where the ZFS property is +.Cm mountpoint=legacy . +.Sh SEE ALSO +.Xr fstab 5 , +.Xr zfs 8 +.Sh HISTORY +A command to manage legacy ZFS mounts appeared in Solaris as +.Pa /etc/fs/zfs/mount . +The +.Nm +utility first appeared in +.Nx 9.0 .