1READV(2)                   Linux Programmer's Manual                  READV(2)
2
3
4

NAME

6       readv,  writev, preadv, pwritev, preadv2, pwritev2 - read or write data
7       into multiple buffers
8

SYNOPSIS

10       #include <sys/uio.h>
11
12       ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
13
14       ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
15
16       ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
17                      off_t offset);
18
19       ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
20                       off_t offset);
21
22       ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
23                       off_t offset, int flags);
24
25       ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
26                        off_t offset, int flags);
27
28   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
29
30       preadv(), pwritev():
31           Since glibc 2.19:
32               _DEFAULT_SOURCE
33           Glibc 2.19 and earlier:
34               _BSD_SOURCE
35

DESCRIPTION

37       The readv() system call reads iovcnt buffers from the  file  associated
38       with the file descriptor fd into the buffers described by iov ("scatter
39       input").
40
41       The writev() system call writes iovcnt buffers of data described by iov
42       to the file associated with the file descriptor fd ("gather output").
43
44       The  pointer  iov  points  to  an array of iovec structures, defined in
45       <sys/uio.h> as:
46
47           struct iovec {
48               void  *iov_base;    /* Starting address */
49               size_t iov_len;     /* Number of bytes to transfer */
50           };
51
52       The readv() system call works just like read(2)  except  that  multiple
53       buffers are filled.
54
55       The  writev() system call works just like write(2) except that multiple
56       buffers are written out.
57
58       Buffers are processed in array order.  This  means  that  readv()  com‐
59       pletely fills iov[0] before proceeding to iov[1], and so on.  (If there
60       is insufficient data, then not all buffers pointed to  by  iov  may  be
61       filled.)   Similarly, writev() writes out the entire contents of iov[0]
62       before proceeding to iov[1], and so on.
63
64       The data transfers performed by readv() and writev()  are  atomic:  the
65       data  written  by  writev()  is  written  as a single block that is not
66       intermingled with output  from  writes  in  other  processes  (but  see
67       pipe(7) for an exception); analogously, readv() is guaranteed to read a
68       contiguous block of data from the file, regardless of  read  operations
69       performed  in  other  threads  or  processes that have file descriptors
70       referring to the same open file description (see open(2)).
71
72   preadv() and pwritev()
73       The preadv() system call combines  the  functionality  of  readv()  and
74       pread(2).   It  performs  the  same  task as readv(), but adds a fourth
75       argument, offset, which specifies the file offset at  which  the  input
76       operation is to be performed.
77
78       The  pwritev()  system  call combines the functionality of writev() and
79       pwrite(2).  It performs the same task as writev(), but  adds  a  fourth
80       argument,