aio_write(3)

NAME
aio_write - Initiate an asynchronous write operation

SYNOPSYS
#include <errno.h>

#include <aio.h>

int aio_write (struct aiocb * aiocbp);

DESCRIPTION
This function initiates an asynchronous write operation. The function call immediately returns after the operation was enqueued or if before this happens an error was encountered. The first aiocbp->aio_nbytes bytes from the buffer starting at aiocbp->aio_buf are written to the file for which aiocbp->aio_fildes is an descriptor, starting at the absolute position aiocbp->aio_offset in the file. If prioritized I/O is supported by the platform, the aiocbp->aio_reqprio value is used to adjust the priority before the request is actually enqueued. The calling process is notified about the termination of the read request according to the aiocbp->aio_sigevent value. When aio_write returns, the return value is zero if no error occurred that can be found before the process is enqueued. If such an early error is found the function returns -1 and sets errno to one of the following values.

EAGAIN
    The request was not enqueued due to (temporarily) exceeded resource limitations.

ENOSYS
    The aio_write function is not implemented.

EBADF
    The aiocbp->aio_fildes descriptor is not valid. This condition may not be recognized before enqueueing the request, and so this error might also be signaled asynchronously.

EINVAL
    The aiocbp->aio_offset or aiocbp->aio_reqprio value is invalid. This condition may not be recognized before enqueueing the request and so this error might also be signaled asynchronously.

In the case aio_write returns zero, the current status of the request can be queried using aio_error and aio_return functions. As long as the value returned by aio_error is EINPROGRESS the operation has not yet completed. If aio_error returns zero, the operation successfully terminated, otherwise the value is to be interpreted as an error code. If the function terminated, the result of the operation can be get using a call to aio_return call to read would have returned. Possible error codes returned by aio_error are:

EBADF
    The aiocbp->aio_fildes descriptor is not valid.

ECANCELED
    The operation was canceled before the operation was finished.

EINVAL
    The aiocbp->aio_offset value is invalid.

When the sources are compiled with _FILE_OFFSET_BITS == 64 , this function is in fact aio_write64 since the LFS interface transparently replaces the normal implementation.

RETURN VALUES
When aio_write returns, the return value is zero if no error occurred that can be found before the process is enqueued. If such an early error is found the function returns -1 and sets errno to one of the following values.

ERRORS

EAGAIN
    The request was not enqueued due to (temporarily) exceeded resource limitations.

ENOSYS
    The aio_write function is not implemented.

EBADF
    The aiocbp->aio_fildes descriptor is not valid. This condition may not be recognized before enqueueing the request, and so this error might also be signaled asynchronously.

EINVAL
    The aiocbp->aio_offset or aiocbp->aio_reqprio value is invalid. This condition may not be recognized before enqueueing the request and so this error might also be signaled asynchronously.

SEE ALSO
aio(3), aio_cancel(3), aio_cancel64(3), aio_error(3), aio_error64(3), aio_fsync(3), aio_fsync64(3), aio_init(3), aio_read(3), aio_read64(3), aio_return(3), aio_return64(3), aio_suspend(3), aio_suspend64(3), aio_write64(3), errno(3),