# lio_listio

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           lio_listio — list directed I/O
    


## SYNOPSIS



           #include <aio.h>
    
           int lio_listio(int _mode_ , struct aiocb *restrict const _list_[restrict],
               int _nent_ , struct sigevent *restrict _sig_);
    


## DESCRIPTION



           The _lio_listio_() function shall 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.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 shall wait until all I/O is complete and the _sig_ argument
           shall be ignored.
    
           If the _mode_ argument is LIO_NOWAIT, the function shall return
           immediately, and asynchronous notification shall occur, according
           to the _sig_ argument, when all the I/O operations complete. If _sig_
           is NULL, then no asynchronous notification shall occur. If _sig_ is
           not NULL, asynchronous notification occurs as specified in _Section_
           _2.4.1_ , _Signal Generation and Delivery_ when all the requests in
           _list_ have completed.
    
           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 shall be ignored.
    
           If the buffer pointed to by _list_ or the **aiocb** structures pointed
           to by the elements of the array _list_ become illegal addresses
           before all asynchronous I/O completed and, if necessary, the
           notification is sent, then the behavior is undefined. If the
           buffers pointed to by the _aio_buf_ member of the **aiocb** structure
           pointed to by the elements of the array _list_ become illegal
           addresses prior to the asynchronous I/O associated with that **aiocb**
           structure being completed, the behavior is undefined.
    
           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.h>_.  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_() 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_() with the _aiocbp_ equal to the
           address of the **aiocb** structure.
    
           The _aio_fildes_ member specifies the file descriptor on which the
           operation is to be performed.
    
           The _aio_buf_ member specifies the address of the buffer to or from
           which the data is 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_() and
           _aio_write_() functions.
    
           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 associated with _aio_fildes_.
    
           For regular files, no data transfer shall occur past the offset
           maximum established in the open file description associated with
           _aiocbp_ ->_aio_fildes_.
    
           If _sig_ ->_sigev_notify_ is SIGEV_THREAD and
           _sig_ ->_sigev_notify_attributes_ is a non-null pointer and the block
           pointed to by this pointer becomes an illegal address prior to all
           asynchronous I/O being completed, then the behavior is undefined.
    


## RETURN VALUE



           If the _mode_ argument has the value LIO_NOWAIT, the _lio_listio_()
           function shall return the value zero if the I/O operations are
           successfully queued; otherwise, the function shall return the
           value -1 and set _errno_ to indicate the error.
    
           If the _mode_ argument has the value LIO_WAIT, the _lio_listio_()
           function shall return the value zero when all the indicated I/O
           has completed successfully. Otherwise, _lio_listio_() shall return a
           value of -1 and set _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 shall examine the error status associated with each
           **aiocb** control block. The error statuses so returned are identical
           to those returned as the result of an _aio_read_() or _aio_write_()
           function.
    


## ERRORS



           The _lio_listio_() function shall fail if:
    
           **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, or 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 shall examine 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 may check 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. If the _lio_listio_() function fails
           with an error code other than **[EAGAIN]** , **[EINTR]** , or **[EIO]** , no
           operations from the list shall 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_() or _write_() 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_() 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_.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           None.
    


## RATIONALE



           Although it may appear that there are inconsistencies in the
           specified circumstances for error codes, the **[EIO]** error condition
           applies when any circumstance relating to an individual operation
           makes that operation fail. This might be due to a badly formulated
           request (for example, the _aio_lio_opcode_ field is invalid, and
           _aio_error_() returns **[EINVAL]**) or might arise from application
           behavior (for example, the file descriptor is closed before the
           operation is initiated, and _aio_error_() returns **[EBADF]**).
    
           The limitation on the set of error codes returned when operations
           from the list shall have been initiated enables applications to
           know when operations have been started and whether _aio_error_() is
           valid for a specific operation.
    


## FUTURE DIRECTIONS



           None.
    


* * *