1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

lib: Add a simple read_data call without NTSTATUS

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2014-11-19 14:35:14 +00:00 committed by Jeremy Allison
parent 78d1c04e1a
commit b322ea2059
2 changed files with 23 additions and 0 deletions

View File

@ -105,3 +105,25 @@ ssize_t write_data(int fd, const void *buffer, size_t n)
iov.iov_len = n;
return write_data_iov(fd, &iov, 1);
}
/*
* Blocking read n bytes from a fd
*/
ssize_t read_data(int fd, void *buffer, size_t n)
{
ssize_t nread;
nread = 0;
while (nread < n) {
ssize_t ret;
ret = sys_read(fd, ((char *)buffer) + nread, n - nread);
if (ret <= 0) {
return ret;
}
nread += ret;
}
return nread;
}

View File

@ -29,5 +29,6 @@ struct iovec;
ssize_t write_data_iov(int fd, const struct iovec *iov, int iovcnt);
ssize_t write_data(int fd, const void *buffer, size_t n);
ssize_t read_data(int fd, void *buffer, size_t n);
#endif