]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/aio_read.3
d6eb83a3a0f01bba5c7496140bc65722261302c2
[thirdparty/man-pages.git] / man3 / aio_read.3
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" SPDX-License-Identifier: GPL-2.0-or-later
4 .\"
5 .TH AIO_READ 3 2021-03-22 "" "Linux Programmer's Manual"
6 .SH NAME
7 aio_read \- asynchronous read
8 .SH LIBRARY
9 Real-time library
10 .RI ( librt ", " \-lrt )
11 .SH SYNOPSIS
12 .nf
13 .B "#include <aio.h>"
14 .PP
15 .BI "int aio_read(struct aiocb *" aiocbp );
16 .fi
17 .SH DESCRIPTION
18 The
19 .BR aio_read ()
20 function queues the I/O request described by the buffer pointed to by
21 .IR aiocbp .
22 This function is the asynchronous analog of
23 .BR read (2).
24 The arguments of the call
25 .PP
26 read(fd, buf, count)
27 .PP
28 correspond (in order) to the fields
29 .IR aio_fildes ,
30 .IR aio_buf ,
31 and
32 .IR aio_nbytes
33 of the structure pointed to by
34 .IR aiocbp .
35 (See
36 .BR aio (7)
37 for a description of the
38 .I aiocb
39 structure.)
40 .PP
41 The data is read starting at the absolute position
42 .IR aiocbp\->aio_offset ,
43 regardless of the file offset.
44 After the call,
45 the value of the file offset is unspecified.
46 .PP
47 The "asynchronous" means that this call returns as soon as the
48 request has been enqueued; the read may or may not have completed
49 when the call returns.
50 One tests for completion using
51 .BR aio_error (3).
52 The return status of a completed I/O operation can be obtained by
53 .BR aio_return (3).
54 Asynchronous notification of I/O completion can be obtained by setting
55 .IR aiocbp\->aio_sigevent
56 appropriately; see
57 .BR sigevent (7)
58 for details.
59 .PP
60 If
61 .B _POSIX_PRIORITIZED_IO
62 is defined, and this file supports it,
63 then the asynchronous operation is submitted at a priority equal
64 to that of the calling process minus
65 .IR aiocbp\->aio_reqprio .
66 .PP
67 The field
68 .I aiocbp\->aio_lio_opcode
69 is ignored.
70 .PP
71 No data is read from a regular file beyond its maximum offset.
72 .SH RETURN VALUE
73 On success, 0 is returned.
74 On error, the request is not enqueued, \-1
75 is returned, and
76 .I errno
77 is set to indicate the error.
78 If an error is detected only later, it will
79 be reported via
80 .BR aio_return (3)
81 (returns status \-1) and
82 .BR aio_error (3)
83 (error status\(emwhatever one would have gotten in
84 .IR errno ,
85 such as
86 .BR EBADF ).
87 .SH ERRORS
88 .TP
89 .B EAGAIN
90 Out of resources.
91 .TP
92 .B EBADF
93 .I aio_fildes
94 is not a valid file descriptor open for reading.
95 .TP
96 .B EINVAL
97 One or more of
98 .IR aio_offset ,
99 .IR aio_reqprio ,
100 or
101 .I aio_nbytes
102 are invalid.
103 .TP
104 .B ENOSYS
105 .BR aio_read ()
106 is not implemented.
107 .TP
108 .B EOVERFLOW
109 The file is a regular file, we start reading before end-of-file
110 and want at least one byte, but the starting position is past
111 the maximum offset for this file.
112 .SH VERSIONS
113 The
114 .BR aio_read ()
115 function is available since glibc 2.1.
116 .SH ATTRIBUTES
117 For an explanation of the terms used in this section, see
118 .BR attributes (7).
119 .ad l
120 .nh
121 .TS
122 allbox;
123 lbx lb lb
124 l l l.
125 Interface Attribute Value
126 T{
127 .BR aio_read ()
128 T} Thread safety MT-Safe
129 .TE
130 .hy
131 .ad
132 .sp 1
133 .SH CONFORMING TO
134 POSIX.1-2001, POSIX.1-2008.
135 .SH NOTES
136 It is a good idea to zero out the control block before use.
137 The control block must not be changed while the read operation
138 is in progress.
139 The buffer area being read into
140 .\" or the control block of the operation
141 must not be accessed during the operation or undefined results may occur.
142 The memory areas involved must remain valid.
143 .PP
144 Simultaneous I/O operations specifying the same
145 .I aiocb
146 structure produce undefined results.
147 .SH EXAMPLES
148 See
149 .BR aio (7).
150 .SH SEE ALSO
151 .BR aio_cancel (3),
152 .BR aio_error (3),
153 .BR aio_fsync (3),
154 .BR aio_return (3),
155 .BR aio_suspend (3),
156 .BR aio_write (3),
157 .BR lio_listio (3),
158 .BR aio (7)