File: readv.2

package info (click to toggle)
manpages 1.29-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,796 kB
  • ctags: 5
  • sloc: sh: 79; makefile: 61
file content (111 lines) | stat: -rw-r--r-- 3,848 bytes parent folder | download
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
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1996 Tom Bjorkholm <tomb@mydata.se>
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" 1996-04-12 Tom Bjorkholm <tomb@mydata.se>
.\"            First version written
.\" Modified Tue Oct 22 17:41:07 1996 by Eric S. Raymond <esr@thyrsus.com>
.\"
.TH READV 2 "1999-01-20" "Linux 2.2.0-pre8" "Linux Programmer's Manual"
.SH NAME
readv, writev \- read or write a vector
.SH SYNOPSIS
.B #include <sys/uio.h>
.sp
.BI "int readv(int " fd ", const struct iovec * " vector ", int " count );
.sp
.BI "int writev(int " fd ", const struct iovec * " vector ", int " count );
.sp
.B
\fBstruct iovec {\fR
.br
  \fB__ptr_t \fIiov_base\fB;\fR /* Starting address.  */
.br  
  \fBsize_t \fIiov_len\fB;\fR /* Length in bytes.  */
.br
\fB};\fR
.fi
.SH DESCRIPTION
\fBreadv\fR reads data from file descriptor \fIfd\fR, and puts the result 
in the buffers described by \fIvector\fR. The number of buffers is
specified by \fIcount\fR. The buffers are filled in the order specified.
Operates just like \fBread\fR except that data is put in \fIvector\fR
instead of a contiguous buffer.

\fBwritev\fR writes data to file descriptor \fIfd\fR, and from  
the buffers described by \fIvector\fR. The number of buffers is
specified by \fIcount\fR. The buffers are used in the order specified.
Operates just like \fBwrite\fR except that data is taken from \fIvector\fR
instead of a contiguous buffer.

.SH RETURN VALUE
On success \fBreadv\fR returns the number of bytes read.
On success \fBwritev\fR returns the number of bytes written.
On error, \-1 is returned, and \fIerrno\fR is set appropriately.

.SH ERRORS
.TP
.B EINVAL
An invalid argument was given. For instance \fIcount\fR might be 
greater than \fBMAX_IOVEC\fR, or zero.  \fIfd\fR could also be attached 
to an object  which  is  unsuitable for reading (for \fBreadv\fR) or
writing (for \fBwritev\fR).
.TP
.B EFAULT
"Segmentation fault." Most likely \fIvector\fR or some of the 
\fIiov_base\fR pointers points to memory that is not properly allocated.
.TP
.B EBADF
The file descriptor \fIfd\fR is not valid.
.TP
.B EINTR
The call was interrupted by a signal before any data was read/written.
.TP
.B EAGAIN
Non-blocking I/O has been selected using 
\fBO_NONBLOCK\fR and no data was immediately available for reading.
(Or the file descriptor \fIfd\fR is for an object that is locked.)
.TP
.B EISDIR
\fIfd\fR refers to a directory.
.TP
.B EOPNOTSUP
\fIfd\fR refers to a socket or device that does not support reading/writing.
.TP
.B ENOMEM
Insufficient kernel memory was available.
.PP
Other errors may occur, depending on the object connected to \fIfd\fR.
.SH "CONFORMING TO"
4.4BSD (the
.B readv
and
.B writev
functions first appeared in BSD 4.2), Unix98.  Linux libc5 uses
\fBsize_t\fR as the type of the \fIcount\fR parameter, which is
logical but non-standard.
.SH SEE ALSO
.BR read (2),
.BR write (2),
.BR fprintf (3),
.BR fscanf (3)