Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: zfsboot
- ===================================================================
- --- zfsboot (revision 339885)
- +++ zfsboot (working copy)
- @@ -238,16 +238,23 @@ ZPOOL_SET='zpool set %s "%s"'
- hline_alnum_arrows_punc_tab_enter="Use alnum, arrows, punctuation, TAB or ENTER"
- hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
- hline_arrows_tab_enter="Press arrows, TAB or ENTER"
- +msg_add="Add"
- msg_an_unknown_error_occurred="An unknown error occurred"
- msg_back="Back"
- msg_cancel="Cancel"
- msg_change_selection="Change Selection"
- msg_configure_options="Configure Options:"
- +msg_dataset_plural="datasets"
- +msg_dataset_singular="dataset"
- +msg_datasets="Datasets"
- msg_detailed_disk_info="gpart(8) show %s:\n%s\n\ncamcontrol(8) inquiry %s:\n%s\n\n\ncamcontrol(8) identify %s:\n%s\n"
- msg_disk_info="Disk Info"
- msg_disk_info_help="Get detailed information on disk device(s)"
- msg_disk_plural="disks"
- msg_disk_singular="disk"
- +msg_edit="Edit"
- +msg_edit_datasets_help="Edit ZFS datasets and their options"
- +msg_edit_zfs_datasets="Edit ZFS datasets:"
- msg_encrypt_disks="Encrypt Disks?"
- msg_encrypt_disks_help="Use geli(8) to encrypt all data partitions"
- msg_error="Error"
- @@ -279,6 +286,7 @@ msg_null_index_argument="NULL index argument"
- msg_null_poolname="NULL poolname"
- msg_odd_disk_selected="An even number of disks must be selected to create a RAID 1+0. (%u selected)"
- msg_ok="OK"
- +msg_options="Options"
- msg_partition_scheme="Partition Scheme"
- msg_partition_scheme_help="Select partitioning scheme. GPT is recommended."
- msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:"
- @@ -289,6 +297,7 @@ msg_pool_name_cannot_be_empty="Pool name cannot be
- msg_pool_name_help="Customize the name of the zpool to be created (Required)"
- msg_pool_type_disks="Pool Type/Disks:"
- msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)"
- +msg_previous_menu="Previous menu"
- msg_processing_selection="Processing selection..."
- msg_raid10_desc="RAID 1+0 - n x 2-Way Mirrors"
- msg_raid10_help="[4+ Disks] Striped Mirrors provides the best performance, but the least storage"
- @@ -298,8 +307,10 @@ msg_raidz2_desc="RAID-Z2 - Double Redundant RAID"
- msg_raidz2_help="[4+ Disks] Withstand failure of 2 disks. Recommended for: 4, 6 or 10 disks"
- msg_raidz3_desc="RAID-Z3 - Triple Redundant RAID"
- msg_raidz3_help="[5+ Disks] Withstand failure of 3 disks. Recommended for: 5, 7 or 11 disks"
- +msg_remove="Remove"
- msg_rescan_devices="Rescan Devices"
- msg_rescan_devices_help="Scan for device changes"
- +msg_reset_defaults="Reset Defaults"
- msg_select="Select"
- msg_select_a_disk_device="Select a disk device"
- msg_select_virtual_device_type="Select Virtual Device type:"
- @@ -339,15 +350,27 @@ dialog_menu_main()
- [ "$ZFSBOOT_GELI_ENCRYPTION" ] && usegeli="$msg_yes"
- [ "$ZFSBOOT_SWAP_ENCRYPTION" ] && swapgeli="$msg_yes"
- [ "$ZFSBOOT_SWAP_MIRROR" ] && swapmirror="$msg_yes"
- - local disks n disks_grammar
- - f_count n $ZFSBOOT_DISKS
- - { [ $n -eq 1 ] && disks_grammar=$msg_disk_singular; } ||
- + local disks ndisks disks_grammar
- + f_count ndisks $ZFSBOOT_DISKS
- + { [ $ndisks -eq 1 ] && disks_grammar=$msg_disk_singular; } ||
- disks_grammar=$msg_disk_plural # grammar
- + local ndatasets dataset_grammar
- + ndatasets=$( echo "$ZFSBOOT_DATASETS" | {
- + n=0
- + while read dataset options; do
- + # Skip blank lines and comments
- + case "$dataset" in "#"*|"") continue; esac
- + n=$(( $n + 1 ))
- + done
- + echo $n
- + } )
- + { [ $ndatasets -eq 1 ] && dataset_grammar=$msg_dataset_singular; } ||
- + dataset_grammar=$msg_dataset_plural # grammar
- local menu_list="
- '>>> $msg_install' '$msg_install_desc'
- '$msg_install_help'
- 'T $msg_pool_type_disks'
- - '$ZFSBOOT_VDEV_TYPE: $n $disks_grammar'
- + '$ZFSBOOT_VDEV_TYPE: $ndisks $disks_grammar'
- '$msg_pool_type_disks_help'
- '- $msg_rescan_devices' '*'
- '$msg_rescan_devices_help'
- @@ -369,6 +392,8 @@ dialog_menu_main()
- '$msg_swap_mirror_help'
- 'W $msg_swap_encrypt' '$swapgeli'
- '$msg_swap_encrypt_help'
- + 'D $msg_datasets' '$msg_edit $ndatasets $dataset_grammar'
- + '$msg_edit_datasets_help'
- " # END-QUOTE
- local defaultitem= # Calculated below
- local hline="$hline_alnum_arrows_punc_tab_enter"
- @@ -1554,6 +1579,120 @@ dialog_menu_diskinfo()
- return $SUCCESS
- }
- +# dialog_menu_datasets
- +#
- +# Present a menu allowing the user to view, add, remove, and modify datasets.
- +#
- +dialog_menu_datasets()
- +{
- + local funcname=dialog_menu_datasets
- + local title="$DIALOG_TITLE"
- + local btitle="$DIALOG_BACKTITLE"
- + local prompt="$msg_edit_zfs_datasets"
- + local menu_list
- + local defaultitem= # Calculated below
- + local hline="$hline_alnum_arrows_punc_tab_enter"
- +
- + menu_list="
- + '<<< $msg_back' '$msg_previous_menu'
- + '> $msg_add' '$msg_datasets/$msg_options'
- + '> $msg_remove' '$msg_datasets/$msg_options'
- + '! $msg_reset_defaults' '*'
- + '---' '---'
- + $( echo "$ZFSBOOT_DATASETS" | while read dataset options; do
- + # Skip blank lines and comments
- + [ "$dataset" ] || continue
- + [ "$dataset" = "${dataset#\#}" ] || continue
- + printf "dataset=%s\n" "$dataset"
- + printf "\t%s\n" "$options"
- + printf "\n"
- + done | awk '
- + BEGIN {
- + ndatasets = 0
- + delete dataset
- + delete dataset_opt
- + }
- + function mprint(tag, item) {
- + gsub(/'\''/, "&\\\\&&", tag)
- + gsub(/'\''/, "&\\\\&&", item)
- + printf "'\''%s'\'' '\''%s'\''\n", tag, item
- + }
- + function _asorti(src, dest)
- + {
- + k = nitems = 0
- + for (i in src) dest[++nitems] = i
- + for (i = 1; i <= nitems; k = i++) {
- + idx = dest[i]
- + while ((k > 0) && (dest[k] > idx)) {
- + dest[k+1] = dest[k]; k--
- + }
- + dest[k+1] = idx
- + }
- + return nitems
- + }
- + sub(/^dataset=/, "") {
- + dataset[d = $0]
- + getline options
- + # Remove leading whitespace
- + sub(/^[[:space:]]*/, "", options)
- + # Remove potential inline comments
- + sub(/#.*/, "", options)
- + # Reduce contiguous whitespace to one single space
- + gsub(/[[:space:]]+/, " ", options)
- + dataset_opt[d] = options
- + }
- + END {
- + ndatasets = _asorti(dataset, dataset_list)
- + delete klist
- + for (n = 1; n <= ndatasets; n++) {
- + d = k = dataset_list[n]
- + if (d ~ "^/ROOT(/.*)?$") {
- + k = "/"
- + } else {
- + sub("^/*", "", k)
- + k = toupper(substr(k, 1, 1))
- + }
- + klist[k d]
- + }
- + delete kseen
- + delete sorted_klist
- + ndatasets = _asorti(klist, sorted_klist)
- + for (n = 1; n <= ndatasets; n++) {
- + k = substr(sorted_klist[n], 1, 1)
- + d = substr(sorted_klist[n], 2)
- + if (k in kseen) {
- + k = "-"
- + } else {
- + kseen[k]
- + }
- + mprint(sprintf("%c %s", k, d), dataset_opt[d])
- + }
- + }
- + ' 2>&3 )"
- +
- + local height width rows
- + eval f_dialog_menu_size height width rows \
- + \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" $menu_list
- +
- + local menu_choice
- + menu_choice=$( eval $DIALOG \
- + --title \"\$title\" \
- + --backtitle \"\$btitle\" \
- + --hline \"\$hline\" \
- + --ok-label \"\$msg_select\" \
- + --cancel-label \"\$msg_cancel\" \
- + --default-item \"\$defaultitem\" \
- + --menu \"\$prompt\" \
- + $height $width $rows \
- + $menu_list \
- + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- + )
- + local retval=$?
- + f_dialog_data_sanitize menu_choice
- +
- + return $retval
- +}
- +
- ############################################################ MAIN
- #
- @@ -1792,6 +1931,9 @@ while :; do
- ZFSBOOT_SWAP_ENCRYPTION=1
- fi
- ;;
- + ?" $msg_datasets")
- + # Present a menu to edit datasets and their options
- + dialog_menu_datasets
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement