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
20 The readv() function shall be equivalent to read(), except as described
21 below. The readv() function shall place the input data into the iovcnt
22 buffers specified by the members of the iov array: iov[0], iov[1], ...,
23 iov[iovcnt-1]. The iovcnt argument is valid if greater than 0 and less
24 than or equal to {IOV_MAX}.
25
26 Each iovec entry specifies the base address and length of an area in
27 memory where data should be placed. The readv() function shall always
28 fill an area completely before proceeding to the next.
29
30 Upon successful completion, readv() shall mark for update the last data
31 access timestamp of the file.
32
34 Refer to read().
35
37 Refer to read().
38
39 In addition, the readv() function shall fail if:
40
41 EINVAL The sum of the iov_len values in the iov array overflowed an
42 ssize_t.
43
44 The readv() function may fail if:
45
46 EINVAL The iovcnt argument was less than or equal to 0, or greater than
47 {IOV_MAX}.
48
49 The following sections are informative.
50
52 Reading Data into an Array
53 The following example reads data from the file associated with the file
54 descriptor fd into the buffers specified by members of the iov array.
55
56
57 #include <sys/types.h>
58 #include <sys/uio.h>
59 #include <unistd.h>
60 ...
61 ssize_t bytes_read;
62 int fd;
63 char buf0[20];
64 char buf1[30];
65 char buf2[40];
66 int iovcnt;
67 struct iovec iov[3];
68
69 iov[0].iov_base = buf0;
70 iov[0].iov_len = sizeof(buf0);
71 iov[1].iov_base = buf1;
72 iov[1].iov_len = sizeof(buf1);
73 iov[2].iov_base = buf2;
74 iov[2].iov_len = sizeof(buf2);
75 ...
76 iovcnt = sizeof(iov) / sizeof(struct iovec);
77
78 bytes_read = readv(fd, iov, iovcnt);
79 ...
80
82 None.
83
85 Refer to read().
86
88 None.
89
91 read(), writev()
92
93 The Base Definitions volume of POSIX.1‐2017, <sys_uio.h>
94
96 Portions of this text are reprinted and reproduced in electronic form
97 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
98 table Operating System Interface (POSIX), The Open Group Base Specifi‐
99 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
100 Electrical and Electronics Engineers, Inc and The Open Group. In the
101 event of any discrepancy between this version and the original IEEE and
102 The Open Group Standard, the original IEEE and The Open Group Standard
103 is the referee document. The original Standard can be obtained online
104 at http://www.opengroup.org/unix/online.html .
105
106 Any typographical or formatting errors that appear in this page are
107 most likely to have been introduced during the conversion of the source
108 files to man page format. To report such errors, see https://www.ker‐
109 nel.org/doc/man-pages/reporting_bugs.html .
110
111
112
113IEEE/The Open Group 2017 READV(3P)