From d134143b55ecb5f7e6f74318acbf04f9e1370af6 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Fri, 3 Apr 2009 19:08:19 +0100 Subject: Makes a series of non-trivial calls. --- daemon/guestfsd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'daemon/guestfsd.c') diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index eaba7f04..6fc8b19f 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -204,6 +204,26 @@ xwrite (int sock, const void *buf, size_t len) } } +void +xread (int sock, void *buf, size_t len) +{ + int r; + + while (len > 0) { + r = read (sock, buf, len); + if (r == -1) { + perror ("read"); + exit (1); + } + if (r == 0) { + fprintf (stderr, "read: unexpected end of file on comms socket\n"); + exit (1); + } + buf += r; + len -= r; + } +} + static void usage (void) { -- cgit