writevnclose_unsafe5.c (579B)
1 /* ISC license. */ 2 3 #include <sys/stat.h> 4 #include <errno.h> 5 6 #include <skalibs/allreadwrite.h> 7 #include <skalibs/siovec.h> 8 #include <skalibs/djbunix.h> 9 10 int writevnclose_unsafe5 (int fd, struct iovec const *v, unsigned int vlen, devino *devino, unsigned int options) 11 { 12 if (allwritev(fd, v, vlen) < siovec_len(v, vlen)) return 0 ; 13 if (options & 1 && fd_sync(fd) == -1 && errno != EINVAL) return 0 ; 14 if (devino) 15 { 16 struct stat st ; 17 if (fstat(fd, &st) == -1) return 0 ; 18 devino->dev = st.st_dev ; 19 devino->ino = st.st_ino ; 20 } 21 fd_close(fd) ; 22 return 1 ; 23 }