.\" Copyright (C) 2003, Michael Kerrisk (mtk.manpages@gmail.com) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" 2003-12-10 Initial creation, Michael Kerrisk .\" 2004-10-28 aeb, corrected prototype, prot must be 0 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2004-2005 Yuichi SATO .\" all rights reserved. .\" Translated Thu Jun 24 06:00:37 JST 2004 .\" by Yuichi SATO .\" Updated & Modified Mon Jan 3 02:50:11 JST 2005 by Yuichi SATO .\" Updated & Modified Mon Oct 10 01:15:38 JST 2005 .\" by Akihiro MOTOKI .\" .TH REMAP_FILE_PAGES 2 2014\-05\-28 Linux "Linux Programmer's Manual" .SH 名前 remap_file_pages \- 非線形ファイルマッピングを作成する。 .SH 書式 .nf \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ \fB#include \fP .sp \fBint remap_file_pages(void *\fP\fIaddr\fP\fB, size_t \fP\fIsize\fP\fB, int \fP\fIprot\fP\fB,\fP \fB size_t \fP\fIpgoff\fP\fB, int \fP\fIflags\fP\fB);\fP .fi .SH 説明 .\" commit 33041a0d76d3c3e0aff28ac95a2ffdedf1282dbc .\" http://lwn.net/Articles/597632/ \fB注意\fP: このシステムコールは (Linux 3.16 以降で) 非推奨となっており、 やがてより低速なカーネル内でのエミュレーションに置き換えられる予定である。 このシステムコールを使用しているアプリケーションは少ないが、こうしたアプリケーションは代替手段への移行を検討すべきである。 \fBremap_file_pages\fP() システムコールは非線形なマッピング、 つまりファイルのページがメモリー上で連続しない順番でマップされる マッピングを作成するために使われる。 \fBremap_file_pages\fP() を使う方が \fBmmap\fP(2) を繰り返して使うより優れている点は、 前者の方法ではカーネルが VMA (Virtual Memory Area, 仮想メモリー領域) データ構造体を追加で作成する必要がないことである。 非線形マッピングを作成するためには、 以下のようなステップを実行する: .TP 3 1. \fBmmap\fP(2) を使い、マッピングを作成する (このマッピングは最初は線形である)。 このマッピングは \fBMAP_SHARED\fP フラグを指定して作成されなければならない。 .TP 2. \fBremap_file_pages\fP() を 1 回以上呼び出して、 マッピングのページとファイルのページの対応関係を再構成する。 ファイルの同じページをマッピング領域の複数の場所に マップすることが可能である。 .LP \fIpgoff\fP と \fIsize\fP 引き数は、マッピング内で再配置されるファイルの領域を指定する。 \fIpgoff\fP はファイルオフセットであり、単位はシステムのページサイズである。 \fIsize\fP は領域の長さであり、単位はバイトである。 \fIaddr\fP 引き数は 2 つの目的で使われる。 第 1 の目的は、この引き数によって再編成したいページの マッピングを識別することである。 よって \fIaddr\fP は \fBmmap\fP(2) の呼び出しで過去にマップされた領域内のアドレスでなければならない。 第 2 の目的は、 \fIpgoff\fP と \fIsize\fP で識別されるファイルページが置かれる予定のアドレスを、 \fIaddr\fP によって指定することである。 .\" This rounding is weird, and not consistent with the treatment of .\" the analogous arguments for munmap()/mprotect() and for mlock(). .\" MTK, 14 Sep 2005 \fIaddr\fP と \fIsize\fP に指定する値は、システムのページサイズの倍数とすべきである。 それ以外の場合、カーネルは「両方」の値を 最も近いページサイズの倍数へ「切り下げる」。 \fIprot\fP 引き数は 0 に指定されなければならない。 \fIflags\fP 引き数は \fBmmap\fP(2) のものと同じ意味であるが、 \fBMAP_NONBLOCK\fP 以外の全てのフラグは無視される。 .SH 返り値 成功した場合、 \fBremap_file_pages\fP() は 0 を返す。 エラーの場合、\-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEINVAL\fP \fIaddr\fP が \fBMAP_SHARED\fP フラグを指定して作成された有効なマッピングを参照していない。 .TP \fBEINVAL\fP .\" And possibly others from vma->vm_ops->populate() \fIaddr\fP, \fIsize\fP, \fIprot\fP, \fIpgoff\fP のいずれかが不正である。 .SH バージョン \fBremap_file_pages\fP() システムコールは Linux 2.5.46 で登場した。 glibc でのサポートは glibc バージョン 2.3.3 で追加された。 .SH 準拠 \fBremap_file_pages\fP() システムコールは Linux 固有のものである。 .SH 注意 .\" commit 3ee6dafc677a68e461a7ddafc94a580ebab80735 Linux 2.6.23 以降、 \fBremap_file_pages\fP() は tmpfs, hugetlbfs, ramfs などのインメモリーファイルシステム上にのみ非線形マッピングを作成する。 裏にデータストアを持つファイルシステム上では、 \fBremap_file_pages\fP() は、 ファイルのどの部分がどのアドレスにマッピングされているかの調整が、 \fBmmap\fP(2) を使った場合ほど効率的ではない。 .SH 関連項目 \fBgetpagesize\fP(2), \fBmmap\fP(2), \fBmmap2\fP(2), \fBmprotect\fP(2), \fBmremap\fP(2), \fBmsync\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。