Commit b5b8c4b7 authored by topjohnwu's avatar topjohnwu

First find blocks by-name, then fallback to parsing sysfs

parent 6c4d81b1
...@@ -45,6 +45,14 @@ toupper() { ...@@ -45,6 +45,14 @@ toupper() {
} }
find_block() { find_block() {
for BLOCK in "$@"; do
DEVICE=`find /dev/block -type l -iname $BLOCK | head -n 1` 2>/dev/null
if [ ! -z $DEVICE ]; then
readlink -f $DEVICE
return 0
fi
done
# Fallback by parsing sysfs uevents
for uevent in /sys/dev/block/*/uevent; do for uevent in /sys/dev/block/*/uevent; do
local DEVNAME=`grep_prop DEVNAME $uevent` local DEVNAME=`grep_prop DEVNAME $uevent`
local PARTNAME=`grep_prop PARTNAME $uevent` local PARTNAME=`grep_prop PARTNAME $uevent`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment