Skip to content

Commit

Permalink
base-files: add mmc_get_mac_ascii function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dangowrt committed Dec 20, 2023
1 parent c7ee906 commit 4658355
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions package/base-files/files/lib/functions/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,29 @@ find_mtd_chardev() {
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() {
local mtdname="$1"
local key="$2"
local part
local mac_dirty

part=$(find_mtd_part "$mtdname")
if [ -z "$part" ]; then
echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
return
fi

mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')

# "canonicalize" mac
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
get_mac_ascii "$part" "$key"
}

mtd_get_mac_text() {
Expand Down Expand Up @@ -144,6 +151,19 @@ mtd_get_part_size() {
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() {
local part_name="$1"
local offset="$2"
Expand Down

0 comments on commit 4658355

Please sign in to comment.