DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

lio_listio(S)


lio_listio -- list directed I/O

Syntax

cc . . . -lsuds
#include <aio.h>

int lio_listio(int mode, struct aiocb * const list[], int nent, struct sigevent *sig);

Description

The lio_listio(S) function allows the calling process to initiate a list of I/O requests with a single function call.

The mode argument takes one of the values LIO_WAIT or LIO_NOWAIT declared in aio(FP) 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 after all the I/O operations are complete.

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 operation to be performed. The supported operations are LIO_READ, LIO_WRITE, and LIO_NOP; these symbols are defined in aio(FP). The LIO_NOP operation 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(S) 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(S) with the aiocbp equal to the address of the aiocb structure.

The aio_files member specifies the file descriptor on which the operation is to be performed. It must refer to a raw device.

The aio_buf member specifies the address of the buffer to or from which the data is to be transferred. It must be 512 byte aligned.

The aio_nbytes member specifies the number of bytes of data to be transferred. It must be a multiple of 512.

The lio_aiocb element further describes the I/O operation to be performed, in the identical manner that the corresponding aiocb structure is used by the aio_read and aio_write functions.

The nent argument specifies how many elements are members of the list, that is, the length of the array.

The sig argument is a pointer to a signal control structure, used when the mode argument has the value LIO_NOWAIT, which defines the signal to be generated when the entire list of I/O requests have been completed.

Return values

If the mode argument has the value LIO_NOWAIT, the lio_listio function returns the value zero if the I/O operations are successfully queued; otherwise, the function returns the value -1 and sets errno to indicate the error.

If the mode argument has the value LIO_WAIT, the lio_listio function returns the value zero when all the indicated I/O has completed successfully. Otherwise, lio_listio returns a value of -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 examines the error status associated with each lio_aiocb control block. The error statuses so returned are identical to those returned as the result of an aio_read or aio_write function.

Diagnostics

If any of the following conditions occur, the lio_listio function returns -1 and sets errno to the corresponding value:

[EAGAIN]
The resources necessary to queue all the I/O requests were not available. The application may check the error status for each aiocb to determine the individual request(s) that failed.

[EAGAIN]
The number of entries indicated by nent would cause the system-wide limit {AIO_MAX} to be exceeded.

[EINVAL]
The mode argument is not a proper value. The value of nent was 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. Outstanding I/O requests are not canceled, and the application examines each list element to determine whether the request was initiated, canceled, or completed.

[EIO]
One or more of the individual I/O operations failed. The application checks the error status for each aiocb structure to determine the individual request(s) that failed.
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 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 which can be set are the same as would be set by a read or write function, with the following additional error codes possible:

[EAGAIN]
The requested I/O operation was not queued due to resource limitations.

[EINPROGRESS]
The requested I/O is in process.

See also

aio(FP), aio_error(S), aio_mkcbs(S), aio_read(S), aio_return(S), aio_write(S), close(S), _exit(S), exec(S), fork(S), lseek(S), read(S)

Standards conformance

Text reprinted and/or adapted from IEEE Std 1003.1b-1993, IEEE Standard for Information Technology, POSIX Part 1: System Application Program Interface (API) Amendment 1: Realtime Extensions [C Language], copyright © 1993 by the Institute of Electrical and Electronics Engineers, Inc. The IEEE takes no responsibility for and will assume no liability for damages resulting from the reader's misinterpretation of said information resulting from the placement and context in this publication. Information is reproduced with the permission of the IEEE.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003