|
Packit |
7cfc04 |
.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
|
|
Packit |
7cfc04 |
.\" This is free documentation; you can redistribute it and/or
|
|
Packit |
7cfc04 |
.\" modify it under the terms of the GNU General Public License as
|
|
Packit |
7cfc04 |
.\" published by the Free Software Foundation; either version 2 of
|
|
Packit |
7cfc04 |
.\" the License, or (at your option) any later version.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" The GNU General Public License's references to "object code"
|
|
Packit |
7cfc04 |
.\" and "executables" are to be interpreted as the output of any
|
|
Packit |
7cfc04 |
.\" document formatting or typesetting system, including
|
|
Packit |
7cfc04 |
.\" intermediate and printed output.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" This manual is distributed in the hope that it will be useful,
|
|
Packit |
7cfc04 |
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
7cfc04 |
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
7cfc04 |
.\" GNU General Public License for more details.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" You should have received a copy of the GNU General Public
|
|
Packit |
7cfc04 |
.\" License along with this manual; if not, see
|
|
Packit |
7cfc04 |
.\" <http://www.gnu.org/licenses/>.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH AIO_READ 3 2017-09-15 "" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
aio_read \- asynchronous read
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.B "#include <aio.h>"
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int aio_read(struct aiocb *" aiocbp );
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Link with \fI\-lrt\fP.
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR aio_read ()
|
|
Packit |
7cfc04 |
function queues the I/O request described by the buffer pointed to by
|
|
Packit |
7cfc04 |
.IR aiocbp .
|
|
Packit |
7cfc04 |
This function is the asynchronous analog of
|
|
Packit |
7cfc04 |
.BR read (2).
|
|
Packit |
7cfc04 |
The arguments of the call
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
read(fd, buf, count)
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
correspond (in order) to the fields
|
|
Packit |
7cfc04 |
.IR aio_fildes ,
|
|
Packit |
7cfc04 |
.IR aio_buf ,
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.IR aio_nbytes
|
|
Packit |
7cfc04 |
of the structure pointed to by
|
|
Packit |
7cfc04 |
.IR aiocbp .
|
|
Packit |
7cfc04 |
(See
|
|
Packit |
7cfc04 |
.BR aio (7)
|
|
Packit |
7cfc04 |
for a description of the
|
|
Packit |
7cfc04 |
.I aiocb
|
|
Packit |
7cfc04 |
structure.)
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The data is read starting at the absolute position
|
|
Packit |
7cfc04 |
.IR aiocbp\->aio_offset ,
|
|
Packit |
7cfc04 |
regardless of the file offset.
|
|
Packit |
7cfc04 |
After the call,
|
|
Packit |
7cfc04 |
the value of the file offset is unspecified.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The "asynchronous" means that this call returns as soon as the
|
|
Packit |
7cfc04 |
request has been enqueued; the read may or may not have completed
|
|
Packit |
7cfc04 |
when the call returns.
|
|
Packit |
7cfc04 |
One tests for completion using
|
|
Packit |
7cfc04 |
.BR aio_error (3).
|
|
Packit |
7cfc04 |
The return status of a completed I/O operation can be obtained by
|
|
Packit |
7cfc04 |
.BR aio_return (3).
|
|
Packit |
7cfc04 |
Asynchronous notification of I/O completion can be obtained by setting
|
|
Packit |
7cfc04 |
.IR aiocbp\->aio_sigevent
|
|
Packit |
7cfc04 |
appropriately; see
|
|
Packit |
7cfc04 |
.BR sigevent (7)
|
|
Packit |
7cfc04 |
for details.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.B _POSIX_PRIORITIZED_IO
|
|
Packit |
7cfc04 |
is defined, and this file supports it,
|
|
Packit |
7cfc04 |
then the asynchronous operation is submitted at a priority equal
|
|
Packit |
7cfc04 |
to that of the calling process minus
|
|
Packit |
7cfc04 |
.IR aiocbp\->aio_reqprio .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The field
|
|
Packit |
7cfc04 |
.I aiocbp\->aio_lio_opcode
|
|
Packit |
7cfc04 |
is ignored.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
No data is read from a regular file beyond its maximum offset.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
On success, 0 is returned.
|
|
Packit |
7cfc04 |
On error, the request is not enqueued, \-1
|
|
Packit |
7cfc04 |
is returned, and
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set appropriately.
|
|
Packit |
7cfc04 |
If an error is detected only later, it will
|
|
Packit |
7cfc04 |
be reported via
|
|
Packit |
7cfc04 |
.BR aio_return (3)
|
|
Packit |
7cfc04 |
(returns status \-1) and
|
|
Packit |
7cfc04 |
.BR aio_error (3)
|
|
Packit |
7cfc04 |
(error status\(emwhatever one would have gotten in
|
|
Packit |
7cfc04 |
.IR errno ,
|
|
Packit |
7cfc04 |
such as
|
|
Packit |
7cfc04 |
.BR EBADF ).
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EAGAIN
|
|
Packit |
7cfc04 |
Out of resources.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EBADF
|
|
Packit |
7cfc04 |
.I aio_fildes
|
|
Packit |
7cfc04 |
is not a valid file descriptor open for reading.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EINVAL
|
|
Packit |
7cfc04 |
One or more of
|
|
Packit |
7cfc04 |
.IR aio_offset ,
|
|
Packit |
7cfc04 |
.IR aio_reqprio ,
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.I aio_nbytes
|
|
Packit |
7cfc04 |
are invalid.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B ENOSYS
|
|
Packit |
7cfc04 |
.BR aio_read ()
|
|
Packit |
7cfc04 |
is not implemented.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EOVERFLOW
|
|
Packit |
7cfc04 |
The file is a regular file, we start reading before end-of-file
|
|
Packit |
7cfc04 |
and want at least one byte, but the starting position is past
|
|
Packit |
7cfc04 |
the maximum offset for this file.
|
|
Packit |
7cfc04 |
.SH VERSIONS
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR aio_read ()
|
|
Packit |
7cfc04 |
function is available since glibc 2.1.
|
|
Packit |
7cfc04 |
.SH ATTRIBUTES
|
|
Packit |
7cfc04 |
For an explanation of the terms used in this section, see
|
|
Packit |
7cfc04 |
.BR attributes (7).
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
allbox;
|
|
Packit |
7cfc04 |
lb lb lb
|
|
Packit |
7cfc04 |
l l l.
|
|
Packit |
7cfc04 |
Interface Attribute Value
|
|
Packit |
7cfc04 |
T{
|
|
Packit |
7cfc04 |
.BR aio_read ()
|
|
Packit |
7cfc04 |
T} Thread safety MT-Safe
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
It is a good idea to zero out the control block before use.
|
|
Packit |
7cfc04 |
The control block must not be changed while the read operation
|
|
Packit |
7cfc04 |
is in progress.
|
|
Packit |
7cfc04 |
The buffer area being read into
|
|
Packit |
7cfc04 |
.\" or the control block of the operation
|
|
Packit |
7cfc04 |
must not be accessed during the operation or undefined results may occur.
|
|
Packit |
7cfc04 |
The memory areas involved must remain valid.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Simultaneous I/O operations specifying the same
|
|
Packit |
7cfc04 |
.I aiocb
|
|
Packit |
7cfc04 |
structure produce undefined results.
|
|
Packit |
7cfc04 |
.SH EXAMPLE
|
|
Packit |
7cfc04 |
See
|
|
Packit |
7cfc04 |
.BR aio (7).
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR aio_cancel (3),
|
|
Packit |
7cfc04 |
.BR aio_error (3),
|
|
Packit |
7cfc04 |
.BR aio_fsync (3),
|
|
Packit |
7cfc04 |
.BR aio_return (3),
|
|
Packit |
7cfc04 |
.BR aio_suspend (3),
|
|
Packit |
7cfc04 |
.BR aio_write (3),
|
|
Packit |
7cfc04 |
.BR lio_listio (3),
|
|
Packit |
7cfc04 |
.BR aio (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|