Print directly used devices

This commit is contained in:
oddlama 2020-10-03 17:59:45 +02:00
parent 627289d911
commit 6859a384f6
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
2 changed files with 34 additions and 17 deletions

View File

@ -281,6 +281,15 @@ disk_create_luks() {
|| die "Could not open luks encrypted device '$device' ($id)" || die "Could not open luks encrypted device '$device' ($id)"
} }
disk_create_dummy() {
local new_id="${arguments[new_id]}"
local device="${arguments[device]}"
if [[ $disk_action_summarize_only == "true" ]]; then
add_summary_entry __root__ "$new_id" "$device" "" ""
return 0
fi
}
init_btrfs() { init_btrfs() {
local device="$1" local device="$1"
local desc="$2" local desc="$2"
@ -391,12 +400,13 @@ apply_disk_action() {
unset known_arguments unset known_arguments
unset arguments; declare -A arguments; parse_arguments "$@" unset arguments; declare -A arguments; parse_arguments "$@"
case "${arguments[action]}" in case "${arguments[action]}" in
'create_gpt') disk_create_gpt ;; 'create_gpt') disk_create_gpt ;;
'create_partition') disk_create_partition ;; 'create_partition') disk_create_partition ;;
'create_raid') disk_create_raid ;; 'create_raid') disk_create_raid ;;
'create_luks') disk_create_luks ;; 'create_luks') disk_create_luks ;;
'format') disk_format ;; 'create_dummy') disk_create_dummy ;;
'format_btrfs') disk_format_btrfs ;; 'format') disk_format ;;
'format_btrfs') disk_format_btrfs ;;
*) echo "Ignoring invalid action: ${arguments[action]}" ;; *) echo "Ignoring invalid action: ${arguments[action]}" ;;
esac esac
} }

View File

@ -48,15 +48,6 @@ only_one_of() {
done done
} }
create_new_id_directly() {
local id="$1"
[[ $id == *';'* ]] \
&& die_trace 2 "Identifier contains invalid character ';'"
[[ ! -v DISK_ID_TO_UUID[$id] ]] \
|| die_trace 2 "Identifier '$id' already exists"
DISK_ID_TO_UUID[$id]="$(load_or_generate_uuid "$(base64 -w 0 <<< "$id")")"
}
create_new_id() { create_new_id() {
local id="${arguments[$1]}" local id="${arguments[$1]}"
[[ $id == *';'* ]] \ [[ $id == *';'* ]] \
@ -196,6 +187,23 @@ create_luks() {
DISK_ACTIONS+=("action=create_luks" "$@" ";") DISK_ACTIONS+=("action=create_luks" "$@" ";")
} }
# Named arguments:
# new_id: Id for the new luks
# device: The device
create_dummy() {
local known_arguments=('+new_id' '+device')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
create_new_id new_id
local new_id="${arguments[new_id]}"
local device="${arguments[device]}"
local uuid="${DISK_ID_TO_UUID[$new_id]}"
create_resolve_entry_device "$new_id" "$device"
DISK_ACTIONS+=("action=create_dummy" "$@" ";")
}
# Named arguments: # Named arguments:
# id: Id of the device / partition created earlier # id: Id of the device / partition created earlier
# type: One of (bios, efi, swap, ext4, btrfs) # type: One of (bios, efi, swap, ext4, btrfs)
@ -387,8 +395,7 @@ create_btrfs_raid_layout() {
for i in "${!extra_arguments[@]}"; do for i in "${!extra_arguments[@]}"; do
[[ $i != 0 ]] || continue [[ $i != 0 ]] || continue
dev_id="root_dev$i" dev_id="root_dev$i"
create_new_id_directly "$dev_id" create_dummy new_id="$dev_id" device="${extra_arguments[$i]}"
create_resolve_entry_device "$dev_id" "${extra_arguments[$i]}"
root_ids="${root_ids}$dev_id;" root_ids="${root_ids}$dev_id;"
done done
fi fi