rpcd: iwinfo plugin fixes
[openwrt/svn-archive/archive.git] / package / base-files / files / lib / functions / system.sh
index 76554601595c7cd3a251fe4c387857d68500e800..35f6d10fdb2bb93d95e4502d7657fcc1a713e55d 100644 (file)
@@ -1,12 +1,5 @@
 # Copyright (C) 2006-2013 OpenWrt.org
 
-find_mtd_index() {
-       local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
-       local INDEX="${PART##mtd}"
-
-       echo ${INDEX}
-}
-
 find_mtd_chardev() {
        local INDEX=$(find_mtd_index "$1")
        local PREFIX=/dev/mtd
@@ -45,7 +38,24 @@ mtd_get_mac_binary() {
                return
        fi
 
-       dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
+       hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $part 2>/dev/null
+}
+
+mtd_get_mac_binary_ubi() {
+       local mtdname="$1"
+       local offset="$2"
+
+       . /lib/upgrade/nand.sh
+
+       local ubidev=$(nand_find_ubi $CI_UBIPART)
+       local part=$(nand_find_volume $ubidev $1)
+
+       if [ -z "$part" ]; then
+               echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2
+               return
+       fi
+
+       hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null
 }
 
 mtd_get_part_size() {
@@ -89,6 +99,7 @@ macaddr_canonicalize()
        local mac="$1"
        local canon=""
 
+       mac=$(echo -n $mac | tr -d \")
        [ ${#mac} -gt 17 ] && return
        [ -n "${mac//[a-fA-F0-9\.: -]/}" ] && return