diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-06-09 13:32:27 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-06-09 13:32:27 +0000 |
commit | c005b541bf9d54327ff860aad88367b854bae3d8 (patch) | |
tree | 6af88b1dd6637084b9e20e0c62b764656b9deaf4 /src/libstddjb/writevnclose_unsafe5.c | |
parent | 4af2899ac7ed0da49db7a6e94914fee391212f92 (diff) | |
download | skalibs-c005b541bf9d54327ff860aad88367b854bae3d8.tar.xz |
Add devino, refactor openwrite(v)nclose
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/writevnclose_unsafe5.c')
-rw-r--r-- | src/libstddjb/writevnclose_unsafe5.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libstddjb/writevnclose_unsafe5.c b/src/libstddjb/writevnclose_unsafe5.c new file mode 100644 index 0000000..49b1444 --- /dev/null +++ b/src/libstddjb/writevnclose_unsafe5.c @@ -0,0 +1,23 @@ +/* ISC license. */ + +#include <sys/stat.h> +#include <errno.h> + +#include <skalibs/allreadwrite.h> +#include <skalibs/siovec.h> +#include <skalibs/djbunix.h> + +int writevnclose_unsafe5 (int fd, struct iovec const *v, unsigned int vlen, devino *devino, unsigned int options) +{ + if (allwritev(fd, v, vlen) < siovec_len(v, vlen)) return 0 ; + if (options & 1 && fd_sync(fd) == -1 && errno != EINVAL) return 0 ; + if (devino) + { + struct stat st ; + if (fstat(fd, &st) == -1) return 0 ; + devino->dev = st.st_dev ; + devino->ino = st.st_ino ; + } + fd_close(fd) ; + return 1 ; +} |