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