base-files: add mtd_get_part_size helper
authorGabor Juhos <juhosg@openwrt.org>
Sat, 20 Jul 2013 09:25:49 +0000 (09:25 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 20 Jul 2013 09:25:49 +0000 (09:25 +0000)
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 37475

package/base-files/Makefile
package/base-files/files/lib/functions.sh

index 3bdb0a8d3ffa1e0349b1d96bb12ec13fc0df3308..9c226c40afc9052f49e4556fd23cb845b8548373 100644 (file)
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=142
+PKG_RELEASE:=143
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
index bc521b07ee0c906ac5fc4ebff0e20a2efbcf76af..19cfbae172a00730db80383386399f9eca1afe80 100755 (executable)
@@ -275,6 +275,18 @@ mtd_get_mac_binary() {
        dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
 }
 
+mtd_get_part_size() {
+       local part_name=$1
+       local first dev size erasesize name
+       while read dev size erasesize name; do
+               name=${name#'"'}; name=${name%'"'}
+               if [ "$name" = "$part_name" ]; then
+                       echo $((0x$size))
+                       break
+               fi
+       done < /proc/mtd
+}
+
 macaddr_add() {
        local mac=$1
        local val=$2