summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2016-11-03 08:34:37 +0000
committeravg <avg@FreeBSD.org>2016-11-03 08:34:37 +0000
commita7295e84d3ef1e49a24dc410eedbb13fea171c62 (patch)
treee8a68200a03b9a984ad748631737ece11213d7cd /etc
parenta80773c87e22a39030ea8f96675519d7ff17fb85 (diff)
downloadFreeBSD-src-a7295e84d3ef1e49a24dc410eedbb13fea171c62.zip
FreeBSD-src-a7295e84d3ef1e49a24dc410eedbb13fea171c62.tar.gz
MFC r307182,307191,307192: rc.d/zfsbe: new script designed for BE support
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/Makefile1
-rwxr-xr-xetc/rc.d/zfs2
-rwxr-xr-xetc/rc.d/zfsbe71
3 files changed, 73 insertions, 1 deletions
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index a80f631..02896a4 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -283,6 +283,7 @@ FILES+= wpa_supplicant
.if ${MK_ZFS} != "no"
FILES+= zfs
+FILES+= zfsbe
FILES+= zvol
.endif
diff --git a/etc/rc.d/zfs b/etc/rc.d/zfs
index e76aac6..7cde065d 100755
--- a/etc/rc.d/zfs
+++ b/etc/rc.d/zfs
@@ -4,7 +4,7 @@
#
# PROVIDE: zfs
-# REQUIRE: mountcritlocal
+# REQUIRE: zfsbe
# BEFORE: FILESYSTEMS var
. /etc/rc.subr
diff --git a/etc/rc.d/zfsbe b/etc/rc.d/zfsbe
new file mode 100755
index 0000000..3c85201
--- /dev/null
+++ b/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"
OpenPOWER on IntegriCloud