diff options
author | Lukas Wunner <[email protected]> | 2015-02-07 11:34:22 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-02-09 10:08:43 -0800 |
commit | bf5efb5c66ac30442bded92c3299db36fe21d92f (patch) | |
tree | 095ea964a0b5d5477983be779f56f42e4a519541 /dracut | |
parent | 293d141ae4f6b2345249020b656cfc0ce007b9fa (diff) |
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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3083
Diffstat (limited to 'dracut')
-rwxr-xr-x | dracut/90zfs/export-zfs.sh.in | 6 | ||||
-rwxr-xr-x | dracut/90zfs/mount-zfs.sh.in | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/dracut/90zfs/export-zfs.sh.in b/dracut/90zfs/export-zfs.sh.in index 12300fc97..6382d762a 100755 --- a/dracut/90zfs/export-zfs.sh.in +++ b/dracut/90zfs/export-zfs.sh.in @@ -4,15 +4,21 @@ _do_zpool_export() { local ret=0 local final=$1 local force + local OLDIFS="$IFS" + local NEWLINE=" +" if [ "x$final" != "x" ]; then force="-f" fi 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 zpool export $force "$fs" || ret=$? done + IFS="$OLDIFS" if [ "x$final" != "x" ]; then info "zpool list" diff --git a/dracut/90zfs/mount-zfs.sh.in b/dracut/90zfs/mount-zfs.sh.in index ca4e46614..1fb4ea537 100755 --- a/dracut/90zfs/mount-zfs.sh.in +++ b/dracut/90zfs/mount-zfs.sh.in @@ -3,6 +3,9 @@ . /lib/dracut-lib.sh ZPOOL_FORCE="" +OLDIFS="$IFS" +NEWLINE=" +" if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then 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 # 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" done + IFS="$OLDIFS" return 1 fi @@ -46,11 +52,11 @@ case "$root" in # Should have an explicit pool set, so just import it and we're done. zfsbootfs="${root#zfs:}" 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 # try it manually. 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}." rootok=0 @@ -61,7 +67,7 @@ case "$root" in # Above should have left our rpool imported and pool/dataset in $root. # 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 mount -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes else |