#include <aio.h>
int lio_listio(int mode, struct aiocb * const list[], int nent, struct sigevent *sig);
struct aiocb {
int aio_fildes; /* file descriptor */
volatile void *aio_buf; /* buffer location */
size_t aio_nbytes; /* length of transfer */
off_t aio_offset; /* file offset */
int aio_reqprio; /* request priority offset */
struct sigevent aio_sigevent; /* signal number and offset */
int aio_lio_opcode; /* listio operation */
};
struct sigevent {
int sigev_notify; /* notification mode */
int sigev_signo; /* signal number */
union sigval sigev_value; /* signal value */
};
union sigval {
int sival_int; /* integer value */
void *sival_ptr; /* pointer value */
};
If mode is set to LIO_WAIT, lio_listio() behaves synchronously, waiting until all I/O is completed, and the sig argument is ignored. If mode is set to LIO_NOWAIT, lio_listio() behaves asynchronously; returning immediately, and signal delivery will occur, according to the sig argument, when all the I/O operations from this function complete. If sig is NULL, or the sigev_signo member of the sigevent structure referenced by sig is zero, then no signal delivery will occur. Otherwise, the signal number indicated by sigev_signo will be delivered when all the requests in list have completed.
list is an array of pointers to aiocb structures. This array consists of nent elements. The array may contain NULL pointers, which will be ignored.
The aio_lio_opcode field of each aiocb structure in list specifies the operation to be performed (see /usr/include/aio.h ).
nent specifies the length of the array (number of members of the list).
When mode has the value LIO_WAIT, a pointer to a signal control structure, sig, is used to define both the signal to be generated and how the calling process will be notified upon I/O completion. 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_SIGNAL, 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(5) ).
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 associated with aio_fildes. (see fcntl(5) definitions of O_DSYNC and O_SYNC.)
If the mode argument has the value LIO_WAIT, and when all the indicated I/O has completed successfully, lio_listio() returns 0; otherwise, it returns -1, and sets errno to indicate the error condition.
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(3R) or aio_write(3R) function.
The value of nent is greater than AIO_LISTIO_MAX.
If either lio_listio() succeeds in queuing all of its requests, or errno is set to EAGAIN, EINTR, or EIO, then some of the I/O specified from the list may have been initiated. In this event, each aiocb structure contains errors specific to the read(2) or write(2) function being performed; i.e.: