diff options
-rw-r--r-- | modules/dev.inc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/dev.inc b/modules/dev.inc index 4f0ee51..ce58075 100644 --- a/modules/dev.inc +++ b/modules/dev.inc @@ -74,6 +74,7 @@ dev_get_type() { pstart="$( cat "/sys/block/${devn}/${partn}/start" )" # For validation label="$( grep -Po '(?<=^PARTNAME=).*$' "/sys/block/${devn}/${partn}/uevent" )" number="$( grep -Po '(?<=^PARTN=).*$' "/sys/block/${devn}/${partn}/uevent" )" + number="$( cat "/sys/block/${devn}/${partn}/partition" )" local gpt= if [ "$( dd if="$dev" bs=1 count=8 skip=512 )" = "EFI PART" ]; then gpt=512 @@ -145,7 +146,7 @@ dev_get_type() { fi if [ -n "$gpt" ]; then # GPT - local table_start current entries no entry_size log_start + local table_start current entries no entry_size log_start readoff num byte table_start="$( __read_le "$dev" "$(( gpt + 72 ))" 8 )" entries="$( __read_le "$dev" "$(( gpt + 80 ))" 4 )" entry_size="$( __read_le "$dev" "$(( gpt + 84 ))" 4 )" @@ -163,6 +164,19 @@ dev_get_type() { # Convert raw hex stream to proper string representation. First 3 groups are little endian. uuid="$( dd if="$dev" bs=1 count=16 skip="$(( current + entry_size * (number - 1) ))" 2> /dev/null \ | __bin2hex | sed -r 's/^(..)(..)(..)(..)(..)(..)(..)(..)(....)/\4\3\2\1-\6\5-\8\7-\9-/' )" + if [ -z "$label" ]; then + readoff="$(( current + entry_size * (number - 1) + 56 ))" + num=0 + while [ "$num" -lt 36 ]; do + byte="$( __read_le "$dev" "$readoff" "1" )" + if [ "$byte" -ge 32 ] && [ "$byte" -le 126 ]; then + byte="$( dd if="$dev" bs=1 count="1" skip="$readoff" 2> /dev/null )" + label="$label$byte" + fi + readoff=$(( readoff + 2 )) + num=$(( num + 1 )) + done + fi return 0 fi # Unknown |