From bf484cd8a5823a216ecf9c7f7525a1819144baf7 Mon Sep 17 00:00:00 2001 From: "Jason R. McNeil" Date: Wed, 10 Apr 2013 20:33:22 -0700 Subject: [PATCH] Find dataset when multiple pools exist on boot If the `zfs` kernel parameter is set to `bootfs` and multiple pools are available, check each pool for the bootfs property. As far as I am aware, there are only three possible strings that might be returned by `zpool list -H -o bootfs`, an empty string, `-`, and a dataset name. If this is not the case this change has the potential to break existing systems. --- devsrc/zfs-utils/zfs-utils.initcpio.hook | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/devsrc/zfs-utils/zfs-utils.initcpio.hook b/devsrc/zfs-utils/zfs-utils.initcpio.hook index 3a6bfdd..7dd1e82 100644 --- a/devsrc/zfs-utils/zfs-utils.initcpio.hook +++ b/devsrc/zfs-utils/zfs-utils.initcpio.hook @@ -1,10 +1,21 @@ ZPOOL_FORCE="" zfs_get_bootfs () { - ZFS_DATASET=`/usr/sbin/zpool list -H -o bootfs | sed 'q'` - if [ "$?" != "0" ] || [ "$ZFS_DATASET" = "" ] || [ "$ZFS_DATASET" = "no pools available" ] ; then - return 1 - fi + for zfs_dataset in $(/usr/sbin/zpool list -H -o bootfs); do + case ${zfs_dataset} in + "" | "-") + # skip this line/dataset + ;; + "no pools available") + return 1 + ;; + *) + ZFS_DATASET=${zfs_dataset} + return 0 + ;; + esac + done + return 1 } zfs_mount_handler () {