]> git.ipfire.org Git - people/ms/network.git/commitdiff
Improve performance of reading files from the device tree
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Jul 2017 18:19:06 +0000 (20:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Jul 2017 18:19:06 +0000 (20:19 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.device

index 4c7f9788d9f25f8e9d31a2859483d7cd396287f1..bdca75e21586ada8230abe9d81c76e3a093b8db6 100644 (file)
@@ -807,13 +807,7 @@ __device_get_file() {
        local device=${1}
        local file=${2}
 
-       assert isset device
-       assert isset file
-
-       local path="${SYS_CLASS_NET}/${device}/${file}"
-       [ -r "${path}" ] || return ${EXIT_ERROR}
-
-       echo "$(<${path})"
+       fread "${SYS_CLASS_NET}/${device}/${file}"
 }
 
 __device_set_file() {
@@ -823,13 +817,7 @@ __device_set_file() {
        local file="${2}"
        local value="${3}"
 
-       local path="${SYS_CLASS_NET}/${device}/${file}"
-       if [ ! -w "${path}" ]; then
-               log DEBUG "Cannot write to file '${file}' (${value})"
-               return ${EXIT_ERROR}
-       fi
-
-       echo "${value}" > "${path}"
+       fwrite "${SYS_CLASS_NET}/${device}/${file}" "${value}"
 }
 
 device_get_rx_bytes() {