1READV(2) Linux Programmer's Manual READV(2)
2
3
4
6 readv, writev, preadv, pwritev, preadv2, pwritev2 - read or write data
7 into multiple buffers
8
10 #include <sys/uio.h>
11
12 ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
13 ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
14
15 ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
16 off_t offset);
17 ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
18 off_t offset);
19
20 ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
21 off_t offset, int flags);
22 ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
23 off_t offset, int flags);
24
25 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
26
27 preadv(), pwritev():
28 Since glibc 2.19:
29 _DEFAULT_SOURCE
30 Glibc 2.19 and earlier:
31 _BSD_SOURCE
32
34 The readv() system call reads iovcnt buffers from the file associated
35 with the file descriptor fd into the buffers described by iov ("scatter
36 input").
37
38 The writev() system call writes iovcnt buffers of data described by iov
39 to the file associated with the file descriptor fd ("gather output").
40
41 The pointer iov points to an array of iovec structures, defined in
42 <sys/uio.h> as:
43
44 struct iovec {
45 void *iov_base; /* Starting address */
46 size_t iov_len; /* Number of bytes to transfer */
47 };
48
49 The readv() system call works just like read(2) except that multiple
50 buffers are filled.
51
52 The writev() system call works just like write(2) except that multiple
53 buffers are written out.
54
55 Buffers are processed in array order. This means that readv() com‐
56 pletely fills iov[0] before proceeding to iov[1], and so on. (If there
57 is insufficient data, then not all buffers pointed to by iov may be
58 filled.) Similarly, writev() writes out the entire contents of iov[0]
59 before proceeding to iov[1], and so on.
60
61 The data transfers performed by readv() and writev() are atomic: the
62 data written by writev() is written as a single block that is not in‐
63 termingled with output from writes in other processes; analogously,
64 readv() is guaranteed to read a contiguous block of data from the file,
65 regardless of read operations performed in other threads or processes
66 that have file descriptors referring to the same open file description
67 (see open(2)).
68
69 preadv() and pwritev()
70 The preadv() system call combines the functionality of readv() and
71 pread(2). It performs the same task as readv(), but adds a fourth ar‐
72 gument, offset, which specifies the file offset at which the input op‐
73 eration is to be performed.
74
75 The pwritev() system call combines the functionality of writev() and
76 pwrite(2). It performs the same task as writev(), but adds a fourth
77 argument, offset, which specifies the file offset at which the output
78 operation is to be performed.
79
80 The file offset is not changed by these