diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-06 12:58:29 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-06 21:24:03 +0900 |
commit | 92c40e1dc825b90f64c22b2e994f3a69e802f089 (patch) | |
tree | dc50934a5ccdee9baea2e5f9a556bfb1d011811c /src/udev/udevadm-trigger.c | |
parent | 559696f7630b3051510a7b6a3b8e8ba547fa2189 (diff) | |
download | systemd-92c40e1dc825b90f64c22b2e994f3a69e802f089.tar.gz systemd-92c40e1dc825b90f64c22b2e994f3a69e802f089.tar.bz2 systemd-92c40e1dc825b90f64c22b2e994f3a69e802f089.zip |
udevadm: use write_string_file() helper function
Diffstat (limited to 'src/udev/udevadm-trigger.c')
-rw-r--r-- | src/udev/udevadm-trigger.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 66ed0aee59..185fe29be0 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -8,6 +8,7 @@ #include "device-enumerator-private.h" #include "fd-util.h" +#include "fileio.h" #include "path-util.h" #include "set.h" #include "string-util.h" @@ -24,7 +25,6 @@ static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_se FOREACH_DEVICE_AND_SUBSYSTEM(e, d) { _cleanup_free_ char *filename = NULL; - _cleanup_close_ int fd = -1; const char *syspath; if (sd_device_get_syspath(d, &syspath) < 0) @@ -39,18 +39,17 @@ static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_se if (!filename) return log_oom(); - fd = open(filename, O_WRONLY|O_CLOEXEC); - if (fd < 0) + r = write_string_file(filename, action, WRITE_STRING_FILE_DISABLE_BUFFER); + if (r < 0) { + log_debug_errno(r, "Failed to write '%s' to '%s', ignoring: %m", action, filename); continue; + } if (settle_set) { r = set_put_strdup(settle_set, syspath); if (r < 0) return log_oom(); } - - if (write(fd, action, strlen(action)) < 0) - log_debug_errno(errno, "Failed to write '%s' to '%s', ignoring: %m", action, filename); } return 0; |