base-files: add function to get binary mac from file
Add a fucntion to get the a binary mac address from file. Use the new function for mtd_get_mac_binary() to limit duplicate code. Signed-off-by: Mathias Kresin <dev@kresin.me>
This commit is contained in:
parent
87c42101cf
commit
64fef8f901
1 changed files with 13 additions and 6 deletions
|
@ -1,5 +1,17 @@
|
||||||
# Copyright (C) 2006-2013 OpenWrt.org
|
# Copyright (C) 2006-2013 OpenWrt.org
|
||||||
|
|
||||||
|
get_mac_binary() {
|
||||||
|
local path="$1"
|
||||||
|
local offset="$2"
|
||||||
|
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
echo "get_mac_binary: file $path not found!" >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
find_mtd_chardev() {
|
find_mtd_chardev() {
|
||||||
local INDEX=$(find_mtd_index "$1")
|
local INDEX=$(find_mtd_index "$1")
|
||||||
local PREFIX=/dev/mtd
|
local PREFIX=/dev/mtd
|
||||||
|
@ -33,12 +45,7 @@ mtd_get_mac_binary() {
|
||||||
local part
|
local part
|
||||||
|
|
||||||
part=$(find_mtd_part "$mtdname")
|
part=$(find_mtd_part "$mtdname")
|
||||||
if [ -z "$part" ]; then
|
get_mac_binary "$part" "$offset"
|
||||||
echo "mtd_get_mac_binary: partition $mtdname not found!" >&2
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $part 2>/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mtd_get_mac_binary_ubi() {
|
mtd_get_mac_binary_ubi() {
|
||||||
|
|
Loading…
Reference in a new issue