summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdinstall/scripts
diff options
context:
space:
mode:
authorallanjude <allanjude@FreeBSD.org>2015-05-05 03:08:49 +0000
committerallanjude <allanjude@FreeBSD.org>2015-05-05 03:08:49 +0000
commit9f65bd95656d108012dfd35a491ecf8c04a48a8c (patch)
treef9902798cb76ee90187a5783be5a0ae65a8e1446 /usr.sbin/bsdinstall/scripts
parent8e5a92abe85f2d44d7b1e8d3b71859a37e6677ad (diff)
downloadFreeBSD-src-9f65bd95656d108012dfd35a491ecf8c04a48a8c.zip
FreeBSD-src-9f65bd95656d108012dfd35a491ecf8c04a48a8c.tar.gz
Add a sanity check to the swap size in zfsboot of bsdinstall
Loop until the user enters a valid size (>100mb or 0) Differential Revision: https://reviews.freebsd.org/D2299 Reported By: Shawn Webb Reviewed by: roberto Approved by: brd MFC after: 2 weeks Sponsored by: ScaleEngine Inc.
Diffstat (limited to 'usr.sbin/bsdinstall/scripts')
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot26
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index eb90b8c..7fa5cd3 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -287,10 +287,12 @@ msg_stripe_desc="Stripe - No Redundancy"
msg_stripe_help="[1+ Disks] Striping provides maximum storage but no redundancy"
msg_swap_encrypt="Encrypt Swap?"
msg_swap_encrypt_help="Encrypt swap partitions with temporary keys, discarded on reboot"
+msg_swap_invalid="The selected swap size (%s) is invalid. Enter a number optionally followed by units. Example: 2G"
msg_swap_mirror="Mirror Swap?"
msg_swap_mirror_help="Mirror swap partitions for redundancy, breaks crash dumps"
msg_swap_size="Swap Size"
msg_swap_size_help="Customize how much swap space is allocated to each selected disk"
+msg_swap_toosmall="The selected swap size (%s) is to small. Please enter a value greater than 100MB or enter 0 for no swap"
msg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 50%% or more of each of the following selected disk\ndevices (not recommended):\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices."
msg_uefi_not_supported="The FreeBSD UEFI loader does not currently support booting root-on-ZFS. Your system will need to boot in legacy (CSM) mode.\nDo you want to continue?"
msg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'"
@@ -1557,10 +1559,26 @@ while :; do
;;
?" $msg_swap_size")
# Prompt the user to input/change the swap size for each disk
- f_dialog_input input \
- "$msg_please_enter_amount_of_swap_space" \
- "$ZFSBOOT_SWAP_SIZE" &&
- ZFSBOOT_SWAP_SIZE="${input:-0}"
+ while :; do
+ f_dialog_input input \
+ "$msg_please_enter_amount_of_swap_space" \
+ "$ZFSBOOT_SWAP_SIZE" &&
+ ZFSBOOT_SWAP_SIZE="${input:-0}"
+ if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
+ then
+ if [ $swapsize -ne 0 -a $swapsize -lt 104857600 ]; then
+ f_show_err "$msg_swap_toosmall" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ else
+ break;
+ fi
+ else
+ f_show_err "$msg_swap_invalid" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ fi
+ done
;;
?" $msg_swap_mirror")
# Toggle the variable referenced both by the menu and later
OpenPOWER on IntegriCloud