1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)read.2 8.4 (Berkeley) 2/26/94
33 .\" $FreeBSD: src/lib/libc/sys/read.2,v 1.9.2.6 2001/12/14 18:34:01 ru Exp $
66 .Fa "const struct iovec *iov"
73 .Fa "const struct iovec *iov"
80 bytes of data from the object referenced by the descriptor
82 into the buffer pointed to by
85 performs the same action,
86 but scatters the input data into the
88 buffers specified by the members of the
90 array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
94 perform the same functions,
95 but read from the specified position in the file
96 without modifying the file pointer.
104 structure is defined as:
106 .Bd -literal -offset indent -compact
108 char *iov_base; /* Base address. */
109 size_t iov_len; /* Length. */
115 entry specifies the base address and length of an area
116 in memory where data should be placed.
120 will always fill an area completely before proceeding
123 On objects capable of seeking, the
126 given by the pointer associated with
132 the pointer is incremented by the number of bytes actually read.
134 Objects that are not capable of seeking always read from the current
135 position. The value of the pointer associated with such an
138 Upon successful completion,
144 return the number of bytes actually read and placed in the buffer.
145 The system guarantees to read the number of bytes requested if
146 the descriptor references a normal file that has that many bytes left
147 before the end-of-file, but in no other case.
150 number of bytes actually read is returned.
151 Upon reading end-of-file,
153 Otherwise, a -1 is returned and the global variable
155 is set to indicate the error.
168 The file was marked for non-blocking I/O,
169 and no data were ready to be read.
173 is not a valid file or socket descriptor open for reading.
177 points outside the allocated address space.
180 A read from a slow device was interrupted before
181 any data arrived by the delivery of a signal.
183 The pointer associated with
188 An I/O error occurred while reading from the file system.
191 .\" The process is a member of a background process
192 .\" attempting to read from its controlling terminal.
195 .\" The process is ignoring or blocking the SIGTTIN signal.
198 The process group is orphaned.
201 The file is a regular file,
204 the starting position is before the end-of-file,
205 and the starting position is greater than or equal
206 to the offset maximum established
207 for the open file descriptor associated with
211 An attempt is made to read a directory.
214 An attempt to allocate a memory buffer fails.
217 Insufficient memory is available.
220 An action is requested of a device that does not exist.
223 A requested action cannot be performed by the device.
226 An attempt to read a remote file through NFS that has already been deleted in
230 The connection timed out while reading a remote file from a soft mounted NFS
238 calls may also return the following errors:
242 The specified file offset is invalid.
245 The file descriptor is associated with a pipe, socket, or FIFO.
250 call may also return the following errors:
254 The connection is closed by the peer
255 during a read attempt on a socket.
258 A read is attempted on an unconnected socket.
261 A transmission timeout occurs
262 during a read attempt on a socket.
269 calls may also return one of the following errors:
275 points outside the process's allocated address space.
279 was less than or equal to 0, or greater than 16.
293 array overflowed a 32-bit integer.
296 .Fd #include <sys/types.h>
297 .Fd #include <sys/uio.h>
298 .Fd #include <unistd.h>
304 are necessary for all functions.
317 function call is expected to conform to
323 functions are expected to conform to
340 function call appeared in