Skip to content

Commit 7879876

Browse files
committed
Read-only helpers
Add an alt-w helper to the main screen to set a pool r/w Show r/o or r/w in the preview header for a selected pool (extracted from a BE)
1 parent 12a04ff commit 7879876

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

90zfsbootmenu/zfsbootmenu-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ draw_be() {
5757
test -f "${env}" || return 130
5858

5959
selected="$( ${FUZZYSEL} -0 --prompt "BE > " \
60-
--expect=alt-k,alt-d,alt-s,alt-c,alt-r,alt-p \
60+
--expect=alt-k,alt-d,alt-s,alt-c,alt-r,alt-p,alt-w \
6161
--preview-window="up:${PREVIEW_HEIGHT}" \
6262
--header="[ENTER] boot [ALT+K] kernel [ALT+D] set bootfs [ALT+S] snapshots [ALT+C] cmdline [ALT+P] Pool status" \
6363
--preview="zfsbootmenu-preview.sh ${BASE} {} ${BOOTFS}" < "${env}" )"

90zfsbootmenu/zfsbootmenu-preview.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ do
2525
selected_arguments="${line}"
2626
done <<< "${BE_ARGS}"
2727

28+
pool="${ENV%%/*}"
29+
readonly_prop="$( zpool get -H -o value readonly "${pool}" )"
30+
[[ ${readonly_prop} = "on" ]] && _readonly="r/o" || _readonly="r/w"
31+
2832
if [[ "${BOOTFS}" =~ ${ENV} ]]; then
29-
selected_env_str="${ENV} (default) - ${selected_kernel}"
33+
selected_env_str="${ENV} (default, ${_readonly}) - ${selected_kernel}"
3034
else
31-
selected_env_str="${ENV} - ${selected_kernel}"
35+
selected_env_str="${ENV} (${_readonly}) - ${selected_kernel}"
3236
fi
3337

3438
if [ -z "${FZF_PREVIEW_COLUMNS}" ]

90zfsbootmenu/zfsbootmenu.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ while true; do
344344
"alt-r")
345345
emergency_shell "alt-r invoked"
346346
;;
347+
"alt-w")
348+
pool="${selected_be%%/*}"
349+
if set_rw_pool "${pool}"; then
350+
CLEAR_SCREEN=1 key_wrapper "${pool}"
351+
fi
352+
;;
347353
"alt-c")
348354
tput clear
349355
tput cnorm

0 commit comments

Comments
 (0)