base-files: allow specifiying rootdev for find_mmc_part
[openwrt/openwrt.git] / package / base-files / files / lib / functions.sh
index e56e4637f0116f9f4e7fdf31f47ab77a47f5f75e..ee0c33845c508790578524c06cc3fc50450e3e58 100644 (file)
@@ -331,13 +331,19 @@ find_mtd_part() {
 }
 
 find_mmc_part() {
-       local DEVNAME PARTNAME
+       local DEVNAME PARTNAME ROOTDEV
 
        if grep -q "$1" /proc/mtd; then
                echo "" && return 0
        fi
 
-       for DEVNAME in /sys/block/mmcblk*/mmcblk*p*; do
+       if [ -n "$2" ]; then
+               ROOTDEV="$2"
+       else
+               ROOTDEV="mmcblk*"
+       fi
+
+       for DEVNAME in /sys/block/$ROOTDEV/mmcblk*p*; do
                PARTNAME="$(grep PARTNAME ${DEVNAME}/uevent | cut -f2 -d'=')"
                [ "$PARTNAME" = "$1" ] && echo "/dev/$(basename $DEVNAME)" && return 0
        done