.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright 2003 Abhijit Menon-Sen .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" 2005-04-08 mtk, noted kernel version and added BUGS .\" .\" Japanese Version Copyright (c) 2004-2007 Yuichi SATO .\" all rights reserved. .\" Translated Sun Jun 20 16:23:17 JST 2004 .\" by Yuichi SATO , LDP v1.66 .\" Updated & Modified Fri Apr 22 03:05:51 JST 2005 by Yuichi SATO, LDP v2.02 .\" Updated & Modified Thu Jan 4 23:55:18 JST 2007 by Yuichi SATO, LDP v2.43 .\" .TH POSIX_FADVISE 2 2003-02-14 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O posix_fadvise \- predeclare an access pattern for file data posix_fadvise \- ファイルデータのアクセスパターンをあらかじめ宣言する .\"O .SH SYNOPSIS .SH 書式 .nf .B #define _XOPEN_SOURCE 600 .B #include .sp .BI "int posix_fadvise(int " fd ", off_t " offset ", off_t " len \ ", int " advice ");" .fi .\"O .SH DESCRIPTION .SH 説明 .\"O Programs can use .\"O .BR posix_fadvise () .\"O to announce an intention to access .\"O file data in a specific pattern in the future, thus allowing the kernel .\"O to perform appropriate optimizations. プログラムは、将来特定のパターンでファイルデータに アクセスする意思を伝えるために .BR posix_fadvise () を使うことができる。 これにより、カーネルが適切な最適化を実行することが可能になる。 .\"O The \fIadvice\fP applies to a (not necessarily existent) region starting .\"O at \fIoffset\fP and extending for \fIlen\fP bytes (or until the end of .\"O the file if \fIlen\fP is 0) within the file referred to by \fIfd\fP. .\"O The advice is not binding; it merely constitutes an expectation on behalf of .\"O the application. \fIadvice\fP は \fIfd\fP が参照しているファイルの \fIoffset\fP から始まる \fIlen\fP バイトの範囲内 (\fIlen\fP が 0 の場合はファイルの終りまで) の (必ずしも存在しない) 領域に適用される。 アドバイスは義務づけではない。 アドバイスは単にアプリケーションのために可能性を構成するだけである。 .\"O Permissible values for \fIadvice\fP include: \fIadvice\fP に許される値には、以下のものが含まれる: .TP .B POSIX_FADV_NORMAL .\"O Indicates that the application has no advice to give about its access .\"O pattern for the specified data. .\"O If no advice is given for an open file, .\"O this is the default assumption. 指定されたデータのアクセスパターンを指示するアドバイスを アプリケーションが何も持っていないことを示す。 オープンされたファイルにアドバイスが指定されない場合、 これがデフォルトで仮定される。 .TP .B POSIX_FADV_SEQUENTIAL .\"O The application expects to access the specified data sequentially (with .\"O lower offsets read before higher ones). アプリケーションは指定されたデータがシーケンシャルに (大きなオフセットの前に小さなオフセットのデータを読むように) アクセスされることを期待する。 .TP .B POSIX_FADV_RANDOM .\"O The specified data will be accessed in random order. 指定されたデータがランダムな順番でアクセスされる。 .TP .B POSIX_FADV_NOREUSE .\"O The specified data will be accessed only once. 指定されたデータは 1 度しかアクセスされない。 .TP .B POSIX_FADV_WILLNEED .\"O The specified data will be accessed in the near future. 指定されたデータは近い将来アクセスされる。 .TP .B POSIX_FADV_DONTNEED .\"O The specified data will not be accessed in the near future. 指定されたデータは近い将来アクセスされない。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, zero is returned. .\"O On error, an error number is returned. 成功した場合は 0 が返される。 失敗した場合はエラー番号が返される。 .\"O .SH ERRORS .SH エラー .TP .B EBADF .\"O The \fIfd\fP argument was not a valid file descriptor. \fIfd\fP 引き数が有効なファイルディスクリプタでない。 .TP .B EINVAL .\"O An invalid value was specified for \fIadvice\fP. 無効な値が \fIadvice\fP に指定された。 .TP .B ESPIPE .\"O returns EINVAL in this case.) .\"O The specified file descriptor refers to a pipe or FIFO. .\"O (Linux actually .\"O returns .\"O .B EINVAL .\"O in this case.) 指定されたファイルディスクリプタがパイプまたは FIFO を参照している (この場合、Linux は実際には .B EINVAL を返す)。 .\"O .SH VERSIONS .SH バージョン .\"O .BR posix_fadvise () .\"O appeared in kernel 2.5.60. .\"O .\" Actually as fadvise64() -- MTK .\"O Glibc support has been provided since version 2.2. .BR posix_fadvise () はカーネル 2.5.60 で登場した。 .\" 実際には fadvise64() として登場した。-- MTK glibc でのサポートは glibc バージョン 2.2 以降で行われている。 .\"O .SH "CONFORMING TO" .SH 準拠 POSIX.1-2001. .\"O Note that the type of the .\"O .I len .\"O argument was changed from .\"O .I size_t .\"O to .\"O .I off_t .\"O in POSIX.1-2003 TC1. .I len 引き数の型が POSIX.1-2003 TC1 において .I size_t から .I off_t に変更された点に注意すること。 .\"O .SH NOTES .\"O Under Linux, \fBPOSIX_FADV_NORMAL\fP sets the readahead window to the .\"O default size for the backing device; \fBPOSIX_FADV_SEQUENTIAL\fP doubles .\"O this size, and \fBPOSIX_FADV_RANDOM\fP disables file readahead entirely. .SH 注意 Linux では、\fBPOSIX_FADV_NORMAL\fP はバッキングデバイスの デフォルトサイズに先読み (readahead) ウインドウを設定する。 \fBPOSIX_FADV_SEQUENTIAL\fP はこのサイズを 2 倍し、 \fBPOSIX_FADV_RANDOM\fP は先読みを全く無効にする。 .\"O These changes affect the entire file, not just the specified region .\"O (but other open file handles to the same file are unaffected). これらの変更はファイル全体に影響し、指定された領域のみに影響するわけではない (しかし同じファイルに対する他のオープンファイルハンドルは影響を受けない)。 .\"O \fBPOSIX_FADV_WILLNEED\fP initiates a .\"O nonblocking read of the specified region into the page cache. .\"O The amount of data read may be decreased by the kernel depending .\"O on virtual memory load. .\"O (A few megabytes will usually be fully satisfied, .\"O and more is rarely useful.) \fBPOSIX_FADV_WILLNEED\fP は、 ページキャッシュに指定領域のブロックされない読み込みを開始する。 読み込まれるデータの総量は、 仮想メモリの負荷に依ってカーネルが減らすかもしれない (数メガバイトであれば通常は全く十分であり、 それより多くてもめったに役に立たない)。 .\"O In kernels before 2.6.18, \fBPOSIX_FADV_NOREUSE\fP had the .\"O same semantics as \fBPOSIX_FADV_WILLNEED\fP. .\"O This was probably a bug; since kernel 2.6.18, this flag is a no-op. 2.6.18 より前のカーネルでは、\fBPOSIX_FADV_NOREUSE\fP は \fBPOSIX_FADV_WILLNEED\fP と同じ意味であった。 これは多分バグであった。 カーネル 2.6.18 以降では、このフラグは何も行わない。 .\"O \fBPOSIX_FADV_DONTNEED\fP attempts to free cached pages associated with .\"O the specified region. .\"O This is useful, for example, while streaming large .\"O files. .\"O A program may periodically request the kernel to free cached data .\"O that has already been used, so that more useful cached pages are not .\"O discarded instead. \fBPOSIX_FADV_DONTNEED\fP は指定された領域に関連付けられた キャッシュページを解放しようとする。 例えば、これは大きなファイルをストリーミングするときに役立つ。 プログラムは、使用済みのキャッシュされたデータを解放するように、 定期的にカーネルに要求するかもしれない。 そうすることにより、さらに有効なキャッシュされたページが、 代わりに破棄されることはない。 .\"O Pages that have not yet been written out will be unaffected, so if the .\"O application wishes to guarantee that pages will be released, it should .\"O call .\"O .BR fsync (2) .\"O or .\"O .BR fdatasync (2) .\"O first. まだ書き出されていないページは影響を受けないので、 そのページの解放が保証されることをアプリケーションが望んでいるなら、 最初に .BR fsync (2) または .BR fdatasync (2) を呼ぶべきである。 .\"O .SH BUGS .SH バグ .\"O In kernels before 2.6.6, if .\"O .I len .\"O was specified as 0, then this was interpreted literally as "zero bytes", .\"O rather than as meaning "all bytes through to the end of the file". 2.6.6 より前のカーネルでは、 .I len に 0 が指定された場合、 「ファイルの終りまでの全てのバイト」という意味ではなく、 文字通り「0 バイト」として解釈されていた。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR readahead (2), .BR posix_fallocate (3), .BR posix_madvise (3), .\" FIXME . Write a posix_fadvise(3) page. .BR feature_test_macros (7)