man-pages/man2/readv.2

130 lines
3.4 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
.\" (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" License.
.\" Modified Sat Jul 24 18:34:44 1993 by Rik Faith (faith@cs.unc.edu)
.\" Merged readv.[23], 2002-10-17, aeb
.\"
.TH READV 2 2002-10-17 "" "Linux Programmer's Manual"
.SH NAME
readv, writev \- read or write data into multiple buffers
.SH SYNOPSIS
.nf
.B #include <sys/uio.h>
.sp
.BI "ssize_t readv(int " fd ", const struct iovec *" vector ", int " count );
.sp
.BI "ssize_t writev(int " fd ", const struct iovec *" vector ", int " count );
.fi
.SH DESCRIPTION
The
.B readv()
function reads
.I count
blocks from the file associated with the file descriptor
.I fd
into the multiple buffers described by
.IR vector .
.PP
The
.B writev()
function writes at most
.I count
blocks described by
.I vector
to the file associated with the file descriptor
.IR fd .
.PP
The pointer
.I vector
points to a
.B struct iovec
defined in
.B <sys/uio.h>
as
.PP
.br
.nf
.in 10
struct iovec {
.in 14
void *iov_base; /* Starting address */
size_t iov_len; /* Number of bytes */
.in 10
};
.fi
.PP
Buffers are processed in the order specified.
.PP
The
.B readv()
function works just like
.BR read (2)
except that multiple buffers are filled.
.PP
The
.B writev()
function works just like
.BR write (2)
except that multiple buffers are written out.
.PP
.SH "RETURN VALUE"
On success, the
.B readv()
function returns the number of bytes read; the
.B writev()
function returns the number of bytes written.
On error, \-1 is returned, and \fIerrno\fP is set appropriately.
.SH ERRORS
The errors are as given for
.BR read (2)
and
.BR write (2).
Additionally the following error is defined.
.TP
.B EINVAL
The sum of the
.I iov_len
values overflows an
.B ssize_t
value. Or,
the vector count \fIcount\fR is zero or greater than \fBMAX_IOVEC\fR.
.SH "CONFORMING TO"
4.4BSD (the
.B readv
and
.B writev
functions first appeared in 4.2BSD), Unix98, POSIX 1003.1-2001.
2004-11-03 13:51:07 +00:00
Linux libc5 used \fBsize_t\fR as the type of the \fIcount\fR parameter,
and \fBint\fP as return type for these functions.
.\" The readv/writev system calls were buggy before Linux 1.3.40.
.\" (Says release.libc.)
.SH BUGS
It is not advisable to mix calls to functions like
.B readv()
or
.BR writev() ,
which operate on file descriptors, with the functions from the stdio
library; the results will be undefined and probably not what you want.
.SH "SEE ALSO"
.BR read (2),
.BR write (2)