DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

aio_write(S)


aio_write -- asynchronous write

Syntax

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

int aio_write(struct aiocb *aiocbp);

Description

The aio_write(S) function allows the calling process to write aiocbp>aio_nbytes to the file associated with aiocbp->aio_fildes from the buffer pointed to by aiocbp->aio_buf (see write(S)). aiocbp->aio_fildes must refer to a raw device, aiocbp->aio_nbytes must be a multiple of 512, and aiocbp->aio_buf must be 512-byte aligned.

The function call returns when the write request has been initiated or, at a minimum, queued to the file or device. The aiocbp may be used as an argument to aio_error(S) and aio_return(S) in order to determine the error status and return status, respectively, of the asynchronous operation while it is proceeding. The aiocbp argument points to an aiocb structure.

If O_APPEND is not set for the file descriptor aio_fildes, then the requested operation takes place at the absolute position in the file as given by aio_offset, as if lseek(S) were called immediately prior to the operation with an offset equal to aio_offset, and a whence equal to SEEK_SET. aio_offset must be set. If O_APPEND is set for the file descriptor, write operations append to the file in the same order as the calls were made.

The aiocbp->aio_lio_opcode field is ignored by aio_write.

Return values

The aio_write function returns the value zero to the calling process if the I/O operation is successfully queued; otherwise, the function returns the value -1 and sets errno to indicate the error.

Diagnostics

If the following condition occurs, the aio_write function returns -1 and sets errno to the corresponding value:

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

Each of the following conditions may be detected synchronously at the time of the call to aio_write, or asynchronously. If any of the conditions below are detected synchronously, the aio_write function returns -1 and sets errno to the corresponding value. If any of the conditions below are detected asynchronously, the return status of the asynchronous operation is set to -1 and the error status of the asynchronous operation is set to the corresponding value:

[EBADF]
The aiocbp->aio_fildes argument is not a valid file descriptor open for writing.

[EINVAL]
The file offset value implied by aiocbp->aio_offset would be invalid, aiocbp->aio_reqprio is not a valid value, aiocbp->aio_nbytes is an invalid value or aiocbp->aio_buf is invalid.
In the case that the aio_write successfully queues the I/O operation, the return status of the asynchronous operation is one of the values normally returned by the write function call. If the operation is successfully queued, but is subsequently canceled or encounters an error, the error status for the asynchronous operation contains one of the values normally set by the write function call, or one of the following:

[EBADF]
The aiocbp->aio_fildes argument is not a valid file descriptor open for writing.

[EINVAL]
The file offset value implied by aiocbp->aio_offset would be invalid.

See also

aio(FP), aio_error(S), aio_mkcbs(S), aio_read(S), aio_return(S), close(S), _exit(S), exec(S), fork(S), lio_listio(S), lseek(S), write(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 System Services (S)
SCO OpenServer Release 5.0.7 -- 11 February 2003