int aio_read(struct aiocb *aiocbp);
Description
The data is read starting at the absolute file offset aiocbp->aio_offset, regardless of the current file position. After this request, the value of the current file position is unspecified.
The "asynchronous" means that this call returns as soon as the request has been enqueued; the read may or may not have completed when the call returns. One tests for completion using aio_error(3).
If _POSIX_PRIORITIZED_IO is defined, and this file supports it, then the asynchronous operation is submitted at a priority equal to that of the calling process minus aiocbp->aio_reqprio.
The field aiocbp->aio_lio_opcode is ignored.
No data is read from a regular file beyond its maximum offset.
Return Value
On success, 0 is returned. On error the request is not enqueued, -1 is returned, and errno is set appropriately. If an error is first detected later, it will be reported via aio_return(3) (returns status -1) and aio_error(3) (error status whatever one would have gotten in errno, such as EBADF).
int aio_write(struct aiocb *aiocbp);
Description
If O_APPEND is not set, the data is written starting at the absolute file offset aiocbp->aio_offset, regardless of the current file position. If O_APPEND is set, the data is written at the end of the file. After this request, the value of the current file position is unspecified.
The "asynchronous" means that this call returns as soon as the request has been enqueued; the write may or may not have completed when the call returns. One tests for completion using aio_error(3).
If _POSIX_PRIORITIZED_IO is defined, and this file supports it, then the asynchronous operation is submitted at a priority equal to that of the calling process minus aiocbp->aio_reqprio.
The field aiocbp->aio_lio_opcode is ignored.
No data is written to a regular file beyond its maximum offset.
Return Value
On success, 0 is returned. On error the request is not enqueued, -1 is returned, and errno is set appropriately. If an error is first detected later, it will be reported via aio_return(3) (returns status -1) and aio_error(3) (error status whatever one would have gotten in errno, such as EBADF).
int aio_cancel(int fd, struct aiocb *aiocbp);
Description
Normal asynchronous notification occurs for cancelled requests. The request return status is set to -1, and the request error status is set to ECANCELED. The control block of requests that cannot be cancelled is not changed.
If aiocbp is not NULL, and fd differs from the file descriptor with which the asynchronous operation was initiated, unspecified results occur.
Which operations are cancelable is implementation-defined.
Return Value
This function returns AIO_CANCELED if all requests were successfully cancelled. It returns AIO_NOTCANCELED when at least one of the requests specified was not cancelled because it was in progress. In this case one may check the status of individual requests using aio_error(3). This function returns AIO_ALLDONE when all requests had been completed already before this call. When some error occurs, -1 is returned, and errno is set appropriately.
ssize_t aio_return(struct aiocb *aiocbp);
Description
This function should be called only once for any given request, after aio_error(3) returns something other than EINPROGRESS.
Return Value
If the asynchronous I/O operation has completed, this function returns the value that would have been returned in case of a synchronous read, write, or fsync request. Otherwise the return value is undefined. On error, the error value is returned.
int aio_error(const struct aiocb *aiocbp);
Description
The aio_error() function returns the error status for the asynchronous I/O request with control block pointed to by aiocbp.
Return Value
int aio_fsync(int op, struct aiocb *aiocbp);
Description
More precisely, if op is O_SYNC, then all currently queued I/O operations shall be completed as if by a call of fsync(2), and if op is O_DSYNC, this call is the asynchronous analog of fdatasync(2). Note that this is a request only -- this call does not wait for I/O completion.
Apart from aio_fildes the only field in the structure pointed to by aiocbp that is used by this call is the aio_sigevent field (a struct sigevent) that indicates the desired type of asynchronous notification at completion. All other fields are ignored.
Return Value
On success (the sync request was successfully queued) this function returns 0. On error -1 is returned, and errno is set appropriately.