Skip to content

Commit

Permalink
Respect the rw/ro kernel cmdline option.
Browse files Browse the repository at this point in the history
Also pipe the zpool list failure to /dev/null.
  • Loading branch information
clefru committed Apr 1, 2014
1 parent 0fdfde1 commit 2ba6481
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions zfs-utils/zfs-utils.initcpio.hook
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,28 @@ zfs_mount_handler () {
fi

local pool="${ZFS_DATASET%%/*}"
if ! "/usr/bin/zpool" list -H $pool > /dev/null ; then
echo "ZFS: Importing pool $pool."
local zpool_import_flags=""
local rwopt_exp=${rwopt:-ro}

if ! "/usr/bin/zpool" import -N $pool $ZPOOL_FORCE ; then
if ! "/usr/bin/zpool" list -H $pool 2>&1 > /dev/null ; then
if [ "$rwopt_exp" != "rw" ]; then
msg "ZFS: Importing pool $pool readonly."
zpool_import_flags="-o readonly=on"
else
msg "ZFS: Importing pool $pool."
fi

if ! "/usr/bin/zpool" import $zpool_import_flags -N $pool $ZPOOL_FORCE ; then
echo "ZFS: Unable to import pool $pool."
return 1
fi
fi

local mountpoint=$("/usr/bin/zfs" get -H -o value mountpoint $ZFS_DATASET)
if [ "$mountpoint" = "legacy" ] ; then
mount -t zfs "$ZFS_DATASET" "$node"
mount -t zfs -o ${rwopt_exp} "$ZFS_DATASET" "$node"
else
mount -o zfsutil -t zfs "$ZFS_DATASET" "$node"
mount -o zfsutil,${rwopt_exp} -t zfs "$ZFS_DATASET" "$node"
fi
}

Expand Down

0 comments on commit 2ba6481

Please sign in to comment.