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

230 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_write</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="aio_write"></a> <a name="tag_03_20"></a><!-- aio_write -->
<!--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_20_01"></a>NAME</h4>
<blockquote>aio_write - asynchronous write to a file (<b>REALTIME</b>)</blockquote>
<h4><a name="tag_03_20_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_write(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_20_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>aio_write</i>() function shall write <i>aiocbp</i>-&gt;<i>aio_nbytes</i> to the file associated with
<i>aiocbp</i>-&gt;<i>aio_fildes</i> from the buffer pointed to by <i>aiocbp</i>-&gt;<i>aio_buf</i>. The function shall return when
the write request has been initiated or, at a minimum, queued to the file or device.</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> argument 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.</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>If O_APPEND is not set for the file descriptor <i>aio_fildes</i>, then the requested operation shall take 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. If
O_APPEND is set for the file descriptor, write operations append to the file in the same order as the calls were made. 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_write</i>().</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_20_04"></a>RETURN VALUE</h4>
<blockquote>
<p>The <i>aio_write</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_20_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>aio_write</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_write</i>(), or asynchronously.
If any of the conditions below are detected synchronously, the <i>aio_write</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 shall be 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 writing.</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_write</i>() successfully queues the I/O operation, the return status of the asynchronous operation
shall be one of the values normally returned by the <a href="../functions/write.html"><i>write</i>()</a> 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 <a href="../functions/write.html"><i>write</i>()</a> function call, or one
of the following:</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 writing.</dd>
<dt>[EINVAL]</dt>
<dd>The file offset value implied by <i>aiocbp</i>-&gt;<i>aio_offset</i> would be invalid.</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>
</dl>
<p>The following condition may be detected synchronously or asynchronously:</p>
<dl compact>
<dt>[EFBIG]</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 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_20_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_20_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>The <i>aio_write</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_20_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_20_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_20_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=
"aio_read.html"><i>aio_read</i>()</a> , <a href="aio_return.html"><i>aio_return</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="lio_listio.html"><i>lio_listio</i>()</a> , <a href="lseek.html"><i>lseek</i>()</a> , <a
href="write.html"><i>write</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_20_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_20_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.</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 that for regular files no data transfer occurs past the offset maximum established
in the open file description associated with <i>aiocbp</i>-&gt;<i>aio_fildes</i>.</p>
</li>
<li>
<p>The [EFBIG] error is added as part of the large file support extensions.</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>