summaryrefslogtreecommitdiff
path: root/package/base-files
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
commit1552af3131cefa5d87ff5d2400df1939c502bb29 (patch)
tree6ef97d3bdc6a6ba8cca7553bb9cbcbdd65a25122 /package/base-files
parentbc82db7d7869a2d585aa1bf561099fce966a8859 (diff)
downloadmtk-20170518-1552af3131cefa5d87ff5d2400df1939c502bb29.zip
mtk-20170518-1552af3131cefa5d87ff5d2400df1939c502bb29.tar.gz
mtk-20170518-1552af3131cefa5d87ff5d2400df1939c502bb29.tar.bz2
base-files: add mtd_find_chardev helper
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> SVN-Revision: 34648
Diffstat (limited to 'package/base-files')
-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 b3a3885..b924fce 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>] ... }