Skip to content

Commit

Permalink
fix(crypt): move devnames function from base module to crypt
Browse files Browse the repository at this point in the history
  • Loading branch information
LaszloGombos committed Feb 21, 2023
1 parent f3a7172 commit 3eeff0e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
40 changes: 40 additions & 0 deletions modules.d/90crypt/crypt-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

command -v getarg > /dev/null || . /lib/dracut-lib.sh

# Get kernel name for given device. Device may be the name too (then the same
# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label
# (prefixed with "LABEL="). If just a beginning of the UUID is specified or
# even an empty, function prints all device names which UUIDs match - every in
# single line.
#
# NOTICE: The name starts with "/dev/".
#
# Example:
# devnames UUID=123
# May print:
# /dev/dm-1
# /dev/sdb1
# /dev/sdf3
devnames() {
local dev="$1"
local d
local names

case "$dev" in
UUID=*)
# shellcheck disable=SC2016
dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
&& return 255
[ -z "$dev" ] && return 255
;;
LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
/dev/?*) ;;
*) return 255 ;;
esac

for d in $dev; do
names="$names
$(readlink -e -q "$d")" || return 255
done

echo "${names#
}"
}

# check if the crypttab contains an entry for a LUKS UUID
crypttab_contains() {
local luks="$1"
Expand Down
40 changes: 0 additions & 40 deletions modules.d/99base/dracut-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -694,46 +694,6 @@ foreach_uuid_until() (
return 1
)

# Get kernel name for given device. Device may be the name too (then the same
# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label
# (prefixed with "LABEL="). If just a beginning of the UUID is specified or
# even an empty, function prints all device names which UUIDs match - every in
# single line.
#
# NOTICE: The name starts with "/dev/".
#
# Example:
# devnames UUID=123
# May print:
# /dev/dm-1
# /dev/sdb1
# /dev/sdf3
devnames() {
local dev="$1"
local d
local names

case "$dev" in
UUID=*)
# shellcheck disable=SC2016
dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
&& return 255
[ -z "$dev" ] && return 255
;;
LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;;
/dev/?*) ;;
*) return 255 ;;
esac

for d in $dev; do
names="$names
$(readlink -e -q "$d")" || return 255
done

echo "${names#
}"
}

usable_root() {
local _i

Expand Down

0 comments on commit 3eeff0e

Please sign in to comment.