]> git.ipfire.org Git - people/ms/network.git/commitdiff
Rename fwrite to fappend
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 14:21:32 +0000 (14:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 14:21:32 +0000 (14:21 +0000)
Because that is what the function is actually doing.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.bonding
src/functions/functions.device
src/functions/functions.dhclient
src/functions/functions.stp
src/functions/functions.sysctl
src/functions/functions.util

index d9861e58cb4a802779ff997df49d15832ca3f737..7939c9624995053327d597d52f567860fdac2d87 100644 (file)
@@ -69,7 +69,7 @@ bonding_create() {
        bonding_init
 
        # Create the bonding device.
-       fwrite "${BONDING_MASTERS}" "+${device}"
+       fappend "${BONDING_MASTERS}" "+${device}"
        local ret=$?
 
        if [ ${ret} -eq ${EXIT_OK} ]; then
@@ -101,7 +101,7 @@ bonding_remove() {
        device_set_down ${device}
 
        # Remove the device.
-       fwrite "${BONDING_MASTERS}" "-${device}"
+       fappend "${BONDING_MASTERS}" "-${device}"
        local ret=$?
 
        if [ ${ret} -eq ${EXIT_OK} ]; then
@@ -129,7 +129,7 @@ bonding_set_mode() {
        local device="${1}"
        local mode="${2}"
 
-       if fwrite "${SYS_CLASS_NET}/${device}/bonding/mode" "${mode}"; then
+       if fappend "${SYS_CLASS_NET}/${device}/bonding/mode" "${mode}"; then
                log DEBUG "Set mode of bond '${device}' to '${mode}'"
        else
                log ERROR "Could not set mode of bond '${device}' to '${mode}'"
@@ -157,7 +157,7 @@ bonding_enslave_device() {
        fi
 
        # Add it.
-       fwrite "${SYS_CLASS_NET}/${device}/bonding/slaves" "+${slave}"
+       fappend "${SYS_CLASS_NET}/${device}/bonding/slaves" "+${slave}"
        local ret=$?
 
        if [ ${ret} -eq ${EXIT_OK} ]; then
index be3fe954035d67ba546e839ec4424a5cdeebfb28..6f79a7f689e3760113305b0336340f9382923153 100644 (file)
@@ -823,7 +823,7 @@ __device_set_file() {
        local file="${2}"
        local value="${3}"
 
-       fwrite "${SYS_CLASS_NET}/${device}/${file}" "${value}"
+       fappend "${SYS_CLASS_NET}/${device}/${file}" "${value}"
 }
 
 device_get_rx_bytes() {
index 9409b0b7b70c78ce9399cd51e006f8fbbd39c441..57724744fa876bf713960a8cd6305d2b5cec4424 100644 (file)
@@ -127,8 +127,8 @@ dhclient_write_config() {
                > "${config_file}"
 
        # Global options.
-       fwrite "${config_file}" "send vendor-class-identifier \"${vendor}\";"
-       fwrite "${config_file}" # empty line
+       fappend "${config_file}" "send vendor-class-identifier \"${vendor}\";"
+       fappend "${config_file}" # empty line
 
        # Interface options.
        (
index 7155c0f31a4215c0f211d0cd1806de1ec30684b1..7b08742acf306b8f804b46d732e73a1cdd6de60e 100644 (file)
@@ -88,7 +88,7 @@ stp_bridge_set_forward_delay() {
 
        # Set the new value.
        log DEBUG "Setting forward delay on bridge '${bridge}' from '${current_fdelay}' to '${fdelay}'"
-       fwrite "${SYS_CLASS_NET}/${bridge}/bridge/forward_delay" "$(( ${fdelay} * 100 ))"
+       fappend "${SYS_CLASS_NET}/${bridge}/bridge/forward_delay" "$(( ${fdelay} * 100 ))"
 
        return ${EXIT_OK}
 }
index 5d77b8e9f078d04f18de2fb6fdc47f2df89ea539..ce8f43a90c3117f241695032f245f89f138f48ef 100644 (file)
@@ -54,7 +54,7 @@ sysctl_set() {
 
        local value="${2}"
 
-       fwrite "$(sysctl_key_to_path "${key}")" "${value}" || return $?
+       fappend "$(sysctl_key_to_path "${key}")" "${value}" || return $?
        return ${EXIT_OK}
 }
 
@@ -87,7 +87,7 @@ sysctl_set_recursively() {
        for path in $(find "${basepath}" -type f); do
                [[ ${path} =~ ${subpath}$ ]] || continue
 
-               fwrite "${path}" "${value}"
+               fappend "${path}" "${value}"
        done
 
        return ${EXIT_OK}
index e083f6a7de3515a3a11ad88e46488c1012c9788a..91601de65d6e57d602740670a229f56c6845dd15 100644 (file)
@@ -190,6 +190,19 @@ fwrite() {
        assert isset file
        shift
 
+       if ! print "%s" "$@" > ${file} 2>/dev/null; then
+               error "Could not write to file: ${file}"
+               return ${EXIT_ERROR}
+       fi
+
+       return ${EXIT_OK}
+}
+
+fappend() {
+       local file=${1}
+       assert isset file
+       shift
+
        if [ -e "${file}" ] && [ ! -w "${file}" ]; then
                log ERROR "${file}: No such file"
                return ${EXIT_ERROR}