1READV(P) POSIX Programmer's Manual READV(P)
2
3
4
6 readv - read a vector
7
9 #include <sys/uio.h>
10
11 ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);
12
13
15 The readv() function shall be equivalent to read(), except as described
16 below. The readv() function shall place the input data into the iovcnt
17 buffers specified by the members of the iov array: iov[0], iov[1], ...,
18 iov[ iovcnt-1]. The iovcnt argument is valid if greater than 0 and
19 less than or equal to {IOV_MAX}.
20
21 Each iovec entry specifies the base address and length of an area in
22 memory where data should be placed. The readv() function shall always
23 fill an area completely before proceeding to the next.
24
25 Upon successful completion, readv() shall mark for update the st_atime
26 field of the file.
27
29 Refer to read() .
30
32 Refer to read() .
33
34 In addition, the readv() function shall fail if:
35
36 EINVAL The sum of the iov_len values in the iov array overflowed an
37 ssize_t.
38
39
40 The readv() function may fail if:
41
42 EINVAL The iovcnt argument was less than or equal to 0, or greater than
43 {IOV_MAX}.
44
45
46 The following sections are informative.
47
49 Reading Data into an Array
50 The following example reads data from the file associated with the file
51 descriptor fd into the buffers specified by members of the iov array.
52
53
54 #include <sys/types.h>
55 #include <sys/uio.h>
56 #include <unistd.h>
57 ...
58 ssize_t bytes_read;
59 int fd;
60 char buf0[20];
61 char buf1[30];
62 char buf2[40];
63 int iovcnt;
64 struct iovec iov[3];
65
66
67 iov[0].iov_base = buf0;
68 iov[0].iov_len = sizeof(buf0);
69 iov[1].iov_base = buf1;
70 iov[1].iov_len = sizeof(buf1);
71 iov[2].iov_base = buf2;
72 iov[2].iov_len = sizeof(buf2);
73 ...
74 iovcnt = sizeof(iov) / sizeof(struct iovec);
75
76
77 bytes_read = readv(fd, iov, iovcnt);
78 ...
79
81 None.
82
84 Refer to read() .
85
87 None.
88
90 read() , writev() , the Base Definitions volume of
91 IEEE Std 1003.1-2001, <sys/uio.h>
92
94 Portions of this text are reprinted and reproduced in electronic form
95 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
96 -- Portable Operating System Interface (POSIX), The Open Group Base
97 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
98 Electrical and Electronics Engineers, Inc and The Open Group. In the
99 event of any discrepancy between this version and the original IEEE and
100 The Open Group Standard, the original IEEE and The Open Group Standard
101 is the referee document. The original Standard can be obtained online
102 at http://www.opengroup.org/unix/online.html .
103
104
105
106IEEE/The Open Group 2003 READV(P)