1307182Savg#!/bin/sh 2307182Savg# 3307182Savg# $FreeBSD: stable/10/etc/rc.d/zfsbe 308244 2016-11-03 08:34:37Z avg $ 4307182Savg# 5307182Savg 6307182Savg# PROVIDE: zfsbe 7307182Savg# REQUIRE: mountcritlocal 8307182Savg 9307182Savg# Handle boot environment subordinate filesystems 10307182Savg# that may have canmount property set to noauto. 11307182Savg# For these filesystems mountpoint relative to / 12307182Savg# must be the same as their dataset name relative 13307182Savg# to BE root dataset. 14307182Savg 15307182Savg. /etc/rc.subr 16307182Savg 17307182Savgname="zfsbe" 18307182Savgrcvar="zfs_enable" 19307182Savgstart_cmd="be_start" 20307182Savgstop_cmd="be_stop" 21307182Savgrequired_modules="zfs" 22307182Savg 23307182Savgmount_subordinate() 24307182Savg{ 25307182Savg local _be 26307182Savg 27307182Savg _be=$1 28307182Savg zfs list -rH -o mountpoint,name,canmount,mounted -s mountpoint -t filesystem $_be | \ 29307182Savg while read _mp _name _canmount _mounted ; do 30307182Savg # skip filesystems that must not be mounted 31307182Savg [ "$_canmount" = "off" ] && continue 32307182Savg # skip filesystems that are already mounted 33307182Savg [ "$_mounted" = "yes" ] && continue 34307182Savg case "$_mp" in 35307182Savg "none" | "legacy" | "/" | "/$_be") 36307182Savg # do nothing for filesystems with unset or legacy mountpoint 37307182Savg # or those that would be mounted over / 38307182Savg ;; 39307182Savg "/$_be/"*) 40307182Savg # filesystems with mountpoint relative to BE 41307182Savg mount -t zfs $_name ${_mp#/$_be} 42307182Savg ;; 43307182Savg *) 44307182Savg # filesystems with mountpoint elsewhere 45307182Savg zfs mount $_name 46307182Savg ;; 47307182Savg esac 48307182Savg done 49307182Savg} 50307182Savg 51307182Savgbe_start() 52307182Savg{ 53307182Savg if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then 54307182Savg : 55307182Savg else 56307182Savg mount -p | while read _dev _mp _type _rest; do 57307182Savg [ $_mp = "/" ] || continue 58307182Savg if [ $_type = "zfs" ] ; then 59307182Savg mount_subordinate $_dev 60307182Savg fi 61307182Savg break 62307182Savg done 63307182Savg fi 64307182Savg} 65307182Savg 66307182Savgbe_stop() 67307182Savg{ 68307182Savg} 69307182Savg 70307182Savgload_rc_config $name 71307182Savgrun_rc_command "$1" 72