summaryrefslogtreecommitdiffstats
path: root/daemon/guestfsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/guestfsd.c')
-rw-r--r--daemon/guestfsd.c20
1 files changed, 20 insertions, 0 deletions
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)
{