DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

aio_read(S-osr5)


aio_read -- asynchronous read

Syntax

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

int aio_read (struct aiocb *aiocbp);

Description

The aiocbp argument points to an aiocb structure. The aio_read(S-osr5) function allows the calling process to read aiocbp->aio_nbytes from the file associated with aiocbp->aio_fildes into the buffer pointed to by aiocbp->aiobuf (see read(S-osr5)). 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 read request has been initiated or queued to the file or device (even when the data cannot be delivered immediately). The aiocbp value may be used as an argument to aio_error(S-osr5) and aio_return(S-osr5) in order to determine the error status and return status, respectively, of the asynchronous operation while it is proceeding. If an error condition is encountered during queuing, the function call returns without having initiated or queued the request. The requested operation takes place at the absolute position in the file as given by aio_offset, as if lseek(S-osr5) 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 a multiple of 512. The aiocbp->aio_lio_opcode field is ignored by aio_read.

Return values

The aio_read 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_read 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_read, or asynchronously. If either of the conditions below is detected synchronously, the aio_read function returns -1 and sets errno to the corresponding value. If either of the conditions below is 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 reading.

[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_read successfully queues the I/O operation but the operation is subsequently canceled or encounters an error, the return status of the asynchronous operation is one of the values normally returned by the read function call. In addition, the error status of the asynchronous operation is set to one of the error statuses normally set by the read function call, or one of the following values:

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

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

See also

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

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.
© 2005 System Services (S-osr5)
SCO OpenServer Release 6.0.0 -- 02 June 2005