aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_solaris.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-11-11 18:22:33 +0000
committerKeir Fraser <keir@xensource.com>2007-11-11 18:22:33 +0000
commitc316590403819d9206b81ca5dd42136c86ee271c (patch)
treed9728245710b174c84dcbd28d9aba5cdb1d747c2 /tools/libxc/xc_solaris.c
parentbbceef66ead2fb6800a767a7625c598f196ce852 (diff)
downloadxen-c316590403819d9206b81ca5dd42136c86ee271c.tar.gz
xen-c316590403819d9206b81ca5dd42136c86ee271c.tar.bz2
xen-c316590403819d9206b81ca5dd42136c86ee271c.zip
libxc: Consolidate read()/write() syscall wrappers to read/write an
exact number of bytes. The consolidated versions are more watertight than the various versions previously distributed around the library source code. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/libxc/xc_solaris.c')
-rw-r--r--tools/libxc/xc_solaris.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c
index a39157028d..86eee3c719 100644
--- a/tools/libxc/xc_solaris.c
+++ b/tools/libxc/xc_solaris.c
@@ -206,37 +206,12 @@ int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind);
}
-static int dorw(int fd, char *data, size_t size, int do_write)
-{
- size_t offset = 0;
- ssize_t len;
-
- while ( offset < size )
- {
- if (do_write)
- len = write(fd, data + offset, size - offset);
- else
- len = read(fd, data + offset, size - offset);
-
- if ( len == -1 )
- {
- if ( errno == EINTR )
- continue;
- return -1;
- }
-
- offset += len;
- }
-
- return 0;
-}
-
evtchn_port_or_error_t
xc_evtchn_pending(int xce_handle)
{
evtchn_port_t port;
- if ( dorw(xce_handle, (char *)&port, sizeof(port), 0) == -1 )
+ if ( read_exact(xce_handle, (char *)&port, sizeof(port)) == -1 )
return -1;
return port;
@@ -244,7 +219,7 @@ xc_evtchn_pending(int xce_handle)
int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)
{
- return dorw(xce_handle, (char *)&port, sizeof(port), 1);
+ return write_exact(xce_handle, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */