1aio_read(3)                Library Functions Manual                aio_read(3)
2
3
4

NAME

6       aio_read - asynchronous read
7

LIBRARY

9       Real-time library (librt, -lrt)
10

SYNOPSIS

12       #include <aio.h>
13
14       int aio_read(struct aiocb *aiocbp);
15

DESCRIPTION

17       The  aio_read() function queues the I/O request described by the buffer
18       pointed to by aiocbp.  This function  is  the  asynchronous  analog  of
19       read(2).  The arguments of the call
20
21           read(fd, buf, count)
22
23       correspond (in order) to the fields aio_fildes, aio_buf, and aio_nbytes
24       of the structure pointed to by aiocbp.  (See aio(7) for  a  description
25       of the aiocb structure.)
26
27       The  data is read starting at the absolute position aiocbp->aio_offset,
28       regardless of the file offset.  After the call, the value of  the  file
29       offset is unspecified.
30
31       The  "asynchronous" means that this call returns as soon as the request
32       has been enqueued; the read may or may not have completed when the call
33       returns.  One tests for completion using aio_error(3).  The return sta‐
34       tus of a completed I/O operation  can  be  obtained  by  aio_return(3).
35       Asynchronous  notification of I/O completion can be obtained by setting
36       aiocbp->aio_sigevent appropriately; see sigevent(7) for details.
37
38       If _POSIX_PRIORITIZED_IO is defined, and this file  supports  it,  then
39       the  asynchronous operation is submitted at a priority equal to that of
40       the calling process minus aiocbp->aio_reqprio.
41
42       The field aiocbp->aio_lio_opcode is ignored.
43
44       No data is read from a regular file beyond its maximum offset.
45

RETURN VALUE

47       On success, 0 is returned.  On error, the request is not  enqueued,  -1
48       is  returned,  and  errno is set to indicate the error.  If an error is
49       detected only later, it will be  reported  via  aio_return(3)  (returns
50       status  -1) and aio_error(3) (error status—whatever one would have got‐
51       ten in errno, such as EBADF).
52

ERRORS

54       EAGAIN Out of resources.
55
56       EBADF  aio_fildes is not a valid file descriptor open for reading.
57
58       EINVAL One or more of aio_offset, aio_reqprio, or  aio_nbytes  are  in‐
59              valid.
60
61       ENOSYS aio_read() is not implemented.
62
63       EOVERFLOW
64              The  file is a regular file, we start reading before end-of-file
65              and want at least one byte, but the starting  position  is  past
66              the maximum offset for this file.
67

ATTRIBUTES

69       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
70       tributes(7).
71
72       ┌────────────────────────────────────────────┬───────────────┬─────────┐
73Interface                                   Attribute     Value   
74       ├────────────────────────────────────────────┼───────────────┼─────────┤
75aio_read()                                  │ Thread safety │ MT-Safe │
76       └────────────────────────────────────────────┴───────────────┴─────────┘
77

STANDARDS

79       POSIX.1-2008.
80

HISTORY

82       glibc 2.1.  POSIX.1-2001.
83

NOTES

85       It is a good idea to zero out the control block before use.   The  con‐
86       trol block must not be changed while the read operation is in progress.
87       The buffer area being read into must not be accessed during the  opera‐
88       tion  or  undefined  results may occur.  The memory areas involved must
89       remain valid.
90
91       Simultaneous I/O operations specifying the same aiocb structure produce
92       undefined results.
93

EXAMPLES

95       See aio(7).
96

SEE ALSO

98       aio_cancel(3),   aio_error(3),  aio_fsync(3),  aio_return(3),  aio_sus‐
99       pend(3), aio_write(3), lio_listio(3), aio(7)
100
101
102
103Linux man-pages 6.04              2023-03-30                       aio_read(3)
Impressum