@@ -261,6 +261,30 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
return total;
}
+ssize_t qemu_read_full(int fd, void *buf, size_t count)
+{
+ ssize_t ret = 0;
+ ssize_t total = 0;
+
+ while (count) {
+ ret = read(fd, buf, count);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ break;
+ }
+ if (ret == 0) {
+ break;
+ }
+
+ count -= ret;
+ buf += ret;
+ total += ret;
+ }
+
+ return total;
+}
+
/*
* Opens a socket with FD_CLOEXEC set
*/
@@ -214,6 +214,8 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
QEMU_WARN_UNUSED_RESULT;
ssize_t qemu_send_full(int fd, const void *buf, size_t count, int flags)
QEMU_WARN_UNUSED_RESULT;
+ssize_t qemu_read_full(int fd, void *buf, size_t count)
+ QEMU_WARN_UNUSED_RESULT;
ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags)
QEMU_WARN_UNUSED_RESULT;
This is read counter part of qemu_write_full(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> --- osdep.c | 24 ++++++++++++++++++++++++ qemu-common.h | 2 ++ 2 files changed, 26 insertions(+)