Because that is what the function is actually doing.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
bonding_init
# Create the bonding device.
bonding_init
# Create the bonding device.
- fwrite "${BONDING_MASTERS}" "+${device}"
+ fappend "${BONDING_MASTERS}" "+${device}"
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
device_set_down ${device}
# Remove the device.
device_set_down ${device}
# Remove the device.
- fwrite "${BONDING_MASTERS}" "-${device}"
+ fappend "${BONDING_MASTERS}" "-${device}"
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
local device="${1}"
local mode="${2}"
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}'"
log DEBUG "Set mode of bond '${device}' to '${mode}'"
else
log ERROR "Could not set mode of bond '${device}' to '${mode}'"
- fwrite "${SYS_CLASS_NET}/${device}/bonding/slaves" "+${slave}"
+ fappend "${SYS_CLASS_NET}/${device}/bonding/slaves" "+${slave}"
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
local ret=$?
if [ ${ret} -eq ${EXIT_OK} ]; then
local file="${2}"
local value="${3}"
local file="${2}"
local value="${3}"
- fwrite "${SYS_CLASS_NET}/${device}/${file}" "${value}"
+ fappend "${SYS_CLASS_NET}/${device}/${file}" "${value}"
}
device_get_rx_bytes() {
}
device_get_rx_bytes() {
> "${config_file}"
# Global options.
> "${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
# Set the new value.
log DEBUG "Setting forward delay on bridge '${bridge}' from '${current_fdelay}' to '${fdelay}'"
# 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 ))"
- fwrite "$(sysctl_key_to_path "${key}")" "${value}" || return $?
+ fappend "$(sysctl_key_to_path "${key}")" "${value}" || return $?
for path in $(find "${basepath}" -type f); do
[[ ${path} =~ ${subpath}$ ]] || continue
for path in $(find "${basepath}" -type f); do
[[ ${path} =~ ${subpath}$ ]] || continue
- fwrite "${path}" "${value}"
+ fappend "${path}" "${value}"
+ 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}
if [ -e "${file}" ] && [ ! -w "${file}" ]; then
log ERROR "${file}: No such file"
return ${EXIT_ERROR}