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