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