1 /* 2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 ** Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <syscalls.h> 8 9 #include <sys/uio.h> 10 #include <errno.h> 11 12 #include <errno_private.h> 13 #include <syscall_utils.h> 14 15 16 ssize_t 17 readv(int fd, const struct iovec *vecs, int count) 18 { 19 ssize_t bytes; 20 if (count < 0) { 21 __set_errno(B_BAD_VALUE); 22 return -1; 23 } 24 bytes = _kern_readv(fd, -1, vecs, count); 25 26 RETURN_AND_SET_ERRNO(bytes); 27 } 28 29 30 ssize_t 31 readv_pos(int fd, off_t pos, const struct iovec *vecs, int count) 32 { 33 ssize_t bytes; 34 if (pos < 0 || count < 0) { 35 __set_errno(B_BAD_VALUE); 36 return -1; 37 } 38 bytes = _kern_readv(fd, pos, vecs, count); 39 40 RETURN_AND_SET_ERRNO(bytes); 41 } 42 43 44 ssize_t 45 writev(int fd, const struct iovec *vecs, int count) 46 { 47 ssize_t bytes; 48 if (count < 0) { 49 __set_errno(B_BAD_VALUE); 50 return -1; 51 } 52 bytes = _kern_writev(fd, -1, vecs, count); 53 54 RETURN_AND_SET_ERRNO(bytes); 55 } 56 57 58 ssize_t 59 writev_pos(int fd, off_t pos, const struct iovec *vecs, int count) 60 { 61 ssize_t bytes; 62 if (pos < 0 || count < 0) { 63 __set_errno(B_BAD_VALUE); 64 return -1; 65 } 66 bytes = _kern_writev(fd, pos, vecs, count); 67 68 RETURN_AND_SET_ERRNO(bytes); 69 } 70 71