zfs revision 168956
1168410Spjd#!/bin/sh 2168410Spjd# 3168410Spjd# $FreeBSD: head/etc/rc.d/zfs 168956 2007-04-22 20:55:08Z pjd $ 4168410Spjd# 5168410Spjd 6168410Spjd# PROVIDE: zfs 7168410Spjd# REQUIRE: mountcritlocal 8168410Spjd 9168410Spjd. /etc/rc.subr 10168410Spjd 11168410Spjdname="zfs" 12168410Spjdrcvar="zfs_enable" 13168410Spjdstart_cmd="zfs_start" 14168410Spjdstop_cmd="zfs_stop" 15168410Spjdrequired_modules="zfs" 16168410Spjd 17168956Spjdzfs_start_jail() 18168410Spjd{ 19168956Spjd if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then 20168956Spjd zfs mount -a 21168956Spjd fi 22168956Spjd} 23168956Spjd 24168956Spjdzfs_start_main() 25168956Spjd{ 26168686Spjd zfs volinit 27168410Spjd zfs mount -a 28168410Spjd zfs share -a 29168686Spjd if [ ! -r /etc/zfs/exports ]; then 30168686Spjd touch /etc/zfs/exports 31168686Spjd fi 32168766Spjd # Enable swap on ZVOLs with property org.freebsd:swap=on. 33168766Spjd zfs list -H -o org.freebsd:swap,name -t volume | \ 34168766Spjd while read state name; do 35168766Spjd case "${state}" in 36168766Spjd [oO][nN]) 37168766Spjd swapon /dev/zvol/${name} 38168766Spjd ;; 39168766Spjd esac 40168766Spjd done 41168410Spjd} 42168410Spjd 43168956Spjdzfs_start() 44168410Spjd{ 45168956Spjd if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then 46168956Spjd zfs_start_jail 47168956Spjd else 48168956Spjd zfs_start_main 49168956Spjd fi 50168956Spjd} 51168956Spjd 52168956Spjdzfs_stop_jail() 53168956Spjd{ 54168956Spjd if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then 55168956Spjd zfs unmount -a 56168956Spjd fi 57168956Spjd} 58168956Spjd 59168956Spjdzfs_stop_main() 60168956Spjd{ 61168766Spjd # Disable swap on ZVOLs with property org.freebsd:swap=on. 62168766Spjd zfs list -H -o org.freebsd:swap,name -t volume | \ 63168766Spjd while read state name; do 64168766Spjd case "${state}" in 65168766Spjd [oO][nN]) 66168766Spjd swapoff /dev/zvol/${name} 67168766Spjd ;; 68168766Spjd esac 69168766Spjd done 70168410Spjd zfs unshare -a 71168686Spjd zfs unmount -a 72168410Spjd zfs volfini 73168410Spjd} 74168410Spjd 75168956Spjdzfs_stop() 76168956Spjd{ 77168956Spjd if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then 78168956Spjd zfs_stop_jail 79168956Spjd else 80168956Spjd zfs_stop_main 81168956Spjd fi 82168956Spjd} 83168956Spjd 84168410Spjdload_rc_config $name 85168410Spjdrun_rc_command "$1" 86