]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix Dracut scripts to allow for blanks in pool and dataset names
authorLukas Wunner <lukas@wunner.de>
Sat, 7 Feb 2015 10:34:22 +0000 (11:34 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 9 Feb 2015 18:08:43 +0000 (10:08 -0800)
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

dracut/90zfs/export-zfs.sh.in
dracut/90zfs/mount-zfs.sh.in

index 12300fc976ce223bd3c4bdb26be289b069107971..6382d762aa9783f81b51ab034d887a054b1e81d1 100755 (executable)
@@ -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"
index ca4e46614d69c8f49ccb822e9615c4e8861b0930..1fb4ea537ec96b5fcf8e9c9245a7b9912eefc58e 100755 (executable)
@@ -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