aio_write(S-osr5)
aio_write --
asynchronous write
Syntax
cc . . . -lsuds
#include <aio.h>
int aio_write(struct aiocb *aiocbp);
Description
The
aio_write(S-osr5)
function allows the calling process to write
aiocbp>aio_nbytes
to the file associated with
aiocbp->aio_fildes
from the buffer pointed to by
aiocbp->aio_buf
(see
write(S-osr5)).
aiocbp->aio_fildes
must refer to a raw device,
aiocbp->aio_nbytes
must be a multiple of 512, and
aiocbp->aio_buf
must be 512-byte aligned.
The function call returns when the write request has been initiated
or, at a minimum, queued to the file or device.
The aiocbp may be used as an argument to
aio_error(S-osr5)
and
aio_return(S-osr5)
in order to determine the error status and return status,
respectively, of the asynchronous operation while it is proceeding.
The aiocbp argument points to an aiocb
structure.
If O_APPEND is not set for the file descriptor
aio_fildes
, then the requested operation takes place at
the absolute position in the file as given by aio_offset
,
as if
lseek(S-osr5)
were called immediately prior to the operation with an
offset equal to aio_offset
, and a
whence equal to SEEK_SET. aio_offset
must be 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.
The aiocbp->aio_lio_opcode
field is ignored by
aio_write.
Return values
The aio_write function returns the value zero to the
calling process if the I/O operation is successfully
queued; otherwise, the function returns the value -1 and sets
errno to indicate the error.
Diagnostics
If the following condition occurs, the aio_write function
returns -1 and sets errno to the corresponding value:
[EAGAIN]-
The requested asynchronous I/O operation was not queued
due to system resource limitations.
Each of the following conditions may be detected synchronously at
the time of the call to aio_write, or asynchronously. If
any of the conditions below are detected synchronously, the
aio_write function returns -1 and sets errno 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:
[EBADF]-
The
aiocbp->aio_fildes
argument is not a valid file
descriptor open for writing.
[EINVAL]-
The file offset value implied by
aiocbp->aio_offset
would be invalid, aiocbp->aio_reqprio
is not a valid
value, aiocbp->aio_nbytes
is an invalid value or
aiocbp->aio_buf
is invalid.
In the case that the aio_write successfully queues the
I/O operation, the return status of the asynchronous
operation is one of the values normally returned by the
write 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 write function call, or one
of the following:
[EBADF]-
The
aiocbp->aio_fildes
argument is not a valid file
descriptor open for writing.
[EINVAL]-
The file offset value implied by
aiocbp->aio_offset
would be invalid.
See also
aio(FP),
aio_error(S-osr5),
aio_mkcbs(S-osr5),
aio_read(S-osr5),
aio_return(S-osr5),
close(S-osr5),
_exit(S-osr5),
exec(S-osr5),
fork(S-osr5),
lio_listio(S-osr5),
lseek(S-osr5),
write(S-osr5)
Standards conformance
Text reprinted and/or adapted from IEEE Std 1003.1b-1993,
IEEE Standard for Information Technology, POSIX
Part 1: System Application Program Interface (API)
Amendment 1: Realtime Extensions [C Language], copyright © 1993
by the Institute of Electrical and Electronics Engineers, Inc. The
IEEE takes no responsibility for and will assume no
liability for damages resulting from the reader's misinterpretation
of said information resulting from the placement and context in this
publication. Information is reproduced with the permission of the
IEEE.
© 2005 System Services (S-osr5)
SCO OpenServer Release 6.0.0 -- 02 June 2005