lib: add sys_write_v - void variant of sys_write
authorMichael Adam <obnox@samba.org>
Fri, 25 Mar 2016 00:28:56 +0000 (01:28 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 12 May 2016 22:16:15 +0000 (00:16 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
lib/util/sys_rw.c
lib/util/sys_rw.h

index 3962d492714560f2ad313b03a082f93238c4ea7a..9a6cdcaa606343845616e1673622a2736d64425c 100644 (file)
@@ -72,6 +72,23 @@ ssize_t sys_write(int fd, const void *buf, size_t count)
        return ret;
 }
 
+/**
+ * write wrapper to deal with EINTR and friends.
+ * void-variant that ignores the number of bytes written.
+ * This is intended to be used as a void variant of
+ * write in situations where the caller wants to ignore
+ * the result. Hence not checking for EAGAIN|EWOULDBLOCK.
+ */
+void sys_write_v(int fd, const void *buf, size_t count)
+{
+       ssize_t ret;
+
+       do {
+               ret = write(fd, buf, count);
+       } while (ret == -1 && errno == EINTR);
+}
+
+
 /*******************************************************************
 A writev wrapper that will deal with EINTR.
 ********************************************************************/
index 6b708a889284e5be659ba18a157c90274606c1d4..ab456d87b22e9747dce2e8d9d94c82e799ffbaec 100644 (file)
@@ -30,6 +30,7 @@ struct iovec;
 ssize_t sys_read(int fd, void *buf, size_t count);
 void sys_read_v(int fd, void *buf, size_t count);
 ssize_t sys_write(int fd, const void *buf, size_t count);
+void sys_write_v(int fd, const void *buf, size_t count);
 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
 ssize_t sys_pread(int fd, void *buf, size_t count, off_t off);
 ssize_t sys_pwrite(int fd, const void *buf, size_t count, off_t off);