From: Gabor Juhos Date: Wed, 12 Dec 2012 16:49:50 +0000 (+0000) Subject: base-files: add mtd_find_chardev helper X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1552af3131cefa5d87ff5d2400df1939c502bb29;p=openwrt%2Fstaging%2Faparcar.git base-files: add mtd_find_chardev helper Signed-off-by: Gabor Juhos SVN-Revision: 34648 --- diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index b3a3885f2d..b924fce285 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -220,13 +220,27 @@ include() { done } -find_mtd_part() { +find_mtd_index() { local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local INDEX="${PART##mtd}" + + echo ${INDEX} +} + +find_mtd_part() { + local INDEX=$(find_mtd_index "$1") local PREFIX=/dev/mtdblock - PART="${PART##mtd}" [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ - echo "${PART:+$PREFIX$PART}" + echo "${INDEX:+$PREFIX$INDEX}" +} + +find_mtd_chardev() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtd + + [ -d /dev/mtd ] && PREFIX=/dev/mtd/ + echo "${INDEX:+$PREFIX$INDEX}" } strtok() { # { [] ... }