Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/aio_read.html
2024-02-19 00:21:47 -05:00

229 lines
9.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>aio_read</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="aio_read"></a> <a name="tag_03_17"></a><!-- aio_read -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_17_01"></a>NAME</h4>
<blockquote>aio_read - asynchronous read from a file (<b>REALTIME</b>)</blockquote>
<h4><a name="tag_03_17_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('AIO')">AIO</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> #include &lt;<a href="../basedefs/aio.h.html">aio.h</a>&gt;<br>
<br>
int aio_read(struct aiocb *</tt><i>aiocbp</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_17_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>aio_read</i>() function shall read <i>aiocbp</i>-&gt;<i>aio_nbytes</i> from the file associated with
<i>aiocbp</i>-&gt;<i>aio_fildes</i> into the buffer pointed to by <i>aiocbp</i>-&gt;<i>aio_buf</i>. The function call shall return
when the read request has been initiated or queued to the file or device (even when the data cannot be delivered immediately).</p>
<p><sup>[<a href="javascript:open_code('PIO')">PIO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If prioritized I/O is supported for this file, then the asynchronous operation shall be submitted at a priority equal to the
scheduling priority of the process minus <i>aiocbp</i>-&gt;<i>aio_reqprio</i>. <img src="../images/opt-end.gif" alt="[Option End]"
border="0"></p>
<p>The <i>aiocbp</i> value may be used as an argument to <a href="../functions/aio_error.html"><i>aio_error</i>()</a> and <a href=
"../functions/aio_return.html"><i>aio_return</i>()</a> 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 shall
return without having initiated or queued the request. The requested operation takes place at the absolute position in the file as
given by <i>aio_offset</i>, as if <a href="../functions/lseek.html"><i>lseek</i>()</a> were called immediately prior to the
operation with an <i>offset</i> equal to <i>aio_offset</i> and a <i>whence</i> 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.</p>
<p>The <i>aiocbp</i>-&gt;<i>aio_lio_opcode</i> field shall be ignored by <i>aio_read</i>().</p>
<p>The <i>aiocbp</i> argument points to an <b>aiocb</b> structure. If the buffer pointed to by <i>aiocbp</i>-&gt;<i>aio_buf</i> or
the control block pointed to by <i>aiocbp</i> becomes an illegal address prior to asynchronous I/O completion, then the behavior is
undefined.</p>
<p>Simultaneous asynchronous operations using the same <i>aiocbp</i> produce undefined results.</p>
<p><sup>[<a href="javascript:open_code('SIO')">SIO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If synchronized I/O is enabled on the file associated with <i>aiocbp</i>-&gt;<i>aio_fildes</i>, the behavior of this function shall
be according to the definitions of synchronized I/O data integrity completion and synchronized I/O file integrity completion. <img
src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>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.</p>
<p>For regular files, no data transfer shall occur past the offset maximum established in the open file description associated with
<i>aiocbp</i>-&gt;<i>aio_fildes</i>.</p>
</blockquote>
<h4><a name="tag_03_17_04"></a>RETURN VALUE</h4>
<blockquote>
<p>The <i>aio_read</i>() function shall return the value zero to the calling process if the I/O operation is successfully queued;
otherwise, the function shall return the value -1 and set <i>errno</i> to indicate the error.</p>
</blockquote>
<h4><a name="tag_03_17_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>aio_read</i>() function shall fail if:</p>
<dl compact>
<dt>[EAGAIN]</dt>
<dd>The requested asynchronous I/O operation was not queued due to system resource limitations.</dd>
</dl>
<p>Each of the following conditions may be detected synchronously at the time of the call to <i>aio_read</i>(), or asynchronously.
If any of the conditions below are detected synchronously, the <i>aio_read</i>() function shall return -1 and set <i>errno</i> 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.</p>
<dl compact>
<dt>[EBADF]</dt>
<dd>The <i>aiocbp</i>-&gt;<i>aio_fildes</i> argument is not a valid file descriptor open for reading.</dd>
<dt>[EINVAL]</dt>
<dd>The file offset value implied by <i>aiocbp</i>-&gt;<i>aio_offset</i> would be invalid, <i>aiocbp</i>-&gt;<i>aio_reqprio</i> is
not a valid value, or <i>aiocbp</i>-&gt;<i>aio_nbytes</i> is an invalid value.</dd>
</dl>
<p>In the case that the <i>aio_read</i>() 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 <a href=
"../functions/read.html"><i>read</i>()</a> function call. In addition, the error status of the asynchronous operation is set to one
of the error statuses normally set by the <a href="../functions/read.html"><i>read</i>()</a> function call, or one of the following
values:</p>
<dl compact>
<dt>[EBADF]</dt>
<dd>The <i>aiocbp</i>-&gt;<i>aio_fildes</i> argument is not a valid file descriptor open for reading.</dd>
<dt>[ECANCELED]</dt>
<dd>The requested I/O was canceled before the I/O completed due to an explicit <a href=
"../functions/aio_cancel.html"><i>aio_cancel</i>()</a> request.</dd>
<dt>[EINVAL]</dt>
<dd>The file offset value implied by <i>aiocbp</i>-&gt;<i>aio_offset</i> would be invalid.</dd>
</dl>
<p>The following condition may be detected synchronously or asynchronously:</p>
<dl compact>
<dt>[EOVERFLOW]</dt>
<dd>The file is a regular file, <i>aiobcp</i>-&gt;<i>aio_nbytes</i> is greater than 0, and the starting offset in
<i>aiobcp</i>-&gt;<i>aio_offset</i> is before the end-of-file and is at or beyond the offset maximum in the open file description
associated with <i>aiocbp</i>-&gt;<i>aio_fildes</i>.</dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_17_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_17_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>The <i>aio_read</i>() function is part of the Asynchronous Input and Output option and need not be available on all
implementations.</p>
</blockquote>
<h4><a name="tag_03_17_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_17_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_17_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="aio_cancel.html"><i>aio_cancel</i>()</a> , <a href="aio_error.html"><i>aio_error</i>()</a> , <a href=
"lio_listio.html"><i>lio_listio</i>()</a> , <a href="aio_return.html"><i>aio_return</i>()</a> , <a href=
"aio_write.html"><i>aio_write</i>()</a> , <a href="close.html"><i>close</i>()</a> , <a href="exec.html"><i><a href=
"../functions/exec.html">exec</a></i>()</a> , <a href="exit.html"><i>exit</i>()</a> , <a href="fork.html"><i>fork</i>()</a> , <a
href="lseek.html"><i>lseek</i>()</a> , <a href="read.html"><i>read</i>()</a> , the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/aio.h.html"><i>&lt;aio.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_17_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 5. Included for alignment with the POSIX Realtime Extension.</p>
<p>Large File Summit extensions are added.</p>
</blockquote>
<h4><a name="tag_03_17_12"></a>Issue 6</h4>
<blockquote>
<p>The [ENOSYS] error condition has been removed as stubs need not be provided if an implementation does not support the
Asynchronous Input and Output option.</p>
<p>The APPLICATION USAGE section is added.<br>
</p>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>In the DESCRIPTION, text is added to indicate setting of the offset maximum in the open file description. This change is to
support large files.</p>
</li>
<li>
<p>In the ERRORS section, the [EOVERFLOW] condition is added. This change is to support large files.</p>
</li>
</ul>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>