Fix Dracut scripts to allow for blanks in pool and dataset names

The ability to use blanks is documented in zpool(8) and implemented
in module/zcommon/zfs_namecheck.c:valid_char().

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3083
This commit is contained in:
Lukas Wunner 2015-02-07 11:34:22 +01:00 committed by Brian Behlendorf
parent 293d141ae4
commit bf5efb5c66
2 changed files with 16 additions and 4 deletions

View File

@ -4,15 +4,21 @@ _do_zpool_export() {
local ret=0 local ret=0
local final=$1 local final=$1
local force local force
local OLDIFS="$IFS"
local NEWLINE="
"
if [ "x$final" != "x" ]; then if [ "x$final" != "x" ]; then
force="-f" force="-f"
fi fi
info "Exporting ZFS storage pools" info "Exporting ZFS storage pools"
# Change IFS to allow for blanks in pool names.
IFS="$NEWLINE"
for fs in `zpool list -H -o name` ; do for fs in `zpool list -H -o name` ; do
zpool export $force "$fs" || ret=$? zpool export $force "$fs" || ret=$?
done done
IFS="$OLDIFS"
if [ "x$final" != "x" ]; then if [ "x$final" != "x" ]; then
info "zpool list" info "zpool list"

View File

@ -3,6 +3,9 @@
. /lib/dracut-lib.sh . /lib/dracut-lib.sh
ZPOOL_FORCE="" ZPOOL_FORCE=""
OLDIFS="$IFS"
NEWLINE="
"
if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then
warn "ZFS: Will force-import pools if necessary." warn "ZFS: Will force-import pools if necessary."
@ -34,9 +37,12 @@ case "$root" in
# Re-export everything since we're not prepared to take # Re-export everything since we're not prepared to take
# responsibility for them. # responsibility for them.
zpool list -H | while read fs rest ; do # Change IFS to allow for blanks in pool names.
IFS="$NEWLINE"
for fs in `zpool list -H -o name` ; do
zpool export "$fs" zpool export "$fs"
done done
IFS="$OLDIFS"
return 1 return 1
fi fi
@ -46,11 +52,11 @@ case "$root" in
# Should have an explicit pool set, so just import it and we're done. # Should have an explicit pool set, so just import it and we're done.
zfsbootfs="${root#zfs:}" zfsbootfs="${root#zfs:}"
pool="${zfsbootfs%%/*}" pool="${zfsbootfs%%/*}"
if ! zpool list -H $pool > /dev/null ; then if ! zpool list -H "$pool" > /dev/null ; then
# pool wasn't imported automatically by the kernel module, so # pool wasn't imported automatically by the kernel module, so
# try it manually. # try it manually.
info "ZFS: Importing pool ${pool}..." info "ZFS: Importing pool ${pool}..."
if ! zpool import -N ${ZPOOL_FORCE} $pool ; then if ! zpool import -N ${ZPOOL_FORCE} "$pool" ; then
warn "ZFS: Unable to import pool ${pool}." warn "ZFS: Unable to import pool ${pool}."
rootok=0 rootok=0
@ -61,7 +67,7 @@ case "$root" in
# Above should have left our rpool imported and pool/dataset in $root. # Above should have left our rpool imported and pool/dataset in $root.
# We need zfsutil for non-legacy mounts and not for legacy mounts. # We need zfsutil for non-legacy mounts and not for legacy mounts.
mountpoint=`zfs get -H -o value mountpoint $zfsbootfs` mountpoint=`zfs get -H -o value mountpoint "$zfsbootfs"`
if [ "$mountpoint" = "legacy" ] ; then if [ "$mountpoint" = "legacy" ] ; then
mount -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes mount -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes
else else