lio_listio(3RT) Realtime Library Functions lio_listio(3RT)NAMElio_listio - list directed I/O
SYNOPSIS
cc [ flag... ] file... -lrt [ library... ]
#include <aio.h>
int lio_listio(int mode, struct aiocb *restrict const list[], int nent,
struct sigevent *restrict sig);
DESCRIPTION
The lio_listio() function allows the calling process, LWP, or thread,
to initiate a list of I/O requests within a single function call.
The mode argument takes one of the values LIO_WAIT or LIO_NOWAIT
declared in <aio.h> and determines whether the function returns when
the I/O operations have been completed, or as soon as the operations
have been queued. If the mode argument is LIO_WAIT, the function waits
until all I/O is complete and the sig argument is ignored.
If the mode argument is LIO_NOWAIT, the function returns immediately,
and asynchronous notification occurs, according to the sig argument,
when all the I/O operations complete. If sig is NULL, or the
sigev_signo member of the sigevent structure referenced by sig is zero,
then no asynchronous notification occurs. If sig is not NULL, asynchro‐
nous notification occurs when all the requests in list have completed.
If sig->sigev_notify is SIGEV_NONE, then no signal will be posted upon
I/O completion, but the error status and the return status for the
operation will be set appropriately. If sig->sigev_notify is SIGEV_SIG‐
NAL, then the signal specified in sig->sigev_signo will be sent to the
process. If the SA_SIGINFO flag is set for that signal number, then the
signal will be queued to the process and the value specified in
sig->sigev_value will be the si_value component of the generated signal
(see siginfo.h(3HEAD)). If sig->sigev_notify is SIGEV_PORT, then upon
I/O completion an event notification will be sent to the event port
determined in the port_notify_t structure addressed by the sival_ptr
(see signal.h(3HEAD)).
The I/O requests enumerated by list are submitted in an unspecified
order.
The list argument is an array of pointers to aiocb structures. The
array contains nent elements. The array may contain null elements,
which are ignored.
The aio_lio_opcode field of each aiocb structure specifies the opera‐
tion to be performed. The supported operations are LIO_READ, LIO_WRITE,
and LIO_NOP; these symbols are defined in <aio.h>. The LIO_NOP opera‐
tion causes the list entry to be ignored. If the aio_lio_opcode element
is equal to LIO_READ, then an I/O operation is submitted as if by a
call to aio_read(3RT) with the aiocbp equal to the address of the aiocb
structure. If the aio_lio_opcode element is equal to LIO_WRITE, then an
I/O operation is submitted as if by a call to aio_write(3RT) with the
aiocbp equal to the address of the aiocb structure.
The aio_fildes member specifies the file descriptor on which the opera‐
tion is to be performed.
The aio_buf member specifies the address of the buffer to or from which
the data is to be transferred.
The aio_nbytes member specifies the number of bytes of data to be
transferred.
The members of the aiocb structure further describe the I/O operation
to be performed, in a manner identical to that of the corresponding
aiocb structure when used by the aio_read(3RT) and aio_write(3RT) func‐
tions.
The nent argument specifies how many elements are members of the list,
that is, the length of the array.
The behavior of this function is altered according to the definitions
of synchronized I/O data integrity completion and synchronized I/O file
integrity completion if synchronized I/O is enabled on the file associ‐
ated with aio_fildes. (see fcntl.h(3HEAD) definitions of O_DSYNC and
O_SYNC.)
For regular files, no data transfer will occur past the offset maximum
established in the open file description associated with
aiocbp->aio_fildes.
RETURN VALUES
If the mode argument has the value LIO_NOWAIT, and the I/O operations
are successfully queued, lio_listio() returns 0; otherwise, it returns
−1, and sets errno to indicate the error.
If the mode argument has the value LIO_WAIT, and all the indicated
I/O has completed successfully, lio_listio() returns 0; otherwise, it
returns −1, and sets errno to indicate the error.
In either case, the return value only indicates the success or failure
of the lio_listio() call itself, not the status of the individual I/O
requests. In some cases, one or more of the I/O requests contained in
the list may fail. Failure of an individual request does not prevent
completion of any other individual request. To determine the outcome
of each I/O request, the application must examine the error status
associated with each aiocb control block. Each error status so
returned is identical to that returned as a result of an aio_read(3RT)
or aio_write(3RT) function.
ERRORS
The lio_listio() function will fail if:
EAGAIN The resources necessary to queue all the I/O requests
were not available. The error status for each request
is recorded in the aio_error member of the correspond‐
ing aiocb structure, and can be retrieved using
aio_error(3RT).
EAGAIN The number of entries indicated by nent would cause the
system-wide limit AIO_MAX to be exceeded.
EINVAL The mode argument is an improper value, or the value of
nent is greater than AIO_LISTIO_MAX.
EINTR A signal was delivered while waiting for all I/O
requests to complete during an LIO_WAIT operation. Note
that, since each I/O operation invoked by lio_listio()
may possibly provoke a signal when it completes, this
error return may be caused by the completion of one (or
more) of the very I/O operations being awaited. Out‐
standing I/O requests are not canceled, and the appli‐
cation can use aio_fsync(3RT) to determine if any
request was initiated; aio_return(3RT) to determine if
any request has completed; or aio_error(3RT) to deter‐
mine if any request was canceled.
EIO One or more of the individual I/O operations failed.
The application can use aio_error(3RT) to check the
error status for each aiocb structure to determine the
individual request(s) that failed.
ENOSYS The lio_listio() function is not supported by the sys‐
tem.
In addition to the errors returned by the lio_listio() function, if the
lio_listio() function succeeds or fails with errors of EAGAIN, EINTR,
or EIO, then some of the I/O specified by the list may have been initi‐
ated. If the lio_listio() function fails with an error code other than
EAGAIN, EINTR, or EIO, no operations from the list have been initiated.
The I/O operation indicated by each list element can encounter errors
specific to the individual read or write function being performed. In
this event, the error status for each aiocb control block contains the
associated error code. The error codes that can be set are the same as
would be set by a read(2) or write(2) function, with the following
additional error codes possible:
EAGAIN The requested I/O operation was not queued due to
resource limitations.
ECANCELED The requested I/O was canceled before the I/O completed
due to an explicit aio_cancel(3RT) request.
EFBIG The aiocbp->aio_lio_opcode is LIO_WRITE, the file is a
regular file, aiocbp->aio_nbytes is greater than 0, and
the aiocbp->aio_offset is greater than or equal to the
offset maximum in the open file description associated
with aiocbp->aio_fildes.
EINPROGRESS The requested I/O is in progress.
EOVERFLOW The aiocbp->aio_lio_opcode is LIO_READ, the file is a
regular file, aiocbp->aio_nbytes is greater than 0, and
the aiocbp->aio_offset is before the end-of-file and is
greater than or equal to the offset maximum in the open
file description associated with aiocbp->aio_fildes.
USAGE
The lio_listio() function has a transitional interface for 64-bit file
offsets. See lf64(5).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │Standard │
├─────────────────────────────┼─────────────────────────────┤
│MT-Level │MT-Safe │
└─────────────────────────────┴─────────────────────────────┘
SEE ALSOclose(2), exec(2), exit(2), fork(2), lseek(2), read(2), write(2),
aio_cancel(3RT), aio_error(3RT), aio_fsync(3RT), aio_read(3RT),
aio_return(3RT), aio_write(3RT), aio.h(3HEAD), fcntl.h(3HEAD), sig‐
info.h(3HEAD), signal.h(3HEAD), attributes(5), lf64(5), standards(5)NOTES
Solaris 2.6 was the first release to support the Asynchronous Input and
Output option. Prior to this release, this function always returned −1
and set errno to ENOSYS.
SunOS 5.10 20 Oct 2003 lio_listio(3RT)