1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "READV" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" readv
.SH NAME
readv \- read a vector
.SH SYNOPSIS
.LP
\fB#include <sys/uio.h>
.br
.sp
ssize_t readv(int\fP \fIfildes\fP\fB, const struct iovec *\fP\fIiov\fP\fB,
int\fP \fIiovcnt\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fIreadv\fP() function shall be equivalent to \fIread\fP(), except
as described
below. The \fIreadv\fP() function shall place the input data into
the \fIiovcnt\fP buffers specified by the members of the
\fIiov\fP array: \fIiov\fP[0], \fIiov\fP[1], ..., \fIiov\fP[ \fIiovcnt\fP-1].
The \fIiovcnt\fP argument is valid if greater
than 0 and less than or equal to {IOV_MAX}.
.LP
Each \fIiovec\fP entry specifies the base address and length of an
area in memory where data should be placed. The
\fIreadv\fP() function shall always fill an area completely before
proceeding to the next.
.LP
Upon successful completion, \fIreadv\fP() shall mark for update the
\fIst_atime\fP field of the file.
.SH RETURN VALUE
.LP
Refer to \fIread\fP() .
.SH ERRORS
.LP
Refer to \fIread\fP() .
.LP
In addition, the \fIreadv\fP() function shall fail if:
.TP 7
.B EINVAL
The sum of the \fIiov_len\fP values in the \fIiov\fP array overflowed
an \fBssize_t\fP.
.sp
.LP
The \fIreadv\fP() function may fail if:
.TP 7
.B EINVAL
The \fIiovcnt\fP argument was less than or equal to 0, or greater
than {IOV_MAX}.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.SS Reading Data into an Array
.LP
The following example reads data from the file associated with the
file descriptor \fIfd\fP into the buffers specified by
members of the \fIiov\fP array.
.sp
.RS
.nf
\fB#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
\&...
ssize_t bytes_read;
int fd;
char buf0[20];
char buf1[30];
char buf2[40];
int iovcnt;
struct iovec iov[3];
.sp
iov[0].iov_base = buf0;
iov[0].iov_len = sizeof(buf0);
iov[1].iov_base = buf1;
iov[1].iov_len = sizeof(buf1);
iov[2].iov_base = buf2;
iov[2].iov_len = sizeof(buf2);
\&...
iovcnt = sizeof(iov) / sizeof(struct iovec);
.sp
bytes_read = readv(fd, iov, iovcnt);
\&...
\fP
.fi
.RE
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
Refer to \fIread\fP() .
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIread\fP() , \fIwritev\fP() , the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<sys/uio.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
|