aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files
diff options
context:
space:
mode:
authorMathias Kresin <dev@kresin.me>2018-01-26 22:54:06 +0100
committerMathias Kresin <dev@kresin.me>2018-03-14 19:04:52 +0100
commit64fef8f90172cf35f9ce878390b6535f482d327b (patch)
treef6945628ff82560e7c1a03ae77f5ec8186e15784 /package/base-files/files
parent87c42101cfb001b4bd418d1201fa4d8c822dc77b (diff)
downloadupstream-64fef8f90172cf35f9ce878390b6535f482d327b.tar.gz
upstream-64fef8f90172cf35f9ce878390b6535f482d327b.tar.bz2
upstream-64fef8f90172cf35f9ce878390b6535f482d327b.zip
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>
Diffstat (limited to 'package/base-files/files')
-rw-r--r--package/base-files/files/lib/functions/system.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 35f6d10fdb..d4402c3a14 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -1,5 +1,17 @@
# 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() {
local INDEX=$(find_mtd_index "$1")
local PREFIX=/dev/mtd
@@ -33,12 +45,7 @@ mtd_get_mac_binary() {
local part
part=$(find_mtd_part "$mtdname")
- if [ -z "$part" ]; then
- 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
+ get_mac_binary "$part" "$offset"
}
mtd_get_mac_binary_ubi() {