1 .\" Copyright (c) 1998 Terry Lambert
2 .\" 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.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $FreeBSD: src/lib/libc/sys/aio_read.2,v 1.19 2003/01/14 02:37:06 tjr Exp $
32 .Nd asynchronous read from a file (REALTIME)
39 .Fa "struct aiocb *aiocbp"
44 system call allows the calling process to read
45 .Fa aiocbp->aio_nbytes
47 .Fa aiocbp->aio_fildes ,
48 beginning at the offset
49 .Fa aiocbp->aio_offset ,
50 into the buffer pointed to by
52 The call returns immediately after the read request has
53 been enqueued to the descriptor;
54 the read may or may not have completed at the time the call returns.
56 If _POSIX_PRIORITIZED_IO is defined, and the descriptor supports it,
57 then the enqueued operation is submitted at a priority equal to that
58 of the calling process minus
59 .Fa aiocbp->aio_reqprio .
62 .Fa aiocbp->aio_lio_opcode
70 pointer may be subsequently used as an argument to
74 in order to determine return or error status for the enqueued operation
75 while it is in progress.
77 If the request could not be enqueued (generally due to invalid arguments),
78 then the call returns without having enqueued the request.
80 If the request is successfully enqueued, the value of
81 .Fa aiocbp->aio_offset
82 can be modified during the request as context, so this value must
83 not be referenced after the request is enqueued.
85 The Asynchronous I/O Control Block structure pointed to by
87 and the buffer that the
89 member of that structure references must remain valid until the
90 operation has completed. For this reason, use of auto (stack) variables
91 for these objects is discouraged.
93 The asynchronous I/O control buffer
95 should be zeroed before the
97 call to avoid passing bogus context information to the kernel.
99 Modifications of the Asynchronous I/O Control Block structure or the
100 buffer contents after the request has been enqueued, but before the
101 request has completed, are not allowed.
103 If the file offset in
104 .Fa aiocbp->aio_offset
105 is past the offset maximum for
106 .Fa aiocbp->aio_fildes ,
115 system call will fail if:
119 Because of system resource limitations,
120 the request was not queued.
125 system call is not supported.
128 The following conditions may be synchronously detected when the
130 system call is made, or asynchronously, at any time thereafter.
131 If they are detected at call time,
138 system call must be called.
141 must then be called to determine the actual value
142 that would have been returned in
149 .Fa aiocbp->aio_fildes
155 .Fa aiocbp->aio_offset
156 is not valid, the priority specified by
157 .Fa aiocbp->aio_reqprio
158 is not a valid priority, or the number of bytes specified by
159 .Fa aiocbp->aio_nbytes
163 The file is a regular file,
164 .Fa aiocbp->aio_nbytes
165 is greater than zero, the starting offset in
166 .Fa aiocbp->aio_offset
167 is before the end of the file, but is at or beyond the
168 .Fa aiocbp->aio_fildes
172 If the request is successfully enqueued, but subsequently cancelled
173 or an error occurs, the value returned by the
175 system call is per the
177 system call, and the value returned by the
179 system call is either one of the error returns from the
181 system call, or one of:
186 .Fa aiocbp->aio_fildes
188 is invalid for reading.
191 The request was explicitly cancelled via a call to
196 .Fa aiocbp->aio_offset
209 system call is expected to conform to the
215 system call first appeared in
219 manual page was written by
220 .An Terry Lambert Aq terry@whistle.com .
222 Invalid information in
223 .Fa aiocbp->_aiocb_private
224 may confuse the kernel.