aio_writeのヘルプ・マニュアル
日本語 英語
aio_write --help
man aio_write
AIO_WRITE(3) Linux Programmer’s Manual AIO_WRITE(3)
名前
aio_write - 非同期で書き込む
書式
#include
int aio_write(struct aiocb *aiocbp);
-lrt でリンクする。
説明
aio_write() 関数は非同期の "n = write(fd, buf, count)" をリクエストする
。 こ こ で fd, buf, count は 、 そ れ ぞ れ aiocbp->aio_fildes,
aiocbp->aio_buf, aiocbp->aio_nbytes で与えられる。返り値 (return sta-
tus) n は、完了時に aio_return(3) を使って取得できる。
O_APPEND が設定されない場合、カレントのファイル位置に関係なく、データは
絶 対ファイルオフセット aiocbp->aio_offset を開始点として書き込まれる。
O_APPEND が設定されている場合、データはファイルの終端に書き込まれる。こ
のリクエストの後の、カレントのファイル位置は規定されていない。
「 非同期」とは「リクエストがキューに入れられたら、この呼び出しはすぐに
返る」ということである。呼び出しから戻った時に、書き込みは完了してい る
か も知れないし、完了していないかも知れない。 aio_error(3) を使うことで
完了したかをテストできる。
_POSIX_PRIORITIZED_IO が定義されていて、かつファイルがこれをサポート し
て い る 場 合 、 非 同 期 操 作 は 呼 び 出 し た プロセスの優先度から
aiocbp->aio_reqprio を引いた優先度で登録 (submit) される。
フィールド aiocbp->aio_lio_opcode は無視される。
最大オフセットを超えた通常のファイルには、何もデータが書き込まれない。
返り値
成功した場合、0 が返される。エラーの場合、リクエストはキューに入れら れ
ず、 -1 が返されて、 errno が適切に設定される。エラーは最初に検知された
後で、 (状態 -1 を返す) aio_return(3) と (errno で取得できる EBADF のよ
うなエラー状態を返す) aio_error(3) で報告されるだろう。
エラー
EAGAIN リソースが足りない。
EBADF aio_fildes は書き込みのためにオープンされた有効なファイルディス
クリプタでない。
EFBIG ファイルは通常のファイルであり、少なくとも 1 バイトを書き込も う
としている。しかし開始位置が、このファイルの最大オフセットと同じ
かそれを超えている。
EINVAL aio_offset, aio_reqprio, aio_nbytes のうち 1 つ以上が無効であ る
。
ENOSYS この関数がサポートされていない。
準拠
POSIX.1-2001.
注意
使用する前に制御ブロックを 0 にしておくのは、よい考えである。この制御ブ
ロックは、読み込み操作が進行している間は変更すべきでない。読み込まれ る
バ ッファ領域は操作の最中にアクセスすべきではない。さもないと起こる結果
が不定になる。これに含まれるメモリ領域は、有効なままにしなければなら な
い。
関連項目
aio_cancel(3), aio_error(3), aio_fsync(3), aio_read(3), aio_return(3),
aio_suspend(3)
2003-11-14 AIO_WRITE(3)
AIO_WRITE(3) Linux Programmer’s Manual AIO_WRITE(3)
NAME
aio_write - asynchronous write
SYNOPSIS
#include
int aio_write(struct aiocb *aiocbp);
Link with -lrt.
DESCRIPTION
The aio_write() function requests an asynchronous "n = write(fd, buf,
count)" with fd, buf, count given by aiocbp->aio_fildes,
aiocbp->aio_buf, aiocbp->aio_nbytes, respectively. The return status n
can be retrieved upon completion using aio_return(3).
If O_APPEND is not set, the data is written starting at the absolute
file offset aiocbp->aio_offset, regardless of the current file posi-
tion. If O_APPEND is set, the data is written at the end of the file.
After this request, the value of the current file position is unspeci-
fied.
The "asynchronous" means that this call returns as soon as the request
has been enqueued; the write may or may not have completed when the
call returns. One tests for completion using aio_error(3).
If _POSIX_PRIORITIZED_IO is defined, and this file supports it, then
the asynchronous operation is submitted at a priority equal to that of
the calling process minus aiocbp->aio_reqprio.
The field aiocbp->aio_lio_opcode is ignored.
No data is written to a regular file beyond its maximum offset.
RETURN VALUE
On success, 0 is returned. On error the request is not enqueued, -1 is
returned, and errno is set appropriately. If an error is first
detected later, it will be reported via aio_return(3) (returns status
-1) and aio_error(3) (error status whatever one would have gotten in
errno, such as EBADF).
ERRORS
EAGAIN Out of resources.
EBADF aio_fildes is not a valid file descriptor open for writing.
EFBIG The file is a regular file, we want to write at least one byte,
but the starting position is at or beyond the maximum offset for
this file.
EINVAL One or more of aio_offset, aio_reqprio, aio_nbytes are invalid.
ENOSYS This function is not supported.
CONFORMING TO
POSIX.1-2001.
NOTES
It is a good idea to zero out the control block before use. This con-
trol block must not be changed while the write operation is in
progress. The buffer area being written out must not be accessed dur-
ing the operation or undefined results may occur. The memory areas
involved must remain valid.
SEE ALSO
aio_cancel(3), aio_error(3), aio_fsync(3), aio_read(3), aio_return(3),
aio_suspend(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
2003-11-14 AIO_WRITE(3)