aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-12-12 16:49:50 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-12-12 16:49:50 +0000
commita38aced95802ab81994c86d353438b57bd9bc386 (patch)
treebfb29bc1cd2c1deb39b00a6e171dd21c795df3f6 /package
parentf267d32f09aaed4be5a9f6472441615f4f9f5907 (diff)
downloadupstream-a38aced95802ab81994c86d353438b57bd9bc386.tar.gz
upstream-a38aced95802ab81994c86d353438b57bd9bc386.tar.bz2
upstream-a38aced95802ab81994c86d353438b57bd9bc386.zip
base-files: add mtd_find_chardev helper
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34648 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh20
1 files changed, 17 insertions, 3 deletions
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() { # <string> { <variable> [<separator>] ... }