[openwrt/openwrt] base-files: allow specifiying rootdev for find_mmc_part

LEDE Commits lede-commits at lists.infradead.org
Mon Nov 1 11:22:25 PDT 2021


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/9f223a20bd5f0cbec9f34427588b645ae38433ff

commit 9f223a20bd5f0cbec9f34427588b645ae38433ff
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Mon Nov 1 13:58:20 2021 +0000

    base-files: allow specifiying rootdev for find_mmc_part
    
    Some devices got more than one mmc device.
    Allow specifying the root device as 2nd parameter of find_mmc_part so
    scripts can avoid matching irrelevant partitions on wrong mmc device.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 package/base-files/files/lib/functions.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index e56e4637f0..ee0c33845c 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -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



More information about the lede-commits mailing list