]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man2/aio_read.2
xnu-3789.1.32.tar.gz
[apple/xnu.git] / bsd / man / man2 / aio_read.2
CommitLineData
91447636
A
1.\" Copyright (c) 1998 Terry Lambert
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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.\"
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
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD: src/lib/libc/sys/aio_read.2,v 1.19 2003/01/14 02:37:06 tjr Exp $
26.\"
27.Dd November 17, 1998
28.Dt AIO_READ 2
29.Os
30.Sh NAME
31.Nm aio_read
32.Nd asynchronous read from a file (REALTIME)
33.Sh LIBRARY
34.Lb libc
35.Sh SYNOPSIS
36.In aio.h
37.Ft int
2d21ac55
A
38.Fo aio_read
39.Fa "struct aiocb *aiocbp"
40.Fc
91447636
A
41.Sh DESCRIPTION
42The
43.Fn aio_read
44system call allows the calling process to read
2d21ac55 45.Fa aiocbp->aio_nbytes
91447636 46from the descriptor
2d21ac55 47.Fa aiocbp->aio_fildes ,
91447636 48beginning at the offset
2d21ac55 49.Fa aiocbp->aio_offset ,
91447636 50into the buffer pointed to by
2d21ac55 51.Fa aiocbp->aio_buf .
91447636 52The call returns immediately after the read request has
2d21ac55
A
53been enqueued to the descriptor;
54the read may or may not have completed at the time the call returns.
91447636
A
55.Pp
56If _POSIX_PRIORITIZED_IO is defined, and the descriptor supports it,
57then the enqueued operation is submitted at a priority equal to that
58of the calling process minus
2d21ac55 59.Fa aiocbp->aio_reqprio .
91447636
A
60.Pp
61The
2d21ac55 62.Fa aiocbp->aio_lio_opcode
91447636
A
63argument
64is ignored by the
65.Fn aio_read
66system call.
67.Pp
68The
2d21ac55 69.Fa aiocbp
91447636
A
70pointer may be subsequently used as an argument to
71.Fn aio_return
72and
73.Fn aio_error
74in order to determine return or error status for the enqueued operation
75while it is in progress.
76.Pp
77If the request could not be enqueued (generally due to invalid arguments),
78then the call returns without having enqueued the request.
79.Pp
80If the request is successfully enqueued, the value of
2d21ac55 81.Fa aiocbp->aio_offset
91447636
A
82can be modified during the request as context, so this value must
83not be referenced after the request is enqueued.
84.Sh RESTRICTIONS
85The Asynchronous I/O Control Block structure pointed to by
2d21ac55 86.Fa aiocbp
91447636 87and the buffer that the
2d21ac55 88.Fa aiocbp->aio_buf
91447636
A
89member of that structure references must remain valid until the
90operation has completed. For this reason, use of auto (stack) variables
91for these objects is discouraged.
92.Pp
93The asynchronous I/O control buffer
2d21ac55 94.Fa aiocbp
91447636
A
95should be zeroed before the
96.Fn aio_read
97call to avoid passing bogus context information to the kernel.
98.Pp
99Modifications of the Asynchronous I/O Control Block structure or the
100buffer contents after the request has been enqueued, but before the
101request has completed, are not allowed.
102.Pp
103If the file offset in
2d21ac55 104.Fa aiocbp->aio_offset
91447636 105is past the offset maximum for
2d21ac55 106.Fa aiocbp->aio_fildes ,
91447636
A
107no I/O will occur.
108.Sh RETURN VALUES
109.Rv -std aio_read
110.Sh DIAGNOSTICS
111None.
112.Sh ERRORS
113The
114.Fn aio_read
115system call will fail if:
116.Bl -tag -width Er
2d21ac55 117.\" ==========
91447636 118.It Bq Er EAGAIN
2d21ac55
A
119Because of system resource limitations,
120the request was not queued.
121.\" ==========
91447636
A
122.It Bq Er ENOSYS
123The
124.Fn aio_read
125system call is not supported.
126.El
127.Pp
128The following conditions may be synchronously detected when the
129.Fn aio_read
2d21ac55
A
130system call is made, or asynchronously, at any time thereafter.
131If they are detected at call time,
91447636
A
132.Fn aio_read
133returns -1 and sets
134.Va errno
2d21ac55
A
135appropriately.
136Otherwise, the
91447636 137.Fn aio_return
2d21ac55
A
138system call must be called.
139It will return -1;
91447636 140.Fn aio_error
2d21ac55
A
141must then be called to determine the actual value
142that would have been returned in
91447636
A
143.Va errno .
144.Pp
145.Bl -tag -width Er
2d21ac55 146.\" ==========
91447636
A
147.It Bq Er EBADF
148The
2d21ac55 149.Fa aiocbp->aio_fildes
91447636
A
150argument
151is invalid.
2d21ac55 152.\" ==========
91447636
A
153.It Bq Er EINVAL
154The offset
2d21ac55 155.Fa aiocbp->aio_offset
91447636 156is not valid, the priority specified by
2d21ac55 157.Fa aiocbp->aio_reqprio
91447636 158is not a valid priority, or the number of bytes specified by
2d21ac55 159.Fa aiocbp->aio_nbytes
91447636 160is not valid.
2d21ac55 161.\" ==========
91447636
A
162.It Bq Er EOVERFLOW
163The file is a regular file,
2d21ac55 164.Fa aiocbp->aio_nbytes
91447636 165is greater than zero, the starting offset in
2d21ac55 166.Fa aiocbp->aio_offset
91447636 167is before the end of the file, but is at or beyond the
2d21ac55 168.Fa aiocbp->aio_fildes
91447636
A
169offset maximum.
170.El
171.Pp
172If the request is successfully enqueued, but subsequently cancelled
173or an error occurs, the value returned by the
174.Fn aio_return
175system call is per the
176.Xr read 2
177system call, and the value returned by the
178.Fn aio_error
179system call is either one of the error returns from the
180.Xr read 2
181system call, or one of:
182.Bl -tag -width Er
2d21ac55 183.\" ==========
91447636
A
184.It Bq Er EBADF
185The
2d21ac55 186.Fa aiocbp->aio_fildes
91447636
A
187argument
188is invalid for reading.
2d21ac55 189.\" ==========
91447636
A
190.It Bq Er ECANCELED
191The request was explicitly cancelled via a call to
192.Fn aio_cancel .
2d21ac55 193.\" ==========
91447636
A
194.It Bq Er EINVAL
195The offset
2d21ac55 196.Fa aiocbp->aio_offset
91447636
A
197would be invalid.
198.El
199.Sh SEE ALSO
200.Xr aio_cancel 2 ,
201.Xr aio_error 2 ,
202.Xr aio_return 2 ,
203.Xr aio_suspend 2 ,
204.Xr aio_write 2 ,
205.Xr aio 4
206.Sh STANDARDS
207The
208.Fn aio_read
209system call is expected to conform to the
210.St -p1003.1
211standard.
212.Sh HISTORY
213The
214.Fn aio_read
215system call first appeared in
216.Fx 3.0 .
217.Sh AUTHORS
218This
219manual page was written by
220.An Terry Lambert Aq terry@whistle.com .
221.Sh BUGS
222Invalid information in
2d21ac55 223.Fa aiocbp->_aiocb_private
91447636 224may confuse the kernel.