From 8af024aa763b6e838a869bbee3a1a732f1be65c5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 19 Oct 2022 17:10:22 +0200 Subject: [dev] Support >= 10 partitions --- modules/dev.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/dev.inc b/modules/dev.inc index 0b27eff..13b042f 100644 --- a/modules/dev.inc +++ b/modules/dev.inc @@ -55,7 +55,7 @@ dev_find_partitions() { # This only makes sense if called within this script, or if slx-tools # was sourced, otherwise the variables will be inaccessible. dev_get_type() { - local part dev partn devn pstart + local part dev partn devlist devn pstart dev= mbrid= uuid= @@ -64,8 +64,10 @@ dev_get_type() { [ -b "$1" ] || return 1 part="$( readlink -f "$1" )" partn="${part##*/}" - for devn in "${partn%p?}" "${partn%?}"; do - if [ "$dev" != "$part" ] && [ -f "/sys/block/${devn}/${partn}/uevent" ]; then + devlist="$( printf "%s" "$partn" | sed -r 's/[0-9]+$//' )" + [ "$partn" = "$devlist" ] && return 1 + for devn in "${devlist}" "${devlist%p}"; do + if [ -f "/sys/block/${devn}/${partn}/uevent" ]; then dev="/dev/${devn}" break fi -- cgit v1.2.3-55-g7522