aio_readのヘルプ・マニュアル
日本語 英語
aio_read --help
man aio_read
AIO_READ(3) Linux Programmer’s Manual AIO_READ(3)
名前
aio_read - 非同期で読み込む
書式
#include
int aio_read(struct aiocb *aiocbp);
-lrt でリンクする。
説明
aio_read() 関数は非同期の "n = read(fd, buf, count)" をリクエストする。
ここで fd, buf, count は、それぞれ aiocbp->aio_fildes, aiocbp->aio_buf,
aiocbp->aio_nbytes で与えられる。返り値 (return status) n は、完了時に
aio_return(3) を使って取得できる。
データは、カレントのファイル位置に関係なく、絶対ファイル オ フ セ ッ ト
aiocbp->aio_offset を開始点として読み込まれる。このリクエスト後の、カレ
ントのファイル位置は規定されていない。
「非同期」とは「リクエストがキューに入れられたら、この呼び出しはすぐ に
返 る」ということである。呼び出しから戻った時に、読み込みは完了している
かも知れないし、完了していないかも知れない。 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 は読み込みのためにオープンされた有効なファイルディス
クリプタでない。
EINVAL aio_offset, aio_reqprio, aio_nbytes のうち 1 つ以上が無効であ る
。
ENOSYS この関数がサポートされていない。
EOVERFLOW
ファイルが通常のファイルであり、ファイルの終端の前から読み込みを
開始して、少なくとも 1 バイトを読み込もうとした。しかし開始位 置
がこのファイルの最大オフセットを超えていた。
準拠
POSIX.1-2001.
注意
使用する前に制御ブロックを 0 にしておくのは、よい考えである。この制御ブ
ロックは、読み込み操作が進行している間は変更すべきでない。読み込まれ る
バ ッファ領域は操作の最中にアクセスすべきではない。さもないと起こる結果
が不定になる。これに含まれるメモリ領域は、有効なままにしなければなら な
い。
関連項目
aio_cancel(3), aio_error(3), aio_fsync(3), aio_return(3), aio_sus-
pend(3), aio_write(3)
2003-11-14 AIO_READ(3)
AIO_READ(3) Linux Programmer’s Manual AIO_READ(3)
NAME
aio_read - asynchronous read
SYNOPSIS
#include
int aio_read(struct aiocb *aiocbp);
Link with -lrt.
DESCRIPTION
The aio_read() function requests an asynchronous "n = read(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).
The data is read starting at the absolute file offset aiocbp->aio_off-
set, regardless of the current file position. After this request, the
value of the current file position is unspecified.
The "asynchronous" means that this call returns as soon as the request
has been enqueued; the read 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 read from 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 reading.
EINVAL One or more of aio_offset, aio_reqprio, aio_nbytes are invalid.
ENOSYS This function is not supported.
EOVERFLOW
The file is a regular file, we start reading before end-of-file
and want at least one byte, but the starting position is past
the maximum offset for this file.
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 read operation is in progress.
The buffer area being read into must not be accessed during the opera-
tion or undefined results may occur. The memory areas involved must
remain valid.
SEE ALSO
aio_cancel(3), aio_error(3), aio_fsync(3), aio_return(3), aio_sus-
pend(3), aio_write(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_READ(3)