1AIO_WRITE(3P) POSIX Programmer's Manual AIO_WRITE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 aio_write - asynchronous write to a file (REALTIME)
13
15 #include <aio.h>
16
17 int aio_write(struct aiocb *aiocbp);
18
19
21 The aio_write() function shall write aiocbp->aio_nbytes to the file
22 associated with aiocbp->aio_fildes from the buffer pointed to by
23 aiocbp->aio_buf. The function shall return when the write request has
24 been initiated or, at a minimum, queued to the file or device.
25
26 If prioritized I/O is supported for this file, then the asynchronous
27 operation shall be submitted at a priority equal to the scheduling pri‐
28 ority of the process minus aiocbp->aio_reqprio.
29
30 The aiocbp argument may be used as an argument to aio_error() and
31 aio_return() in order to determine the error status and return status,
32 respectively, of the asynchronous operation while it is proceeding.
33
34 The aiocbp argument points to an aiocb structure. If the buffer pointed
35 to by aiocbp->aio_buf or the control block pointed to by aiocbp becomes
36 an illegal address prior to asynchronous I/O completion, then the
37 behavior is undefined.
38
39 If O_APPEND is not set for the file descriptor aio_fildes, then the
40 requested operation shall take place at the absolute position in the
41 file as given by aio_offset, as if lseek() were called immediately
42 prior to the operation with an offset equal to aio_offset and a whence
43 equal to SEEK_SET. If O_APPEND is set for the file descriptor, write
44 operations append to the file in the same order as the calls were made.
45 After a successful call to enqueue an asynchronous I/O operation, the
46 value of the file offset for the file is unspecified.
47
48 The aiocbp->aio_lio_opcode field shall be ignored by aio_write().
49
50 Simultaneous asynchronous operations using the same aiocbp produce
51 undefined results.
52
53 If synchronized I/O is enabled on the file associated with
54 aiocbp->aio_fildes, the behavior of this function shall be according to
55 the definitions of synchronized I/O data integrity completion, and syn‐
56 chronized I/O file integrity completion.
57
58 For any system action that changes the process memory space while an
59 asynchronous I/O is outstanding to the address range being changed, the
60 result of that action is undefined.
61
62 For regular files, no data transfer shall occur past the offset maximum
63 established in the open file description associated with
64 aiocbp->aio_fildes.
65
67 The aio_write() function shall return the value zero to the calling
68 process if the I/O operation is successfully queued; otherwise, the
69 function shall return the value -1 and set errno to indicate the error.
70
72 The aio_write() function shall fail if:
73
74 EAGAIN The requested asynchronous I/O operation was not queued due to
75 system resource limitations.
76
77
78 Each of the following conditions may be detected synchronously at the
79 time of the call to aio_write(), or asynchronously. If any of the con‐
80 ditions below are detected synchronously, the aio_write() function
81 shall return -1 and set errno to the corresponding value. If any of the
82 conditions below are detected asynchronously, the return status of the
83 asynchronous operation shall be set to -1, and the error status of the
84 asynchronous operation is set to the corresponding value.
85
86 EBADF The aiocbp->aio_fildes argument is not a valid file descriptor
87 open for writing.
88
89 EINVAL The file offset value implied by aiocbp->aio_offset would be
90 invalid, aiocbp->aio_reqprio is not a valid value, or
91 aiocbp->aio_nbytes is an invalid value.
92
93
94 In the case that the aio_write() successfully queues the I/O operation,
95 the return status of the asynchronous operation shall be one of the
96 values normally returned by the write() function call. If the operation
97 is successfully queued but is subsequently canceled or encounters an
98 error, the error status for the asynchronous operation contains one of
99 the values normally set by the write() function call, or one of the
100 following:
101
102 EBADF The aiocbp->aio_fildes argument is not a valid file descriptor
103 open for writing.
104
105 EINVAL The file offset value implied by aiocbp->aio_offset would be
106 invalid.
107
108 ECANCELED
109 The requested I/O was canceled before the I/O completed due to
110 an explicit aio_cancel() request.
111
112
113 The following condition may be detected synchronously or asyn‐
114 chronously:
115
116 EFBIG The file is a regular file, aiobcp->aio_nbytes is greater than
117 0, and the starting offset in aiobcp->aio_offset is at or beyond
118 the offset maximum in the open file description associated with
119 aiocbp->aio_fildes.
120
121
122 The following sections are informative.
123
125 None.
126
128 The aio_write() function is part of the Asynchronous Input and Output
129 option and need not be available on all implementations.
130
132 None.
133
135 None.
136
138 aio_cancel(), aio_error(), aio_read(), aio_return(), close(), exec(),
139 exit(), fork(), lio_listio(), lseek(), write(), the Base Definitions
140 volume of IEEE Std 1003.1-2001, <aio.h>
141
143 Portions of this text are reprinted and reproduced in electronic form
144 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
145 -- Portable Operating System Interface (POSIX), The Open Group Base
146 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
147 Electrical and Electronics Engineers, Inc and The Open Group. In the
148 event of any discrepancy between this version and the original IEEE and
149 The Open Group Standard, the original IEEE and The Open Group Standard
150 is the referee document. The original Standard can be obtained online
151 at http://www.opengroup.org/unix/online.html .
152
153
154
155IEEE/The Open Group 2003 AIO_WRITE(3P)