OSDN Git Service

(split) LDP_man-pages: update original to v3.35.
[linuxjm/LDP_man-pages.git] / original / man3 / aio_read.3
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .TH AIO_READ 3 2010-10-03  "" "Linux Programmer's Manual"
24 .SH NAME
25 aio_read \- asynchronous read
26 .SH SYNOPSIS
27 .B "#include <aio.h>"
28 .sp
29 .BI "int aio_read(struct aiocb *" aiocbp );
30 .sp
31 Link with \fI\-lrt\fP.
32 .SH DESCRIPTION
33 The
34 .BR aio_read ()
35 function queues the I/O request described by the buffer pointed to by
36 .IR aiocbp .
37 This function is the asynchronous analog of
38 .BR read (2).
39 The arguments of the call
40
41     read(fd, buf, count)
42
43 correspond (in order) to the fields
44 .IR aio_fildes ,
45 .IR aio_buf ,
46 and
47 .IR aio_nbytes
48 of the structure pointed to by
49 .IR aiocbp .
50 (See
51 .BR aio (7)
52 for a description of the
53 .I aiocb
54 structure.)
55 .LP
56 The data is read starting at the absolute file offset
57 .IR aiocbp\->aio_offset ,
58 regardless of the current file offset.
59 After the call,
60 the value of the current file offset is unspecified.
61 .LP
62 The "asynchronous" means that this call returns as soon as the
63 request has been enqueued; the read may or may not have completed
64 when the call returns.
65 One tests for completion using
66 .BR aio_error (3).
67 The return status of a completed I/O operation can be obtained
68 .BR aio_return (3).
69 Asynchronous notification of I/O completion can be obtained by setting
70 .IR aiocbp\->aio_sigevent
71 appropriately; see
72 .BR sigevent (7)
73 for details.
74 .LP
75 If
76 .B _POSIX_PRIORITIZED_IO
77 is defined, and this file supports it,
78 then the asynchronous operation is submitted at a priority equal
79 to that of the calling process minus
80 .IR aiocbp\->aio_reqprio .
81 .LP
82 The field
83 .I aiocbp\->aio_lio_opcode
84 is ignored.
85 .LP
86 No data is read from a regular file beyond its maximum offset.
87 .SH "RETURN VALUE"
88 On success, 0 is returned.
89 On error the request is not enqueued, \-1
90 is returned, and
91 .I errno
92 is set appropriately.
93 If an error is only detected later, it will
94 be reported via
95 .BR aio_return (3)
96 (returns status \-1) and
97 .BR aio_error (3)
98 (error status\(emwhatever one would have gotten in
99 .IR errno ,
100 such as
101 .BR EBADF ).
102 .SH ERRORS
103 .TP
104 .B EAGAIN
105 Out of resources.
106 .TP
107 .B EBADF
108 .I aio_fildes
109 is not a valid file descriptor open for reading.
110 .TP
111 .B EINVAL
112 One or more of
113 .IR aio_offset ,
114 .IR aio_reqprio ,
115 or
116 .I aio_nbytes
117 are invalid.
118 .TP
119 .B ENOSYS
120 This function is not supported.
121 .TP
122 .B EOVERFLOW
123 The file is a regular file, we start reading before end-of-file
124 and want at least one byte, but the starting position is past
125 the maximum offset for this file.
126 .SH VERSIONS
127 The
128 .BR aio_read ()
129 function is available since glibc 2.1.
130 .SH "CONFORMING TO"
131 POSIX.1-2001, POSIX.1-2008.
132 .SH NOTES
133 It is a good idea to zero out the control block before use.
134 The control block must not be changed while the read operation
135 is in progress.
136 The buffer area being read into
137 .\" or the control block of the operation
138 must not be accessed during the operation or undefined results may occur.
139 The memory areas involved must remain valid.
140
141 Simultaneous I/O operations specifying the same
142 .I aiocb
143 structure produce undefined results.
144 .SH EXAMPLE
145 See
146 .BR aio (7).
147 .SH "SEE ALSO"
148 .BR aio_cancel (3),
149 .BR aio_error (3),
150 .BR aio_fsync (3),
151 .BR aio_return (3),
152 .BR aio_suspend (3),
153 .BR aio_write (3),
154 .BR lio_listio (3),
155 .BR aio (7)