X-Git-Url: https://git.archive.openwrt.org/?p=openwrt.git;a=blobdiff_plain;f=package%2Fbase-files%2Ffiles%2Flib%2Ffunctions.sh;h=6f23e0b8b2ea57fedc0cf3ae8d1f300e843a1516;hp=85ebc2aeb16143826ca07c82579d4a4970e1bd70;hb=1cd654611f450bd2ce579590a9118e7c84712587;hpb=0eed0af1d6d697a9fd82271544cfb3e38062861f;ds=inline diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 85ebc2aeb1..6f23e0b8b2 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -260,6 +260,26 @@ mtd_get_mac_ascii() [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" } +mtd_get_blob() +{ + local mtdname="$1" + local offset="$2" + local count="$3" + local firmware="$4" + local part + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_blob: partition $mtdname not found!" >&2 + return 1 + fi + + dd if=$part of=$firmware bs=1 skip=$offset count=$count 2>/dev/null || { + echo "mtd_get_blob: failed to extract $firmware from $part" >&2 + return 1 + } +} + mtd_get_mac_binary() { local mtdname="$1" local offset="$2"