From 750aae10b19341d973c4e8d984e6e13272ccb8a5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 21 Jul 2017 20:19:06 +0200 Subject: [PATCH] Improve performance of reading files from the device tree Signed-off-by: Michael Tremer --- src/functions/functions.device | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) 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() { -- 2.47.3