From c005b541bf9d54327ff860aad88367b854bae3d8 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 9 Jun 2023 13:32:27 +0000 Subject: Add devino, refactor openwrite(v)nclose Signed-off-by: Laurent Bercot --- src/libstddjb/writenclose_unsafe5.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/libstddjb/writenclose_unsafe5.c (limited to 'src/libstddjb/writenclose_unsafe5.c') diff --git a/src/libstddjb/writenclose_unsafe5.c b/src/libstddjb/writenclose_unsafe5.c new file mode 100644 index 0000000..b0cbe48 --- /dev/null +++ b/src/libstddjb/writenclose_unsafe5.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include +#include + +#include +#include + +int writenclose_unsafe5 (int fd, char const *s, size_t len, devino *devino, unsigned int options) +{ + if (allwrite(fd, s, len) < len) 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 ; +} -- cgit v1.2.3