xref: /illumos-gate/usr/src/lib/libresolv2/common/bsd/readv.c (revision bc1f688b4872ace323eaddbb1a6365d054e7bf56)
1 #include "port_before.h"
2 
3 #include <sys/types.h>
4 #include <sys/uio.h>
5 #include <sys/stat.h>
6 #include <sys/socket.h>
7 
8 #include "port_after.h"
9 
10 #ifndef NEED_READV
11 int __bindcompat_readv;
12 #else
13 
14 int
15 __readv(fd, vp, vpcount)
16 	int fd;
17 	const struct iovec *vp;
18 	int vpcount;
19 {
20 	int count = 0;
21 
22 	while (vpcount-- > 0) {
23 		int bytes = read(fd, vp->iov_base, vp->iov_len);
24 
25 		if (bytes < 0)
26 			return (-1);
27 		count += bytes;
28 		if (bytes != vp->iov_len)
29 			break;
30 		vp++;
31 	}
32 	return (count);
33 }
34 #endif /* NEED_READV */
35 /*! \file */
36