Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Nov 2016 08:34:37 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r308244 - in stable/10: etc/rc.d tools/build/mk
Message-ID:  <201611030834.uA38Ybot069262@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Nov  3 08:34:37 2016
New Revision: 308244
URL: https://svnweb.freebsd.org/changeset/base/308244

Log:
  MFC r307182,307191,307192: rc.d/zfsbe: new script designed for BE support

Added:
  stable/10/etc/rc.d/zfsbe
     - copied unchanged from r307182, head/etc/rc.d/zfsbe
Modified:
  stable/10/etc/rc.d/Makefile
  stable/10/etc/rc.d/zfs
  stable/10/tools/build/mk/OptionalObsoleteFiles.inc
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/rc.d/Makefile
==============================================================================
--- stable/10/etc/rc.d/Makefile	Thu Nov  3 08:34:24 2016	(r308243)
+++ stable/10/etc/rc.d/Makefile	Thu Nov  3 08:34:37 2016	(r308244)
@@ -283,6 +283,7 @@ FILES+=		wpa_supplicant
 
 .if ${MK_ZFS} != "no"
 FILES+=		zfs
+FILES+=		zfsbe
 FILES+=		zvol
 .endif
 

Modified: stable/10/etc/rc.d/zfs
==============================================================================
--- stable/10/etc/rc.d/zfs	Thu Nov  3 08:34:24 2016	(r308243)
+++ stable/10/etc/rc.d/zfs	Thu Nov  3 08:34:37 2016	(r308244)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: zfs
-# REQUIRE: mountcritlocal
+# REQUIRE: zfsbe
 # BEFORE: FILESYSTEMS var
 
 . /etc/rc.subr

Copied: stable/10/etc/rc.d/zfsbe (from r307182, head/etc/rc.d/zfsbe)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/etc/rc.d/zfsbe	Thu Nov  3 08:34:37 2016	(r308244, copy of r307182, head/etc/rc.d/zfsbe)
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: zfsbe
+# REQUIRE: mountcritlocal
+
+# Handle boot environment subordinate filesystems
+# that may have canmount property set to noauto.
+# For these filesystems mountpoint relative to /
+# must be the same as their dataset name relative
+# to BE root dataset.
+
+. /etc/rc.subr
+
+name="zfsbe"
+rcvar="zfs_enable"
+start_cmd="be_start"
+stop_cmd="be_stop"
+required_modules="zfs"
+
+mount_subordinate()
+{
+	local _be
+
+	_be=$1
+	zfs list -rH -o mountpoint,name,canmount,mounted -s mountpoint -t filesystem $_be | \
+	while read _mp _name _canmount _mounted ; do
+		# skip filesystems that must not be mounted
+		[ "$_canmount" = "off" ] && continue
+		# skip filesystems that are already mounted
+		[ "$_mounted" = "yes" ] && continue
+		case "$_mp" in
+		"none" | "legacy" | "/" | "/$_be")
+			# do nothing for filesystems with unset or legacy mountpoint
+			# or those that would be mounted over /
+			;;
+		"/$_be/"*)
+			# filesystems with mountpoint relative to BE
+			mount -t zfs $_name ${_mp#/$_be}
+			;;
+		*)
+			# filesystems with mountpoint elsewhere
+			zfs mount $_name
+			;;
+		esac
+	done
+}
+
+be_start()
+{
+	if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
+		:
+	else
+		mount -p | while read _dev _mp _type _rest; do
+			[ $_mp  = "/" ] || continue
+			if [ $_type = "zfs" ] ; then
+				mount_subordinate $_dev
+			fi
+			break
+		done
+	fi
+}
+
+be_stop()
+{
+}
+
+load_rc_config $name
+run_rc_command "$1"

Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc
==============================================================================
--- stable/10/tools/build/mk/OptionalObsoleteFiles.inc	Thu Nov  3 08:34:24 2016	(r308243)
+++ stable/10/tools/build/mk/OptionalObsoleteFiles.inc	Thu Nov  3 08:34:37 2016	(r308244)
@@ -711,6 +711,7 @@ OLD_FILES+=boot/gptzfsboot
 OLD_FILES+=boot/zfsboot
 OLD_FILES+=boot/zfsloader
 OLD_FILES+=etc/rc.d/zfs
+OLD_FILES+=etc/rc.d/zfsbe
 OLD_FILES+=etc/rc.d/zvol
 OLD_FILES+=etc/devd/zfs.conf
 OLD_FILES+=etc/periodic/daily/404.status-zfs



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611030834.uA38Ybot069262>