Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
Copyright 1989 AT&T
Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
#include <aio.h> int aio_read(struct aiocb *aiocbp);
The aio_read() 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->aio_buf. 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). If _POSIX_PRIORITIZED_IO is defined and prioritized I/O is supported for this file, then the asynchronous operation is submitted at a priority equal to the scheduling priority of the process minus aiocbp->aio_reqprio. The aiocbp value may be used as an argument to aio_error(3C) and aio_return(3C) 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(2) were called immediately prior to the operation with an offset equal to aio_offset and a whence equal to SEEK_SET. After a successful call to enqueue an asynchronous I/O operation, the value of the file offset for the file is unspecified.
The aiocbp->aio_sigevent structure defines what asynchronous notification is to occur when the asynchronous operation completes, as specified in signal.h(3HEAD).
The aiocbp->aio_lio_opcode field is ignored by aio_read().
The aiocbp argument points to an aiocb structure. If the buffer pointed to by aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal address prior to asynchronous I/O completion, then the behavior is undefined.
Simultaneous asynchronous operations using the same aiocbp produce undefined results.
If _POSIX_SYNCHRONIZED_IO is defined and synchronized I/O is enabled on the file associated with aiocbp->aio_fildes, the behavior of this function is according to the definitions of synchronized I/O data integrity completion and synchronized I/O file integrity completion.
For any system action that changes the process memory space while an asynchronous I/O is outstanding to the address range being changed, the result of that action is undefined.
For regular files, no data transfer will occur past the offset maximum established in the open file description associated with aiocbp->aio_fildes.
The aio_read() function returns 0 to the calling process if the I/O operation is successfully queued; otherwise, the function returns -1 and sets errno to indicate the error.
The aio_read() function will fail if: 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 any of the conditions below are detected synchronously, the aio_read() 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 will be set to the corresponding value. EBADF
The aiocbp->aio_fildes argument is not a valid file descriptor open for reading.
The file offset value implied by aiocbp->aio_offset would be invalid, aiocbp->aio_reqprio is not a valid value, or aiocbp->aio_nbytes is an invalid value.
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(2) function call. In addition, the error status of the asynchronous operation will be 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.
The requested I/O was canceled before the I/O completed due to an explicit aio_cancel(3C) request.
The file offset value implied by aiocbp->aio_offset would be invalid.
The following condition may be detected synchronously or asynchronously: EOVERFLOW
The file is a regular file, aiobcp->aio_nbytes is greater than 0 and the starting offset in aiobcp->aio_offset is before the end-of-file and is at or beyond the offset maximum in the open file description associated with aiocbp->aio_fildes.
For portability, the application should set aiocb->aio_reqprio to 0.
The aio_read() function has a transitional interface for 64-bit file offsets. See lf64(5).
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Committed |
MT-Level MT-Safe |
Standard See standards(5). |
close(2), exec(2), exit(2), fork(2), lseek(2), read(2), write(2), aio_cancel(3C), aio_return(3C), aio.h(3HEAD), lio_listio(3C), siginfo.h(3HEAD), signal.h(3HEAD), attributes(5), lf64(5), standards(5)