From: Michael Tremer Date: Fri, 21 Jul 2017 18:19:06 +0000 (+0200) Subject: Improve performance of reading files from the device tree X-Git-Tag: 009~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=750aae10b19341d973c4e8d984e6e13272ccb8a5;p=network.git Improve performance of reading files from the device tree Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.device b/src/functions/functions.device index 4c7f9788..bdca75e2 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -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() {