Skip to content

Commit

Permalink
zfs-chroot: add read-write prompt
Browse files Browse the repository at this point in the history
When entering a chroot for a regular dataset and the pool is read-only,
provide a timed_prompt that lets the user choose between entering a
read-only chroot (return key/enter key) or a read-write chroot (escape
key). If the dataset is a snapshot or the pool is already read-write, do
not show the prompt.

Fixes #428
  • Loading branch information
zdykstra committed Oct 13, 2023
1 parent 09e4d76 commit 7b3dcc1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions zfsbootmenu/bin/zfs-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,24 @@ selected="${1}"
zdebug "started with ${selected}"

[ -n "${selected}" ] || exit 0
pool="${selected%%/*}"

if ! is_snapshot "${selected}" && ! is_writable "${pool}" ; then
if ! timed_prompt -d 10 \
-e "Enter r/w chroot" \
-r "Enter r/o chroot" \
-p "Entering chroot in $( colorize yellow "%0.2d" ) seconds" ; then
set_rw_pool "${pool}"
fi
fi

clear

if ! mountpoint="$( allow_rw=yes mount_zfs "${selected}" )"; then
zerror "failed to mount ${selected}"
exit 1
fi

pool="${selected%%/*}"

# Snapshots and read-only pools always produce read-only mounts
if is_snapshot "${selected}" || ! is_writable "${pool}"; then
writemode="$( colorize green "read-only")"
Expand Down

0 comments on commit 7b3dcc1

Please sign in to comment.