diff options
author | Michael Adam <obnox@samba.org> | 2016-03-25 01:28:27 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2016-05-13 00:16:15 +0200 |
commit | 4680fe047a2779c0797193825481a4e8ecbbc254 (patch) | |
tree | ef9f5d9b15c8131c74f3ebe43ebc93dd0b58c2fb /lib | |
parent | af83bc39202f743c9f51c472d73ede58fd81d971 (diff) | |
download | samba-4680fe047a2779c0797193825481a4e8ecbbc254.tar.gz |
lib: add sys_read_v - void variant of sys_read
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/sys_rw.c | 16 | ||||
-rw-r--r-- | lib/util/sys_rw.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/util/sys_rw.c b/lib/util/sys_rw.c index f625066ebcc..3962d492714 100644 --- a/lib/util/sys_rw.c +++ b/lib/util/sys_rw.c @@ -40,6 +40,22 @@ ssize_t sys_read(int fd, void *buf, size_t count) return ret; } +/** + * read wrapper, void variant: + * This is intended to be used as a void variant of + * read in situations where the caller wants to ignore + * the result. Hence not checking for EAGAIN|EWOULDBLOCK. + */ +void sys_read_v(int fd, void *buf, size_t count) +{ + ssize_t ret; + + do { + ret = read(fd, buf, count); + } while (ret == -1 && errno == EINTR); +} + + /******************************************************************* A write wrapper that will deal with EINTR/EWOULDBLOCK. ********************************************************************/ diff --git a/lib/util/sys_rw.h b/lib/util/sys_rw.h index ee1584e904f..6b708a88928 100644 --- a/lib/util/sys_rw.h +++ b/lib/util/sys_rw.h @@ -28,6 +28,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); 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); |