diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-04 11:27:08 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-04-12 11:44:57 +0200 |
commit | 02e23d1a1a8c3baf73d82da5abbab3a4eeb1cbf4 (patch) | |
tree | a7b7f26ec3058af9278cd4e2e40f87d4232bdf94 /src/basic/tmpfile-util.c | |
parent | 41f6e627d7cfdf1ea50d5adbd7e118589dbcf8db (diff) | |
download | systemd-02e23d1a1a8c3baf73d82da5abbab3a4eeb1cbf4.tar.gz |
Add fdopen_unlocked() wrapper
Diffstat (limited to 'src/basic/tmpfile-util.c')
-rw-r--r-- | src/basic/tmpfile-util.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c index 260443a1d6..3ed91520b9 100644 --- a/src/basic/tmpfile-util.c +++ b/src/basic/tmpfile-util.c @@ -6,6 +6,7 @@ #include "alloc-util.h" #include "fd-util.h" +#include "fileio.h" #include "fs-util.h" #include "hexdecoct.h" #include "macro.h" @@ -42,16 +43,14 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { /* This assumes that returned FILE object is short-lived and used within the same single-threaded * context and never shared externally, hence locking is not necessary. */ - f = fdopen(fd, "w"); - if (!f) { - unlink_noerrno(t); + r = fdopen_unlocked(fd, "w", &f); + if (r < 0) { + unlink(t); free(t); safe_close(fd); - return -errno; + return r; } - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - *_f = f; *_temp_path = t; |