mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
base-files: add mmc_get_mac_ascii function
Similar to the *_get_mac_binary function, also split the common parts off mtd_get_mac_ascii into new get_mac_ascii function and introduce mmc_get_mac_ascii which uses it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
c7ee906425
commit
46583553b7
@ -61,11 +61,21 @@ find_mtd_chardev() {
|
|||||||
echo "${INDEX:+$PREFIX$INDEX}"
|
echo "${INDEX:+$PREFIX$INDEX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_mac_ascii() {
|
||||||
|
local part="$1"
|
||||||
|
local key="$2"
|
||||||
|
local mac_dirty
|
||||||
|
|
||||||
|
mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
|
||||||
|
|
||||||
|
# "canonicalize" mac
|
||||||
|
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
|
||||||
|
}
|
||||||
|
|
||||||
mtd_get_mac_ascii() {
|
mtd_get_mac_ascii() {
|
||||||
local mtdname="$1"
|
local mtdname="$1"
|
||||||
local key="$2"
|
local key="$2"
|
||||||
local part
|
local part
|
||||||
local mac_dirty
|
|
||||||
|
|
||||||
part=$(find_mtd_part "$mtdname")
|
part=$(find_mtd_part "$mtdname")
|
||||||
if [ -z "$part" ]; then
|
if [ -z "$part" ]; then
|
||||||
@ -73,10 +83,7 @@ mtd_get_mac_ascii() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
|
get_mac_ascii "$part" "$key"
|
||||||
|
|
||||||
# "canonicalize" mac
|
|
||||||
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mtd_get_mac_text() {
|
mtd_get_mac_text() {
|
||||||
@ -144,6 +151,19 @@ mtd_get_part_size() {
|
|||||||
done < /proc/mtd
|
done < /proc/mtd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mmc_get_mac_ascii() {
|
||||||
|
local part_name="$1"
|
||||||
|
local key="$2"
|
||||||
|
local part
|
||||||
|
|
||||||
|
part=$(find_mmc_part "$part_name")
|
||||||
|
if [ -z "$part" ]; then
|
||||||
|
echo "mmc_get_mac_ascii: partition $part_name not found!" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_mac_ascii "$part" "$key"
|
||||||
|
}
|
||||||
|
|
||||||
mmc_get_mac_binary() {
|
mmc_get_mac_binary() {
|
||||||
local part_name="$1"
|
local part_name="$1"
|
||||||
local offset="$2"
|
local offset="$2"
|
||||||
|
Loading…
Reference in New Issue
Block a user