.\" .\" 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 SunOS 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] .\" .\" .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved. .\" .TH AIO_READ 3C "Feb 5, 2008" .SH NAME aio_read \- asynchronous read from a file .SH SYNOPSIS .LP .nf #include \fBint\fR \fBaio_read\fR(\fBstruct aiocb *\fR\fIaiocbp\fR); .fi .SH DESCRIPTION .sp .LP The \fBaio_read()\fR function allows the calling process to read \fIaiocbp\fR->\fBaio_nbytes\fR from the file associated with \fIaiocbp\fR->\fBaio_fildes\fR into the buffer pointed to by \fIaiocbp\fR->\fBaio_buf\fR. 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 \fB_POSIX_PRIORITIZED_IO\fR 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 \fIaiocbp\fR->\fBaio_reqprio\fR. The \fIaiocbp\fR value may be used as an argument to \fBaio_error\fR(3C) and \fBaio_return\fR(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 \fIaio_offset\fR, as if \fBlseek\fR(2) were called immediately prior to the operation with an \fIoffset\fR equal to \fIaio_offset\fR and a \fBwhence\fR equal to \fBSEEK_SET\fR. After a successful call to enqueue an asynchronous I/O operation, the value of the file offset for the file is unspecified. .sp .LP The \fIaiocbp\fR->\fBaio_sigevent\fR structure defines what asynchronous notification is to occur when the asynchronous operation completes, as specified in \fBsignal.h\fR(3HEAD). .sp .LP The \fIaiocbp\fR->\fBaio_lio_opcode\fR field is ignored by \fBaio_read()\fR. .sp .LP The \fIaiocbp\fR argument points to an \fBaiocb\fR structure. If the buffer pointed to by \fIaiocbp\fR->\fBaio_buf\fR or the control block pointed to by \fIaiocbp\fR becomes an illegal address prior to asynchronous I/O completion, then the behavior is undefined. .sp .LP Simultaneous asynchronous operations using the same \fIaiocbp\fR produce undefined results. .sp .LP If \fB_POSIX_SYNCHRONIZED_IO\fR is defined and synchronized I/O is enabled on the file associated with \fIaiocbp\fR->\fBaio_fildes,\fR the behavior of this function is according to the definitions of synchronized I/O data integrity completion and synchronized I/O file integrity completion. .sp .LP 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. .sp .LP For regular files, no data transfer will occur past the offset maximum established in the open file description associated with \fIaiocbp\fR->\fBaio_fildes\fR. .SH RETURN VALUES .sp .LP The \fBaio_read()\fR function returns \fB0\fR to the calling process if the I/O operation is successfully queued; otherwise, the function returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. .SH ERRORS .sp .LP The \fBaio_read()\fR function will fail if: .sp .ne 2 .na \fB\fBEAGAIN\fR\fR .ad .RS 10n The requested asynchronous I/O operation was not queued due to system resource limitations. .RE .sp .LP Each of the following conditions may be detected synchronously at the time of the call to \fBaio_read()\fR, or asynchronously. If any of the conditions below are detected synchronously, the \fBaio_read()\fR function returns \fB-1\fR and sets \fBerrno\fR to the corresponding value. If any of the conditions below are detected asynchronously, the return status of the asynchronous operation is set to \(mi1, and the error status of the asynchronous operation will be set to the corresponding value. .sp .ne 2 .na \fB\fBEBADF\fR\fR .ad .RS 10n The \fIaiocbp\fR->\fBaio_fildes\fR argument is not a valid file descriptor open for reading. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n The file offset value implied by \fIaiocbp\fR->\fBaio_offset\fR would be invalid, \fIaiocbp->\fR\fBaio_reqprio\fR is not a valid value, or \fIaiocbp\fR->\fBaio_nbytes\fR is an invalid value. .RE .sp .LP In the case that the \fBaio_read()\fR 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 \fBread\fR(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 \fBread()\fR function call, or one of the following values: .sp .ne 2 .na \fB\fBEBADF\fR\fR .ad .RS 13n The \fIaiocbp\fR->\fBaio_fildes\fR argument is not a valid file descriptor open for reading. .RE .sp .ne 2 .na \fB\fBECANCELED\fR\fR .ad .RS 13n The requested I/O was canceled before the I/O completed due to an explicit \fBaio_cancel\fR(3C) request. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 13n The file offset value implied by \fIaiocbp\fR->\fBaio_offset\fR would be invalid. .RE .sp .LP The following condition may be detected synchronously or asynchronously: .sp .ne 2 .na \fB\fBEOVERFLOW\fR\fR .ad .RS 13n The file is a regular file, \fIaiobcp\fR->\fBaio_nbytes\fR is greater than 0 and the starting offset in \fIaiobcp\fR->\fBaio_offset\fR is before the end-of-file and is at or beyond the offset maximum in the open file description associated with \fIaiocbp\fR->\fBaio_fildes\fR. .RE .SH USAGE .sp .LP For portability, the application should set \fIaiocb->\fR\fBaio_reqprio\fR to \fB0\fR. .sp .LP The \fBaio_read()\fR function has a transitional interface for 64-bit file offsets. See \fBlf64\fR(7). .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level MT-Safe _ Standard See \fBstandards\fR(7). .TE .SH SEE ALSO .sp .LP .BR close (2), .BR exec (2), .BR exit (2), .BR fork (2), .BR lseek (2), .BR read (2), .BR write (2), .BR aio_cancel (3C), .BR aio_return (3C), .BR lio_listio (3C), .BR aio.h (3HEAD), .BR siginfo.h (3HEAD), .BR signal.h (3HEAD), .BR attributes (7), .BR lf64 (7), .BR standards (7)