1AIO_READ(3P) POSIX Programmer's Manual AIO_READ(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 aio_read — asynchronous read from a file
14
16 #include <aio.h>
17
18 int aio_read(struct aiocb *aiocbp);
19
21 The aio_read() function shall read aiocbp->aio_nbytes from the file
22 associated with aiocbp->aio_fildes into the buffer pointed to by
23 aiocbp->aio_buf. The function call shall return when the read request
24 has been initiated or queued to the file or device (even when the data
25 cannot be delivered immediately).
26
27 If prioritized I/O is supported for this file, then the asynchronous
28 operation shall be submitted at a priority equal to a base scheduling
29 priority minus aiocbp->aio_reqprio. If Thread Execution Scheduling is
30 not supported, then the base scheduling priority is that of the calling
31 process;
32 otherwise, the base scheduling priority is that of the calling thread.
33
34 The aiocbp value may be used as an argument to aio_error() and
35 aio_return() in order to determine the error status and return status,
36 respectively, of the asynchronous operation while it is proceeding. If
37 an error condition is encountered during queuing, the function call
38 shall return without having initiated or queued the request. The
39 requested operation takes place at the absolute position in the file as
40 given by aio_offset, as if lseek() were called immediately prior to the
41 operation with an offset equal to aio_offset and a whence equal to
42 SEEK_SET. After a successful call to enqueue an asynchronous I/O oper‐
43 ation, the value of the file offset for the file is unspecified.
44
45 The aio_sigevent member specifies the notification which occurs when
46 the request is completed.
47
48 The aiocbp->aio_lio_opcode field shall be ignored by aio_read().
49
50 The aiocbp argument points to an aiocb structure. If the buffer pointed
51 to by aiocbp->aio_buf or the control block pointed to by aiocbp becomes
52 an illegal address prior to asynchronous I/O completion, then the
53 behavior is undefined.
54
55 Simultaneous asynchronous operations using the same aiocbp produce
56 undefined results.
57
58 If synchronized I/O is enabled on the file associated with
59 aiocbp->aio_fildes, the behavior of this function shall be according to
60 the definitions of synchronized I/O data integrity completion and syn‐
61 chronized I/O file integrity completion.
62
63 For any system action that changes the process memory space while an
64 asynchronous I/O is outstanding to the address range being changed, the
65 result of that action is undefined.
66
67 For regular files, no data transfer shall occur past the offset maximum
68 established in the open file description associated with
69 aiocbp->aio_fildes.
70
72 The aio_read() function shall return the value zero if the I/O opera‐
73 tion is successfully queued; otherwise, the function shall return the
74 value −1 and set errno to indicate the error.
75
77 The aio_read() function shall fail if:
78
79 EAGAIN The requested asynchronous I/O operation was not queued due to
80 system resource limitations.
81
82 Each of the following conditions may be detected synchronously at the
83 time of the call to aio_read(), or asynchronously. If any of the condi‐
84 tions below are detected synchronously, the aio_read() function shall
85 return −1 and set errno to the corresponding value. If any of the con‐
86 ditions below are detected asynchronously, the return status of the
87 asynchronous operation is set to −1, and the error status of the asyn‐
88 chronous operation is set to the corresponding value.
89
90 EBADF The aiocbp->aio_fildes argument is not a valid file descriptor
91 open for reading.
92
93 EINVAL The file offset value implied by aiocbp->aio_offset would be
94 invalid,
95 aiocbp->aio_reqprio is not a valid value, or aiocbp->aio_nbytes
96 is an invalid value.
97
98 In the case that the aio_read() successfully queues the I/O operation
99 but the operation is subsequently canceled or encounters an error, the
100 return status of the asynchronous operation is one of the values nor‐
101 mally returned by the read() function call. In addition, the error sta‐
102 tus of the asynchronous operation is set to one of the error statuses
103 normally set by the read() function call, or one of the following val‐
104 ues:
105
106 EBADF The aiocbp->aio_fildes argument is not a valid file descriptor
107 open for reading.
108
109 ECANCELED
110 The requested I/O was canceled before the I/O completed due to
111 an explicit aio_cancel() request.
112
113 EINVAL The file offset value implied by aiocbp->aio_offset would be
114 invalid.
115
116 The following condition may be detected synchronously or asyn‐
117 chronously:
118
119 EOVERFLOW
120 The file is a regular file, aiobcp->aio_nbytes is greater than
121 0, and the starting offset in aiobcp->aio_offset is before the
122 end-of-file and is at or beyond the offset maximum in the open
123 file description associated with aiocbp->aio_fildes.
124
125 The following sections are informative.
126
128 None.
129
131 None.
132
134 None.
135
137 None.
138
140 aio_cancel(), aio_error(), lio_listio(), aio_return(), aio_write(),
141 close(), exec, exit(), fork(), lseek(), read()
142
143 The Base Definitions volume of POSIX.1‐2008, <aio.h>
144
146 Portions of this text are reprinted and reproduced in electronic form
147 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
148 -- Portable Operating System Interface (POSIX), The Open Group Base
149 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
150 cal and Electronics Engineers, Inc and The Open Group. (This is
151 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
152 event of any discrepancy between this version and the original IEEE and
153 The Open Group Standard, the original IEEE and The Open Group Standard
154 is the referee document. The original Standard can be obtained online
155 at http://www.unix.org/online.html .
156
157 Any typographical or formatting errors that appear in this page are
158 most likely to have been introduced during the conversion of the source
159 files to man page format. To report such errors, see https://www.ker‐
160 nel.org/doc/man-pages/reporting_bugs.html .
161
162
163
164IEEE/The Open Group 2013 AIO_READ(3P)