summaryrefslogtreecommitdiff
path: root/sys-fs/zfs/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-fs/zfs/files
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-fs/zfs/files')
-rw-r--r--sys-fs/zfs/files/bash-completion232
-rw-r--r--sys-fs/zfs/files/bash-completion-r1391
-rw-r--r--sys-fs/zfs/files/zed25
-rw-r--r--sys-fs/zfs/files/zfs-0.6.0_rc14-fix-libzpool-function-relocations.patch34
-rw-r--r--sys-fs/zfs/files/zfs-0.6.1-avoid-zdb-abort.patch30
-rw-r--r--sys-fs/zfs/files/zfs-0.6.1-fix-gcc-4.8-warning.patch42
-rw-r--r--sys-fs/zfs/files/zfs-0.6.1-fix-zvol-initialization-r1.patch167
-rw-r--r--sys-fs/zfs/files/zfs-0.6.1-gentoo-openrc-dependencies.patch57
-rw-r--r--sys-fs/zfs/files/zfs-0.6.5-fix-openrc-scripts.patch256
-rw-r--r--sys-fs/zfs/files/zfs-init.sh.in29
-rw-r--r--sys-fs/zfs/files/zfs.service.in16
11 files changed, 1279 insertions, 0 deletions
diff --git a/sys-fs/zfs/files/bash-completion b/sys-fs/zfs/files/bash-completion
new file mode 100644
index 000000000000..1b9428bf8602
--- /dev/null
+++ b/sys-fs/zfs/files/bash-completion
@@ -0,0 +1,232 @@
+# Copyright (c) 2010, Aneurin Price <aneurin.price@gmail.com>
+
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+__zfs_get_commands()
+{
+ zfs 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq
+}
+
+__zfs_get_properties()
+{
+ zfs get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all
+}
+
+__zfs_get_editable_properties()
+{
+ zfs get 2>&1 | awk '$2 == "YES" {printf("%s=\n", $1)}'
+}
+
+__zfs_get_inheritable_properties()
+{
+ zfs get 2>&1 | awk '$3 == "YES" {print $1}'
+}
+
+__zfs_list_datasets()
+{
+ zfs list -H -o name
+}
+
+__zfs_list_filesystems()
+{
+ zfs list -H -o name -t filesystem
+}
+
+__zfs_list_snapshots()
+{
+ zfs list -H -o name -t snapshot
+}
+
+__zfs_list_volumes()
+{
+ zfs list -H -o name -t volume
+}
+
+__zfs_argument_chosen()
+{
+ for word in $(seq $((COMP_CWORD-1)) -1 2)
+ do
+ local prev="${COMP_WORDS[$word]}"
+ for property in $@
+ do
+ if [ "x$prev" = "x$property" ]
+ then
+ return 0
+ fi
+ done
+ done
+ return 1
+}
+
+__zfs_complete_ordered_arguments()
+{
+ local list1=$1
+ local list2=$2
+ local cur=$3
+ local extra=$4
+ if __zfs_argument_chosen $list1
+ then
+ COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur"))
+ else
+ COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur"))
+ fi
+}
+
+__zfs_complete()
+{
+ local cur prev cmd cmds
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ cmd="${COMP_WORDS[1]}"
+ cmds=$(__zfs_get_commands)
+
+ if [ "${prev##*/}" = "zfs" ]
+ then
+ COMPREPLY=($(compgen -W "$cmds -?" -- "$cur"))
+ return 0
+ fi
+
+ case "${cmd}" in
+ clone)
+ __zfs_complete_ordered_arguments "$(__zfs_list_snapshots)" "$(__zfs_list_filesystems) $(__zfs_list_volumes)" $cur
+ return 0
+ ;;
+ get)
+ __zfs_complete_ordered_arguments "$(__zfs_get_properties)" "$(__zfs_list_datasets)" "$cur" "-H -r -p"
+ return 0
+ ;;
+ inherit)
+ __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_list_datasets)" $cur
+ return 0
+ ;;
+ list)
+ if [ "x$prev" = "x-o" ]
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "${cur##*,}"))
+ local existing_opts=$(expr "$cur" : '\(.*,\)')
+ if [ ! "x$existing_opts" = "x" ]
+ then
+ COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
+ fi
+ else
+ COMPREPLY=($(compgen -W "$(__zfs_list_datasets) -H -r -o" -- "$cur"))
+ fi
+ return 0
+ ;;
+ promote)
+ COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur"))
+ return 0
+ ;;
+ rollback|send)
+ COMPREPLY=($(compgen -W "$(__zfs_list_snapshots)" -- "$cur"))
+ return 0
+ ;;
+ snapshot)
+ COMPREPLY=($(compgen -W "$(__zfs_list_filesystems) $(__zfs_list_volumes)" -- "$cur"))
+ return 0
+ ;;
+ set)
+ __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_list_filesystems) $(__zfs_list_volumes)" $cur
+ return 0
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur"))
+ return 0
+ ;;
+ esac
+
+}
+
+__zpool_get_commands()
+{
+ zpool 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq
+}
+
+__zpool_get_properties()
+{
+ zpool get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all
+}
+
+__zpool_get_editable_properties()
+{
+ zpool get 2>&1 | awk '$2 == "YES" {printf("%s=\n", $1)}'
+}
+
+__zpool_list_pools()
+{
+ zpool list -H -o name
+}
+
+__zpool_complete()
+{
+ local cur prev cmd cmds
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ cmd="${COMP_WORDS[1]}"
+ cmds=$(__zpool_get_commands)
+
+ if [ "${prev##*/}" = "zpool" ]
+ then
+ COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
+ return 0
+ fi
+
+ case "${cmd}" in
+ get)
+ __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur
+ return 0
+ ;;
+ import)
+ if [ "x$prev" = "x-d" ]
+ then
+ _filedir -d
+ else
+ COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur"))
+ fi
+ return 0
+ ;;
+ set)
+ __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur
+ return 0
+ ;;
+ add|attach|clear|create|detach|offline|online|remove|replace)
+ local pools="$(__zpool_list_pools)"
+ if __zfs_argument_chosen $pools
+ then
+ _filedir
+ else
+ COMPREPLY=($(compgen -W "$pools" -- "$cur"))
+ fi
+ return 0
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur"))
+ return 0
+ ;;
+ esac
+
+}
+
+complete -F __zfs_complete zfs
+complete -o filenames -F __zpool_complete zpool
diff --git a/sys-fs/zfs/files/bash-completion-r1 b/sys-fs/zfs/files/bash-completion-r1
new file mode 100644
index 000000000000..b1aded368e85
--- /dev/null
+++ b/sys-fs/zfs/files/bash-completion-r1
@@ -0,0 +1,391 @@
+# Copyright (c) 2013, Aneurin Price <aneurin.price@gmail.com>
+
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+#if [[ -w /dev/zfs ]]; then
+ __ZFS_CMD="zfs"
+ __ZPOOL_CMD="zpool"
+#else
+# __ZFS_CMD="sudo zfs"
+# __ZPOOL_CMD="sudo zpool"
+#fi
+
+__zfs_get_commands()
+{
+ $__ZFS_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | cut -f1 -d '|' | uniq
+}
+
+__zfs_get_properties()
+{
+ $__ZFS_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all name space
+}
+
+__zfs_get_editable_properties()
+{
+ $__ZFS_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}'
+}
+
+__zfs_get_inheritable_properties()
+{
+ $__ZFS_CMD get 2>&1 | awk '$3 == "YES" {print $1}'
+}
+
+__zfs_list_datasets()
+{
+ $__ZFS_CMD list -H -o name -t filesystem,volume
+}
+
+__zfs_list_filesystems()
+{
+ $__ZFS_CMD list -H -o name -t filesystem
+}
+
+__zfs_match_snapshot()
+{
+ local base_dataset=${cur%@*}
+ if [[ $base_dataset != $cur ]]
+ then
+ $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset
+ else
+ $__ZFS_CMD list -H -o name -t filesystem,volume | awk '{print $1"@"}'
+ fi
+}
+
+__zfs_match_explicit_snapshot()
+{
+ local base_dataset=${cur%@*}
+ if [[ $base_dataset != $cur ]]
+ then
+ $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset
+ fi
+}
+
+__zfs_match_multiple_snapshots()
+{
+ local existing_opts=$(expr "$cur" : '\(.*\)[%,]')
+ if [[ $existing_opts ]]
+ then
+ local base_dataset=${cur%@*}
+ if [[ $base_dataset != $cur ]]
+ then
+ local cur=${cur##*,}
+ if [[ $cur =~ ^%|%.*% ]]
+ then
+ # correct range syntax is start%end
+ return 1
+ fi
+ local range_start=$(expr "$cur" : '\(.*%\)')
+ $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g'
+ fi
+ else
+ __zfs_match_explicit_snapshot; __zfs_list_datasets
+ fi
+}
+
+__zfs_list_volumes()
+{
+ $__ZFS_CMD list -H -o name -t volume
+}
+
+__zfs_argument_chosen()
+{
+ local word property
+ for word in $(seq $((COMP_CWORD-1)) -1 2)
+ do
+ local prev="${COMP_WORDS[$word]}"
+ if [[ ${COMP_WORDS[$word-1]} != -[tos] ]]
+ then
+ if [[ "$prev" == [^,]*,* ]] || [[ "$prev" == *[@:]* ]]
+ then
+ return 0
+ fi
+ for property in $@
+ do
+ if [[ $prev == "$property" ]]
+ then
+ return 0
+ fi
+ done
+ fi
+ done
+ return 1
+}
+
+__zfs_complete_ordered_arguments()
+{
+ local list1=$1
+ local list2=$2
+ local cur=$3
+ local extra=$4
+ if __zfs_argument_chosen $list1
+ then
+ COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur"))
+ else
+ COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur"))
+ fi
+}
+
+__zfs_complete_multiple_options()
+{
+ local options=$1
+ local cur=$2
+
+ COMPREPLY=($(compgen -W "$options" -- "${cur##*,}"))
+ local existing_opts=$(expr "$cur" : '\(.*,\)')
+ if [[ $existing_opts ]]
+ then
+ COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
+ fi
+}
+
+__zfs_complete_switch()
+{
+ local options=$1
+ if [[ ${cur:0:1} == - ]]
+ then
+ COMPREPLY=($(compgen -W "-{$options}" -- "$cur"))
+ return 0
+ else
+ return 1
+ fi
+}
+
+__zfs_complete()
+{
+ local cur prev cmd cmds
+ COMPREPLY=()
+ # Don't split on colon
+ _get_comp_words_by_ref -n : -c cur -p prev -w COMP_WORDS -i COMP_CWORD
+ cmd="${COMP_WORDS[1]}"
+
+ if [[ ${prev##*/} == zfs ]]
+ then
+ cmds=$(__zfs_get_commands)
+ COMPREPLY=($(compgen -W "$cmds -?" -- "$cur"))
+ return 0
+ fi
+
+ case "${cmd}" in
+ clone)
+ case "${prev}" in
+ -o)
+ COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur"))
+ ;;
+ *)
+ if ! __zfs_complete_switch "o,p"
+ then
+ if __zfs_argument_chosen
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur"))
+ else
+ COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
+ fi
+ fi
+ ;;
+ esac
+ ;;
+ get)
+ case "${prev}" in
+ -d)
+ COMPREPLY=($(compgen -W "" -- "$cur"))
+ ;;
+ -t)
+ __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur"
+ ;;
+ -s)
+ __zfs_complete_multiple_options "local default inherited temporary none" "$cur"
+ ;;
+ -o)
+ __zfs_complete_multiple_options "name property value source received all" "$cur"
+ ;;
+ *)
+ if ! __zfs_complete_switch "H,r,p,d,o,t,s"
+ then
+ if __zfs_argument_chosen $(__zfs_get_properties)
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
+ else
+ __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur"
+ fi
+ fi
+ ;;
+ esac
+ ;;
+ inherit)
+ if ! __zfs_complete_switch "r"
+ then
+ __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur
+ fi
+ ;;
+ list)
+ case "${prev}" in
+ -d)
+ COMPREPLY=($(compgen -W "" -- "$cur"))
+ ;;
+ -t)
+ __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur"
+ ;;
+ -o)
+ __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur"
+ ;;
+ -s|-S)
+ COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "$cur"))
+ ;;
+ *)
+ if ! __zfs_complete_switch "H,r,d,o,t,s,S"
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
+ fi
+ ;;
+ esac
+ ;;
+ promote)
+ COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur"))
+ ;;
+ rollback)
+ if ! __zfs_complete_switch "r,R,f"
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
+ fi
+ ;;
+ send)
+ if ! __zfs_complete_switch "d,n,P,p,R,v,i,I"
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
+ fi
+ ;;
+ snapshot)
+ case "${prev}" in
+ -o)
+ COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur"))
+ ;;
+ *)
+ if ! __zfs_complete_switch "o,r"
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_list_datasets | awk '{print $1"@"}')" -- "$cur"))
+ fi
+ ;;
+ esac
+ ;;
+ set)
+ __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur
+ ;;
+ upgrade)
+ case "${prev}" in
+ -a|-V|-v)
+ COMPREPLY=($(compgen -W "" -- "$cur"))
+ ;;
+ *)
+ if ! __zfs_complete_switch "a,V,v,r"
+ then
+ COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur"))
+ fi
+ ;;
+ esac
+ ;;
+ destroy)
+ if ! __zfs_complete_switch "d,f,n,p,R,r,v"
+ then
+ __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur
+ fi
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
+ ;;
+ esac
+ __ltrim_colon_completions "$cur"
+ return 0
+}
+
+__zpool_get_commands()
+{
+ $__ZPOOL_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq
+}
+
+__zpool_get_properties()
+{
+ $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all
+}
+
+__zpool_get_editable_properties()
+{
+ $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}'
+}
+
+__zpool_list_pools()
+{
+ $__ZPOOL_CMD list -H -o name
+}
+
+__zpool_complete()
+{
+ local cur prev cmd cmds
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ cmd="${COMP_WORDS[1]}"
+
+ if [[ ${prev##*/} == zpool ]]
+ then
+ cmds=$(__zpool_get_commands)
+ COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
+ return 0
+ fi
+
+ case "${cmd}" in
+ get)
+ __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur
+ return 0
+ ;;
+ import)
+ if [[ $prev == -d ]]
+ then
+ _filedir -d
+ else
+ COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur"))
+ fi
+ return 0
+ ;;
+ set)
+ __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur
+ return 0
+ ;;
+ add|attach|clear|create|detach|offline|online|remove|replace)
+ local pools="$(__zpool_list_pools)"
+ if __zfs_argument_chosen $pools
+ then
+ _filedir
+ else
+ COMPREPLY=($(compgen -W "$pools" -- "$cur"))
+ fi
+ return 0
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur"))
+ return 0
+ ;;
+ esac
+
+}
+
+complete -F __zfs_complete zfs
+complete -F __zpool_complete zpool
diff --git a/sys-fs/zfs/files/zed b/sys-fs/zfs/files/zed
new file mode 100644
index 000000000000..d46acfacb4a3
--- /dev/null
+++ b/sys-fs/zfs/files/zed
@@ -0,0 +1,25 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need zfs
+}
+
+start() {
+ ebegin "Starting ZFS Event daemon"
+
+ checkpath -q -d -m 0755 /var/run/zed
+
+ start-stop-daemon --start -q \
+ --exec /sbin/zed -- -M \
+ -p /var/run/zed/pid
+ eend $?
+
+}
+
+stop() {
+ebegin "Stopping ZFS Event daemon"
+ start-stop-daemon --stop -q --pidfile /var/run/zed/pid
+eend $?
+}
diff --git a/sys-fs/zfs/files/zfs-0.6.0_rc14-fix-libzpool-function-relocations.patch b/sys-fs/zfs/files/zfs-0.6.0_rc14-fix-libzpool-function-relocations.patch
new file mode 100644
index 000000000000..b493424a1e77
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.0_rc14-fix-libzpool-function-relocations.patch
@@ -0,0 +1,34 @@
+From 399f60c8b47f7513d078a7c181ff132e2cafdd15 Mon Sep 17 00:00:00 2001
+From: Richard Yao <ryao@cs.stonybrook.edu>
+Date: Tue, 5 Feb 2013 18:14:30 -0500
+Subject: [PATCH] Fix function relocations in libzpool
+
+binutils 2.23.1 fails in situations that generate function relocations
+on PowerPC and possibly other architectures. This causes linking of
+libzpool to fail because it depends on libnvpair. We add a dependency on
+libnvpair to lib/libzpool/Makefile.am to correct that.
+
+Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #1267
+---
+ lib/libzpool/Makefile.am | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am
+index 3e62de6..cbba388 100644
+--- a/lib/libzpool/Makefile.am
++++ b/lib/libzpool/Makefile.am
+@@ -94,7 +94,8 @@ libzpool_la_SOURCES = \
+
+ libzpool_la_LIBADD = \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+- $(top_builddir)/lib/libuutil/libuutil.la
++ $(top_builddir)/lib/libuutil/libuutil.la \
++ $(top_builddir)/lib/libnvpair/libnvpair.la
+
+ libzpool_la_LDFLAGS = -pthread -version-info 1:1:0
+
+--
+1.7.10
+
diff --git a/sys-fs/zfs/files/zfs-0.6.1-avoid-zdb-abort.patch b/sys-fs/zfs/files/zfs-0.6.1-avoid-zdb-abort.patch
new file mode 100644
index 000000000000..f73840feeed6
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.1-avoid-zdb-abort.patch
@@ -0,0 +1,30 @@
+From 5d3dc3fb72518a4c191e3a014622b74365eb3a74 Mon Sep 17 00:00:00 2001
+From: Mike Leddy <mike.leddy@gmail.com>
+Date: Thu, 4 Jul 2013 01:02:05 -0300
+Subject: [PATCH] Avoid abort() in vn_rdwr(): libzpool/kernel.c
+
+Make sure that buffer is aligned to 512 bytes on linux so that
+pread call combined with O_DIRECT does not return EINVAL.
+
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #1570
+---
+ cmd/zdb/zdb.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
+index 936974b..a2b6bfe 100644
+--- a/cmd/zdb/zdb.c
++++ b/cmd/zdb/zdb.c
+@@ -2844,7 +2844,7 @@
+ psize = size;
+ lsize = size;
+
+- pbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
++ pbuf = umem_alloc_aligned(SPA_MAXBLOCKSIZE, 512, UMEM_NOFAIL);
+ lbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
+
+ BP_ZERO(bp);
+--
+1.8.1.6
+
diff --git a/sys-fs/zfs/files/zfs-0.6.1-fix-gcc-4.8-warning.patch b/sys-fs/zfs/files/zfs-0.6.1-fix-gcc-4.8-warning.patch
new file mode 100644
index 000000000000..00ec1057efa1
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.1-fix-gcc-4.8-warning.patch
@@ -0,0 +1,42 @@
+From 3db3ff4a787acf068b122562fb5be5aecec2611f Mon Sep 17 00:00:00 2001
+From: Richard Yao <ryao@gentoo.org>
+Date: Tue, 2 Jul 2013 00:07:15 -0400
+Subject: [PATCH] Use MAXPATHLEN instead of sizeof in snprintf
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This silences a GCC 4.8.0 warning by fixing a programming error
+caught by static analysis:
+
+../../cmd/ztest/ztest.c: In function ‘ztest_vdev_aux_add_remove’:
+../../cmd/ztest/ztest.c:2584:33: error: argument to ‘sizeof’
+ in ‘snprintf’ call is the same expression as the destination;
+ did you mean to provide an explicit length?
+ [-Werror=sizeof-pointer-memaccess]
+ (void) snprintf(path, sizeof (path), ztest_aux_template,
+ ^
+
+Signed-off-by: Richard Yao <ryao@gentoo.org>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #1480
+---
+ cmd/ztest/ztest.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
+index b38d7b1..93a5f1e 100644
+--- a/cmd/ztest/ztest.c
++++ b/cmd/ztest/ztest.c
+@@ -2581,7 +2581,7 @@ enum ztest_object {
+ zs->zs_vdev_aux = 0;
+ for (;;) {
+ int c;
+- (void) snprintf(path, sizeof (path), ztest_aux_template,
++ (void) snprintf(path, MAXPATHLEN, ztest_aux_template,
+ ztest_opts.zo_dir, ztest_opts.zo_pool, aux,
+ zs->zs_vdev_aux);
+ for (c = 0; c < sav->sav_count; c++)
+--
+1.8.1.6
+
diff --git a/sys-fs/zfs/files/zfs-0.6.1-fix-zvol-initialization-r1.patch b/sys-fs/zfs/files/zfs-0.6.1-fix-zvol-initialization-r1.patch
new file mode 100644
index 000000000000..b1e7d3736db0
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.1-fix-zvol-initialization-r1.patch
@@ -0,0 +1,167 @@
+diff --git a/module/zfs/spa.c b/module/zfs/spa.c
+index e986e92..65f78b7 100644
+--- a/module/zfs/spa.c
++++ b/module/zfs/spa.c
+@@ -64,6 +64,7 @@
+ #include <sys/zfs_ioctl.h>
+ #include <sys/dsl_scan.h>
+ #include <sys/zfeature.h>
++#include <sys/zvol.h>
+
+ #ifdef _KERNEL
+ #include <sys/bootprops.h>
+@@ -2856,6 +2857,7 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
+ spa_load_state_t state = SPA_LOAD_OPEN;
+ int error;
+ int locked = B_FALSE;
++ int firstopen = B_FALSE;
+
+ *spapp = NULL;
+
+@@ -2879,6 +2881,8 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
+ if (spa->spa_state == POOL_STATE_UNINITIALIZED) {
+ zpool_rewind_policy_t policy;
+
++ firstopen = B_TRUE;
++
+ zpool_get_rewind_policy(nvpolicy ? nvpolicy : spa->spa_config,
+ &policy);
+ if (policy.zrp_request & ZPOOL_DO_REWIND)
+@@ -2953,6 +2957,11 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
+ mutex_exit(&spa_namespace_lock);
+ }
+
++#ifdef _KERNEL
++ if (firstopen)
++ zvol_create_minors(spa->spa_name);
++#endif
++
+ *spapp = spa;
+
+ return (0);
+@@ -4010,6 +4019,10 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
+ mutex_exit(&spa_namespace_lock);
+ spa_history_log_version(spa, LOG_POOL_IMPORT);
+
++#ifdef _KERNEL
++ zvol_create_minors(pool);
++#endif
++
+ return (0);
+ }
+
+diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
+index 1226b2c..a9184a1 100644
+--- a/module/zfs/zfs_ioctl.c
++++ b/module/zfs/zfs_ioctl.c
+@@ -1268,9 +1268,6 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
+ error = err;
+ }
+
+- if (error == 0)
+- zvol_create_minors(zc->zc_name);
+-
+ nvlist_free(config);
+
+ if (props)
+diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
+index 43a7bb6..e35c91b 100644
+--- a/module/zfs/zvol.c
++++ b/module/zfs/zvol.c
+@@ -1215,6 +1215,9 @@ zvol_alloc(dev_t dev, const char *name)
+
+ zv = kmem_zalloc(sizeof (zvol_state_t), KM_SLEEP);
+
++ spin_lock_init(&zv->zv_lock);
++ list_link_init(&zv->zv_next);
++
+ zv->zv_queue = blk_init_queue(zvol_request, &zv->zv_lock);
+ if (zv->zv_queue == NULL)
+ goto out_kmem;
+@@ -1248,9 +1251,6 @@ zvol_alloc(dev_t dev, const char *name)
+ sizeof (rl_t), offsetof(rl_t, r_node));
+ zv->zv_znode.z_is_zvol = TRUE;
+
+- spin_lock_init(&zv->zv_lock);
+- list_link_init(&zv->zv_next);
+-
+ zv->zv_disk->major = zvol_major;
+ zv->zv_disk->first_minor = (dev & MINORMASK);
+ zv->zv_disk->fops = &zvol_ops;
+@@ -1561,30 +1561,36 @@ zvol_init(void)
+ {
+ int error;
+
++ list_create(&zvol_state_list, sizeof (zvol_state_t),
++ offsetof(zvol_state_t, zv_next));
++ mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);
++
+ zvol_taskq = taskq_create(ZVOL_DRIVER, zvol_threads, maxclsyspri,
+ zvol_threads, INT_MAX, TASKQ_PREPOPULATE);
+ if (zvol_taskq == NULL) {
+ printk(KERN_INFO "ZFS: taskq_create() failed\n");
+- return (-ENOMEM);
++ error = -ENOMEM;
++ goto out1;
+ }
+
+ error = register_blkdev(zvol_major, ZVOL_DRIVER);
+ if (error) {
+ printk(KERN_INFO "ZFS: register_blkdev() failed %d\n", error);
+- taskq_destroy(zvol_taskq);
+- return (error);
++ goto out2;
+ }
+
+ blk_register_region(MKDEV(zvol_major, 0), 1UL << MINORBITS,
+ THIS_MODULE, zvol_probe, NULL, NULL);
+
+- mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);
+- list_create(&zvol_state_list, sizeof (zvol_state_t),
+- offsetof(zvol_state_t, zv_next));
++ return (0);
+
+- (void) zvol_create_minors(NULL);
++out2:
++ taskq_destroy(zvol_taskq);
++out1:
++ mutex_destroy(&zvol_state_lock);
++ list_destroy(&zvol_state_list);
+
+- return (0);
++ return (error);
+ }
+
+ void
+diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh
+index 141348c..281166c 100755
+--- a/scripts/zconfig.sh
++++ b/scripts/zconfig.sh
+@@ -264,8 +264,9 @@ test_4() {
+ zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9
+
+- # Load the modules, wait 1 second for udev
++ # Load the modules, list the pools to ensure they are opened
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 10
++ ${ZPOOL} list &>/dev/null
+
+ # Verify the devices were created
+ zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+diff --git a/udev/rules.d/90-zfs.rules.in b/udev/rules.d/90-zfs.rules.in
+index 52e1d63..a2715d2 100644
+--- a/udev/rules.d/90-zfs.rules.in
++++ b/udev/rules.d/90-zfs.rules.in
+@@ -1,4 +1,4 @@
+-SUBSYSTEM!="block", GOTO="zfs_end"
++SUBSYSTEM!="block|misc", GOTO="zfs_end"
+ ACTION!="add|change", GOTO="zfs_end"
+
+ ENV{ID_FS_TYPE}=="zfs", RUN+="/sbin/modprobe zfs"
+@@ -7,4 +7,6 @@ ENV{ID_FS_TYPE}=="zfs_member", RUN+="/sbin/modprobe zfs"
+ KERNEL=="null", SYMLINK+="root"
+ SYMLINK=="null", SYMLINK+="root"
+
++SUBSYSTEM=="misc", KERNEL=="zfs", RUN+="@sbindir@/zpool list"
++
+ LABEL="zfs_end"
diff --git a/sys-fs/zfs/files/zfs-0.6.1-gentoo-openrc-dependencies.patch b/sys-fs/zfs/files/zfs-0.6.1-gentoo-openrc-dependencies.patch
new file mode 100644
index 000000000000..e794b183eb33
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.1-gentoo-openrc-dependencies.patch
@@ -0,0 +1,57 @@
+commit 75c2fb953c99bba008f1ef72ee71136002749f51
+Author: Richard Yao <ryao@cs.stonybrook.edu>
+Date: Tue May 28 20:08:15 2013 -0400
+
+ Improve OpenRC init script
+
+ The current zfs OpenRC script's dependencies cause OpenRC to attempt to
+ unmount ZFS filesystems at shutdown while things were still using them,
+ which would fail. This is a cosmetic issue, but it should still be
+ addressed. It probably does not affect systems where the rootfs is a
+ legacy filesystem, but any system with the rootfs on ZFS needs to run
+ the ZFS init script after the system is ready to shutdown filesystems.
+
+ OpenRC's shutdown process occurs in the reverse order of the startup
+ process. Therefore running the ZFS shutdown procedure after filesystems
+ are ready to be unmounted requires running the startup procedure before
+ fstab. This patch changes the dependencies of the script to expliclty
+ run before fstab at boot when the rootfs is ZFS and to run after fstab
+ at boot whenever the rootfs is not ZFS. This should cover most use
+ cases.
+
+ The only cases not covered well by this are systems with legacy
+ root filesystems where people want to configure fstab to mount a non-ZFS
+ filesystem off a zvol and possibly also systems whose pools are stored
+ on network block devices. The former requires that the ZFS script run
+ before fstab, which could cause ZFS datasets to mount too early and
+ appear under the fstab mount points. The latter requires that the ZFS
+ script run after networking starts, which precludes the ability to store
+ any system information on ZFS. An additional OpenRC script could be
+ written to handle non-root pools on network block devices, but that will
+ depend on user demand and developer time.
+
+ Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
+
+diff --git a/etc/init.d/zfs.gentoo.in b/etc/init.d/zfs.gentoo.in
+index 5b8671e..0034e02 100644
+--- a/etc/init.d/zfs.gentoo.in
++++ b/etc/init.d/zfs.gentoo.in
+@@ -10,9 +10,16 @@ fi
+
+ depend()
+ {
++ # Try to allow people to mix and match fstab with ZFS in a way that makes sense.
++ if [ "$(mountinfo -s /)" = 'zfs' ]
++ then
++ before localmount
++ else
++ after localmount
++ fi
++
+ # bootmisc will log to /var which may be a different zfs than root.
+- before net bootmisc
+- after udev localmount
++ before bootmisc logger
+ keyword -lxc -openvz -prefix -vserver
+ }
+
diff --git a/sys-fs/zfs/files/zfs-0.6.5-fix-openrc-scripts.patch b/sys-fs/zfs/files/zfs-0.6.5-fix-openrc-scripts.patch
new file mode 100644
index 000000000000..fec87d0123f3
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-0.6.5-fix-openrc-scripts.patch
@@ -0,0 +1,256 @@
+commit 3cb750b249717b43cbfcde78b44b0e38a2a61dc2
+Author: James Lee <jlee@thestaticvoid.com>
+Date: Sat Sep 19 22:00:36 2015 -0400
+
+ zfs-import: Perform verbatim import using cache file
+
+ This change modifies the import service to use the default cache file
+ to perform a verbatim import of pools at boot. This fixes code that
+ searches all devices and imported all visible pools.
+
+ Using the cache file is in keeping with the way ZFS has always worked,
+ how Solaris, Illumos, FreeBSD, and systemd performs imports, and is how
+ it is written in the man page (zpool(1M,8)):
+
+ All pools in this cache are automatically imported when the
+ system boots.
+
+ Importantly, the cache contains important information for importing
+ multipath devices, and helps control which pools get imported in more
+ dynamic environments like SANs, which may have thousands of visible
+ and constantly changing pools, which the ZFS_POOL_EXCEPTIONS variable
+ is not equipped to handle. Verbatim imports prevent rogue pools from
+ being automatically imported and mounted where they shouldn't be.
+
+ The change also stops the service from exporting pools at shutdown.
+ Exporting pools is only meant to be performed explicitly by the
+ administrator of the system.
+
+ The old behavior of searching and importing all visible pools is
+ preserved and can be switched on by heeding the warning and toggling
+ the ZPOOL_IMPORT_ALL_VISIBLE variable in /etc/default/zfs.
+
+ Closes #3777
+ Closes #3526
+
+diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
+index 5e21929..2258638 100755
+--- a/etc/init.d/zfs-import.in
++++ b/etc/init.d/zfs-import.in
+@@ -1,11 +1,10 @@
+ #!@SHELL@
+ #
+-# zfs-import This script will import/export zfs pools.
++# zfs-import This script will import ZFS pools
+ #
+ # chkconfig: 2345 01 99
+-# description: This script will import/export zfs pools during system
+-# boot/shutdown.
+-# It is also responsible for all userspace zfs services.
++# description: This script will perform a verbatim import of ZFS pools
++# during system boot.
+ # probe: true
+ #
+ ### BEGIN INIT INFO
+@@ -17,7 +16,7 @@
+ # X-Start-Before: checkfs
+ # X-Stop-After: zfs-mount
+ # Short-Description: Import ZFS pools
+-# Description: Run the `zpool import` or `zpool export` commands.
++# Description: Run the `zpool import` command.
+ ### END INIT INFO
+ #
+ # NOTE: Not having '$local_fs' on Required-Start but only on Required-Stop
+@@ -43,6 +42,16 @@ do_depend()
+ keyword -lxc -openvz -prefix -vserver
+ }
+
++# Use the zpool cache file to import pools
++do_verbatim_import()
++{
++ if [ -f "$ZPOOL_CACHE" ]
++ then
++ zfs_action "Importing ZFS pool(s)" \
++ "$ZPOOL" import -c "$ZPOOL_CACHE" -N -a
++ fi
++}
++
+ # Support function to get a list of all pools, separated with ';'
+ find_pools()
+ {
+@@ -60,8 +69,8 @@ find_pools()
+ echo "${pools%%;}" # Return without the last ';'.
+ }
+
+-# Import all pools
+-do_import()
++# Find and import all visible pools, even exported ones
++do_import_all_visible()
+ {
+ local already_imported available_pools pool npools
+ local exception dir ZPOOL_IMPORT_PATH RET=0 r=1
+@@ -109,7 +118,7 @@ do_import()
+ fi
+ fi
+
+- # Filter out any exceptions...
++ # Filter out any exceptions...
+ if [ -n "$ZFS_POOL_EXCEPTIONS" ]
+ then
+ local found=""
+@@ -249,41 +258,15 @@ do_import()
+ return "$RET"
+ }
+
+-# Export all pools
+-do_export()
++do_import()
+ {
+- local already_imported pool root_pool RET r
+- RET=0
+-
+- root_pool=$(get_root_pool)
+-
+- [ -n "$init" ] && zfs_log_begin_msg "Exporting ZFS pool(s)"
+-
+- # Find list of already imported pools.
+- already_imported=$(find_pools "$ZPOOL" list -H -oname)
+-
+- OLD_IFS="$IFS" ; IFS=";"
+- for pool in $already_imported; do
+- [ "$pool" = "$root_pool" ] && continue
+-
+- if [ -z "$init" ]
+- then
+- # Interactive - one 'Importing ...' line per pool
+- zfs_log_begin_msg "Exporting ZFS pool $pool"
+- else
+- # Not interactive - a dot for each pool.
+- zfs_log_progress_msg "."
+- fi
+-
+- "$ZPOOL" export "$pool"
+- r="$?" ; RET=$((RET + r))
+- [ -z "$init" ] && zfs_log_end_msg "$r"
+- done
+- IFS="$OLD_IFS"
+-
+- [ -n "$init" ] && zfs_log_end_msg "$RET"
+-
+- return "$RET"
++ if check_boolean "$ZPOOL_IMPORT_ALL_VISIBLE"
++ then
++ do_import_all_visible
++ else
++ # This is the default option
++ do_verbatim_import
++ fi
+ }
+
+ # Output the status and list of pools
+@@ -323,14 +306,6 @@ do_start()
+ fi
+ }
+
+-do_stop()
+-{
+- # Check to see if the module is even loaded.
+- check_module_loaded "zfs" || exit 0
+-
+- do_export
+-}
+-
+ # ----------------------------------------------------
+
+ if [ ! -e /etc/gentoo-release ]
+@@ -340,7 +315,7 @@ then
+ do_start
+ ;;
+ stop)
+- do_stop
++ # no-op
+ ;;
+ status)
+ do_status
+@@ -350,7 +325,7 @@ then
+ ;;
+ *)
+ [ -n "$1" ] && echo "Error: Unknown command $1."
+- echo "Usage: $0 {start|stop|status}"
++ echo "Usage: $0 {start|status}"
+ exit 3
+ ;;
+ esac
+@@ -360,6 +335,5 @@ else
+ # Create wrapper functions since Gentoo don't use the case part.
+ depend() { do_depend; }
+ start() { do_start; }
+- stop() { do_stop; }
+ status() { do_status; }
+ fi
+diff --git a/etc/init.d/zfs.in b/etc/init.d/zfs.in
+index eabb7e4..d81ef22 100644
+--- a/etc/init.d/zfs.in
++++ b/etc/init.d/zfs.in
+@@ -16,6 +16,24 @@ ZFS_SHARE='yes'
+ # Run `zfs unshare -a` during system stop?
+ ZFS_UNSHARE='yes'
+
++# By default, a verbatim import of all pools is performed at boot based on the
++# contents of the default zpool cache file. The contents of the cache are
++# managed automatically by the 'zpool import' and 'zpool export' commands.
++#
++# By setting this to 'yes', the system will instead search all devices for
++# pools and attempt to import them all at boot, even those that have been
++# exported. Under this mode, the search path can be controlled by the
++# ZPOOL_IMPORT_PATH variable and a list of pools that should not be imported
++# can be listed in the ZFS_POOL_EXCEPTIONS variable.
++#
++# Note that importing all visible pools may include pools that you don't
++# expect, such as those on removable devices and SANs, and those pools may
++# proceed to mount themselves in places you do not want them to. The results
++# can be unpredictable and possibly dangerous. Only enable this option if you
++# understand this risk and have complete physical control over your system and
++# SAN to prevent the insertion of malicious pools.
++ZPOOL_IMPORT_ALL_VISIBLE='no'
++
+ # Specify specific path(s) to look for device nodes and/or links for the
+ # pool import(s). See zpool(8) for more information about this variable.
+ # It supersedes the old USE_DISK_BY_ID which indicated that it would only
+@@ -23,6 +41,18 @@ ZFS_UNSHARE='yes'
+ # The old variable will still work in the code, but is deprecated.
+ #ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:/dev/disk/by-id"
+
++# List of pools that should NOT be imported at boot
++# when ZPOOL_IMPORT_ALL_VISIBLE is 'yes'.
++# This is a space separated list.
++#ZFS_POOL_EXCEPTIONS="test2"
++
++# List of pools that SHOULD be imported at boot by the initramfs
++# instead of trying to import all available pools. If this is set
++# then ZFS_POOL_EXCEPTIONS is ignored.
++# Only applicable for Debian GNU/Linux {dkms,initramfs}.
++# This is a semi-colon separated list.
++#ZFS_POOL_IMPORT="pool1;pool2"
++
+ # Should the datasets be mounted verbosely?
+ # A mount counter will be used when mounting if set to 'yes'.
+ VERBOSE_MOUNT='no'
+@@ -97,17 +127,6 @@ ZFS_INITRD_POST_MODPROBE_SLEEP='0'
+ # Example: If root FS is 'rpool/ROOT/rootfs', this would make sense.
+ #ZFS_INITRD_ADDITIONAL_DATASETS="rpool/ROOT/usr rpool/ROOT/var"
+
+-# List of pools that should NOT be imported at boot?
+-# This is a space separated list.
+-#ZFS_POOL_EXCEPTIONS="test2"
+-
+-# List of pools to import?
+-# If this variable is set, there will be NO auto-import of ANY other
+-# pool. In essence, there will be no auto detection of availible pools.
+-# This is a semi-colon separated list.
+-# Makes the variable ZFS_POOL_EXCEPTIONS above redundant (won't be checked).
+-#ZFS_POOL_IMPORT="pool1;pool2"
+-
+ # Optional arguments for the ZFS Event Daemon (ZED).
+ # See zed(8) for more information on available options.
+ #ZED_ARGS="-M"
diff --git a/sys-fs/zfs/files/zfs-init.sh.in b/sys-fs/zfs/files/zfs-init.sh.in
new file mode 100644
index 000000000000..ed84585cd5f6
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-init.sh.in
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+ZFS="@sbindir@/zfs"
+ZPOOL="@sbindir@/zpool"
+ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
+
+if [ -f "${ZPOOL_CACHE}" ]; then
+ "${ZPOOL}" import -c "${ZPOOL_CACHE}" -aN 2>/dev/null
+ if [ "${?}" != "0" ]; then
+ echo "Failed to import not-yet imported pools." >&2
+ fi
+fi
+
+echo "Mounting ZFS filesystems"
+"${ZFS}" mount -a
+if [ "${?}" != "0" ]; then
+ echo "Failed to mount ZFS filesystems." >&2
+ exit 1
+fi
+
+echo "Exporting ZFS filesystems"
+"${ZFS}" share -a
+if [ "${?}" != "0" ]; then
+ echo "Failed to export ZFS filesystems." >&2
+ exit 1
+fi
+
+exit 0
+
diff --git a/sys-fs/zfs/files/zfs.service.in b/sys-fs/zfs/files/zfs.service.in
new file mode 100644
index 000000000000..c390a480708e
--- /dev/null
+++ b/sys-fs/zfs/files/zfs.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=ZFS filesystems setup
+Before=network.target
+After=systemd-udev-settle.target local-fs.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStartPre=/sbin/modprobe zfs
+ExecStartPre=/usr/bin/test -c /dev/zfs
+ExecStart=/usr/libexec/zfs-init.sh
+ExecStop=@sbindir@/zfs umount -a
+
+[Install]
+WantedBy=multi-user.target
+