📄 aio_write.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>aio_write</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_001_158"> </a>NAME</h4><blockquote>aio_write - asynchronous write to a file(<b>REALTIME</b>)</blockquote><h4><a name = "tag_000_001_159"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="aio.h.html">aio.h</a>>int aio_write(struct aiocb *<i>aiocbp</i>);</code></pre></blockquote><h4><a name = "tag_000_001_160"> </a>DESCRIPTION</h4><blockquote>The<i>aio_write()</i>function allows the calling process to write<i>aiocbp->aio_nbytes</i>to the file associated with<i>aiocbp->aio_fildes</i>from the buffer pointed to by<i>aiocbp->aio_buf</i>.The function call returnswhen the write request has been initiated or, at a minimum,queued to the file or device.If _POSIX_PRIORITIZED_IO is definedand prioritized I/O is supported for this file,then the asynchronous operation is submitted at a priority equal tothe scheduling priority of the process minus<i>aiocbp->aio_reqprio</i>.The<i>aiocbp</i>may be used as an argument to<i><a href="aio_error.html">aio_error()</a></i>and<i><a href="aio_return.html">aio_return()</a></i>in order to determine theerror status and return status, respectively, of the asynchronous operationwhile it is proceeding.<p>The<i>aiocbp</i>argument points to an<b>aiocb</b>structure.If the buffer pointed to by<i>aiocbp->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 behaviour is undefined.<p>If O_APPEND is not set for the file descriptor<i>aio_fildes</i>,then the requested operation takes place at the absolute position inthe file as given by<i>aio_offset</i>,as if<i><a href="lseek.html">lseek()</a></i>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_APPENDis set for the file descriptor, write operations append to the filein 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>The<i>aiocbp->aio_lio_opcode</i>field is ignored by<i>aio_write()</i>.<p>Simultaneous asynchronous operations using the same<i>aiocbp</i>produce undefined results.<p>If _POSIX_SYNCHRONIZED_IO is definedand synchronised I/O is enabled on the file associated with<i>aiocbp->aio_fildes</i>,the behaviour of this function shall be according to the definitions ofsynchronised I/O data integrity completionandsynchronised I/O file integrity completion.<p>For any system action that changes the process memory spacewhile an asynchronous I/O is outstanding to the address range being changed,the result of that action is undefined.<p>For regular files, no data transfer will occur past the offset maximumestablished in the open file description associated with<i>aiocbp->aio_fildes</i>.</blockquote><h4><a name = "tag_000_001_161"> </a>RETURN VALUE</h4><blockquote>The<i>aio_write()</i>function returns the value zero to thecalling process if the I/O operation is successfully queued;otherwise, the function returns the value -1 and sets<i>errno</i>to indicate the error.</blockquote><h4><a name = "tag_000_001_162"> </a>ERRORS</h4><blockquote>The <i>aio_write()</i>function will fail if:<dl compact><dt>[EAGAIN]<dd>The requested asynchronous I/O operation was not queueddue to system resource limitations.<dt>[ENOSYS]<dd>The<i>aio_write()</i>function is not supported by this implementation.</dl><p>Each of the following conditions may be detected synchronouslyat 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 returns -1 and sets<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 will beset to the corresponding value.<dl compact><dt>[EBADF]<dd>The<i>aiocbp->aio_fildes</i>argument is not a valid file descriptor open for writing.<dt>[EINVAL]<dd>The file offset value implied by<i>aiocbp->aio_offset</i>would be invalid,<i>aiocbp->aio_reqprio</i>is not a valid value, or<i>aiocbp->aio_nbytes</i>is an invalid value.</dl><p>In the case that the<i>aio_write()</i>successfully queues the I/O operation,the return status of the asynchronous operationwill be one of the values normally returned by the<i><a href="write.html">write()</a></i>function call.If the operation is successfully queuedbut is subsequently canceled or encounters an error,the error status for the asynchronous operationcontains one of the values normally set by the<i><a href="write.html">write()</a></i>function call, or one of the following:<dl compact><dt>[EBADF]<dd>The<i>aiocbp->aio_fildes</i>argument is not a valid file descriptor open for writing.<dt>[EINVAL]<dd>The file offset value implied by<i>aiocbp->aio_offset</i>would be invalid.<dt>[ECANCELED]<dd>The requested I/O was canceled before the I/O completed due to an explicit<i><a href="aio_cancel.html">aio_cancel()</a></i>request.</dl><p>The following condition may be detected synchronously or asynchronously:<dl compact><dt>[EFBIG]<dd>The file is a regular file, <i>aiobcp->aio_nbytes</i>is greater than 0 and the starting offset in<i>aiobcp->aio_offset</i>is at or beyond the offset maximum in theopen file description associated with<i>aiocbp->aio_fildes</i>.</dl></blockquote><h4><a name = "tag_000_001_163"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_164"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_165"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_166"> </a>SEE ALSO</h4><blockquote><i><a href="aio_cancel.html">aio_cancel()</a></i>,<i><a href="aio_error.html">aio_error()</a></i>,<i><a href="aio_read.html">aio_read()</a></i>,<i><a href="aio_return.html">aio_return()</a></i>,<i><a href="lio_listio.html">lio_listio()</a></i>,<i><a href="close.html">close()</a></i>,<i><a href="_exit.html">_exit()</a></i>,<i><a href="exec.html">exec</a></i>,<i><a href="fork.html">fork()</a></i>,<i><a href="lseek.html">lseek()</a></i>,<i><a href="write.html">write()</a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995) </blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -