From b5b8c4b725510ddfeed8065ab652ebb2857e5101 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 3 Jul 2018 02:57:57 +0800 Subject: [PATCH] First find blocks by-name, then fallback to parsing sysfs --- scripts/util_functions.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 3d1c04f2f..99672e565 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -45,6 +45,14 @@ toupper() { } 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 local DEVNAME=`grep_prop DEVNAME $uevent` local PARTNAME=`grep_prop PARTNAME $uevent`