1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-07-01 01:18:54 +03:00

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
This commit is contained in:
juhosg 2012-12-12 16:49:50 +00:00
parent 5c04be0b52
commit ab15bfa483

View File

@ -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>] ... }