OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / remap_file_pages.2
1 .\" Copyright (C) 2003, Michael Kerrisk (mtk.manpages@gmail.com)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" 2003-12-10 Initial creation, Michael Kerrisk <mtk.manpages@gmail.com>
24 .\" 2004-10-28 aeb, corrected prototype, prot must be 0
25 .\"
26 .\" Japanese Version Copyright (c) 2004-2005 Yuichi SATO
27 .\"         all rights reserved.
28 .\" Translated Thu Jun 24 06:00:37 JST 2004
29 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
30 .\" Updated & Modified Mon Jan  3 02:50:11 JST 2005 by Yuichi SATO
31 .\" Updated & Modified Mon Oct 10 01:15:38 JST 2005
32 .\"         by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
33 .\"
34 .TH REMAP_FILE_PAGES 2 2008-04-22 "Linux" "Linux Programmer's Manual"
35 .\"O .SH NAME
36 .SH Ì¾Á°
37 .\"O remap_file_pages \- create a nonlinear file mapping
38 remap_file_pages \- ÈóÀþ·Á¥Õ¥¡¥¤¥ë¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¡£
39 .\"O .SH SYNOPSIS
40 .SH ½ñ¼°
41 .nf
42 .B #define _GNU_SOURCE
43 .B #include <sys/mman.h>
44 .sp
45 .BI "int remap_file_pages(void *" addr ", size_t " size ", int " prot ,
46 .BI "                     ssize_t " pgoff ", int " flags );
47 .fi
48 .\"O .SH DESCRIPTION
49 .SH ÀâÌÀ
50 .\"O The
51 .\"O .BR remap_file_pages ()
52 .\"O system call is used to create a nonlinear mapping, that is, a mapping
53 .\"O in which the pages of the file are mapped into a nonsequential order
54 .\"O in memory.
55 .BR remap_file_pages ()
56 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÈóÀþ·Á¤Ê¥Þ¥Ã¥Ô¥ó¥°¡¢
57 ¤Ä¤Þ¤ê¥Õ¥¡¥¤¥ë¤Î¥Ú¡¼¥¸¤¬¥á¥â¥ê¾å¤ÇϢ³¤·¤Ê¤¤½çÈ֤ǥޥåפµ¤ì¤ë
58 ¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤ë¡£
59 .\"O The advantage of using
60 .\"O .BR remap_file_pages ()
61 .\"O over using repeated calls to
62 .\"O .BR mmap (2)
63 .\"O is that the former approach does not require the kernel to create
64 .\"O additional VMA (Virtual Memory Area) data structures.
65 .BR remap_file_pages ()
66 ¤ò»È¤¦Êý¤¬
67 .BR mmap (2)
68 ¤ò·«¤êÊÖ¤·¤Æ»È¤¦¤è¤êÍ¥¤ì¤Æ¤¤¤ëÅÀ¤Ï¡¢
69 Á°¼Ô¤ÎÊýË¡¤Ç¤Ï¥«¡¼¥Í¥ë¤¬ VMA (Virtual Memory Area, ²¾ÁÛ¥á¥â¥êÎΰè)
70 ¥Ç¡¼¥¿¹½Â¤ÂΤòÄɲäǺîÀ®¤¹¤ëɬÍפ¬¤Ê¤¤¤³¤È¤Ç¤¢¤ë¡£
71
72 .\"O To create a nonlinear mapping we perform the following steps:
73 ÈóÀþ·Á¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
74 °Ê²¼¤Î¤è¤¦¤Ê¥¹¥Æ¥Ã¥×¤ò¼Â¹Ô¤¹¤ë:
75 .TP 3
76 1.
77 .\"O Use
78 .\"O .BR mmap (2)
79 .\"O to create a mapping (which is initially linear).
80 .BR mmap (2)
81 ¤ò»È¤¤¡¢¥Þ¥Ã¥Ô¥ó¥°¤òºîÀ®¤¹¤ë (¤³¤Î¥Þ¥Ã¥Ô¥ó¥°¤ÏºÇ½é¤ÏÀþ·Á¤Ç¤¢¤ë)¡£
82 .\"O This mapping must be created with the
83 .\"O .B MAP_SHARED
84 .\"O flag.
85 ¤³¤Î¥Þ¥Ã¥Ô¥ó¥°¤Ï
86 .B MAP_SHARED
87 ¥Õ¥é¥°¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
88 .TP
89 2.
90 .\"O Use one or more calls to
91 .\"O .BR remap_file_pages ()
92 .\"O to rearrange the correspondence between the pages of the mapping
93 .\"O and the pages of the file.
94 .\"O It is possible to map the same page of a file
95 .\"O into multiple locations within the mapped region.
96 .BR remap_file_pages ()
97 ¤ò 1 ²ó°Ê¾å¸Æ¤Ó½Ð¤·¤Æ¡¢
98 ¥Þ¥Ã¥Ô¥ó¥°¤Î¥Ú¡¼¥¸¤È¥Õ¥¡¥¤¥ë¤Î¥Ú¡¼¥¸¤ÎÂбþ´Ø·¸¤òºÆ¹½À®¤¹¤ë¡£
99 ¥Õ¥¡¥¤¥ë¤ÎƱ¤¸¥Ú¡¼¥¸¤ò¥Þ¥Ã¥Ô¥ó¥°Îΰè¤ÎÊ£¿ô¤Î¾ì½ê¤Ë
100 ¥Þ¥Ã¥×¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¢¤ë¡£
101 .LP
102 .\"O The
103 .\"O .I pgoff
104 .\"O and
105 .\"O .I size
106 .\"O arguments specify the region of the file that is to be relocated
107 .\"O within the mapping:
108 .I pgoff
109 ¤È
110 .I size
111 °ú¤­¿ô¤Ï¡¢¥Þ¥Ã¥Ô¥ó¥°Æâ¤ÇºÆÇÛÃÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ÎÎΰè¤ò»ØÄꤹ¤ë¡£
112 .\"O .I pgoff
113 .\"O is a file offset in units of the system page size;
114 .I pgoff
115 ¤Ï¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤Ç¤¢¤ê¡¢Ã±°Ì¤Ï¥·¥¹¥Æ¥à¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤Ç¤¢¤ë¡£
116 .\"O .I size
117 .\"O is the length of the region in bytes.
118 .I size
119 ¤ÏÎΰè¤ÎŤµ¤Ç¤¢¤ê¡¢Ã±°Ì¤Ï¥Ð¥¤¥È¤Ç¤¢¤ë¡£
120
121 .\"O The
122 .\"O .I addr
123 .\"O argument serves two purposes.
124 .I addr
125 °ú¤­¿ô¤Ï 2 ¤Ä¤ÎÌÜŪ¤Ç»È¤ï¤ì¤ë¡£
126 .\"O First, it identifies the mapping whose pages we want to rearrange.
127 Âè 1 ¤ÎÌÜŪ¤Ï¡¢¤³¤Î°ú¤­¿ô¤Ë¤è¤Ã¤ÆºÆÊÔÀ®¤·¤¿¤¤¥Ú¡¼¥¸¤Î
128 ¥Þ¥Ã¥Ô¥ó¥°¤ò¼±Ê̤¹¤ë¤³¤È¤Ç¤¢¤ë¡£
129 .\"O Thus,
130 .\"O .I addr
131 .\"O must be an address that falls within
132 .\"O a region previously mapped by a call to
133 .\"O .BR mmap (2).
134 ¤è¤Ã¤Æ
135 .I addr
136 ¤Ï
137 .BR mmap (2)
138 ¤Î¸Æ¤Ó½Ð¤·¤Ç²áµî¤Ë¥Þ¥Ã¥×¤µ¤ì¤¿ÎΰèÆâ¤Î¥¢¥É¥ì¥¹¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
139 .\"O Second,
140 .\"O .I addr
141 .\"O specifies the address at which the file pages
142 .\"O identified by
143 .\"O .I pgoff
144 .\"O and
145 .\"O .I size
146 .\"O will be placed.
147 Âè 2 ¤ÎÌÜŪ¤Ï¡¢
148 .I pgoff
149 ¤È
150 .I size
151 ¤Ç¼±Ê̤µ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ú¡¼¥¸¤¬ÃÖ¤«¤ì¤ëͽÄê¤Î¥¢¥É¥ì¥¹¤ò¡¢
152 .I addr
153 ¤Ë¤è¤Ã¤Æ»ØÄꤹ¤ë¤³¤È¤Ç¤¢¤ë¡£
154
155 .\"O The values specified in
156 .\"O .I addr
157 .\"O and
158 .\"O .I size
159 .\"O should be multiples of the system page size.
160 .\"O If they are not, then the kernel rounds
161 .\"O .I both
162 .\"O values
163 .\"O .I down
164 .\"O to the nearest multiple of the page size.
165 .\"O .\" This rounding is weird, and not consistent with the treatment of
166 .\"O .\" the analogous arguments for munmap()/mprotect() and for mlock().
167 .\"O .\" MTK, 14 Sep 2005
168 .I addr
169 ¤È
170 .I size
171 ¤Ë»ØÄꤹ¤ëÃͤϡ¢¥·¥¹¥Æ¥à¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤ÎÇÜ¿ô¤È¤¹¤Ù¤­¤Ç¤¢¤ë¡£
172 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢¥«¡¼¥Í¥ë¤Ï¡ÖξÊý¡×¤ÎÃͤò
173 ºÇ¤â¶á¤¤¥Ú¡¼¥¸¥µ¥¤¥º¤ÎÇÜ¿ô¤Ø¡ÖÀڤ겼¤²¤ë¡×¡£
174 .\" ¤³¤Î´Ý¤á½èÍý¤ÏÉ÷ÊѤï¤ê¤Ç¡¢munmap()/mprotect() ¤ä mlock() ¤Î
175 .\" Æ±Íͤΰú¤­¿ô¤Î½èÍýÊýË¡¤È¤âÌ·½â¤¹¤ë¡£
176 .\" MTK, 14 Sep 2005
177
178 .\"O The
179 .\"O .I prot
180 .\"O argument must be specified as 0.
181 .I prot
182 °ú¤­¿ô¤Ï 0 ¤Ë»ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
183
184 .\"O The
185 .\"O .I flags
186 .\"O argument has the same meaning as for
187 .\"O .BR mmap (2),
188 .\"O but all flags other than
189 .\"O .B MAP_NONBLOCK
190 .\"O are ignored.
191 .I flags
192 °ú¤­¿ô¤Ï
193 .BR mmap (2)
194 ¤Î¤â¤Î¤ÈƱ¤¸°ÕÌ£¤Ç¤¢¤ë¤¬¡¢
195 .B MAP_NONBLOCK
196 °Ê³°¤ÎÁ´¤Æ¤Î¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡£
197 .\"O .SH "RETURN VALUE"
198 .SH ÊÖ¤êÃÍ
199 .\"O On success,
200 .\"O .BR remap_file_pages ()
201 .\"O returns 0.
202 .\"O On error, \-1 is returned, and
203 .\"O .I errno
204 .\"O is set appropriately.
205 À®¸ù¤·¤¿¾ì¹ç¡¢
206 .BR remap_file_pages ()
207 ¤Ï 0 ¤òÊÖ¤¹¡£
208 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤¬ÊÖ¤µ¤ì¡¢
209 .I errno
210 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
211 .\"O .SH ERRORS
212 .SH ¥¨¥é¡¼
213 .TP
214 .B EINVAL
215 .\"O .I addr
216 .\"O does not refer to a valid mapping
217 .\"O created with the
218 .\"O .B MAP_SHARED
219 .\"O flag.
220 .I addr
221 ¤¬
222 .B MAP_SHARED
223 ¥Õ¥é¥°¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿Í­¸ú¤Ê¥Þ¥Ã¥Ô¥ó¥°¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
224 .TP
225 .B EINVAL
226 .\"O .IR addr ,
227 .\"O .IR size ,
228 .\"O .IR prot ,
229 .\"O or
230 .\"O .I pgoff
231 .\"O is invalid.
232 .IR addr ,
233 .IR size ,
234 .IR prot ,
235 .I pgoff
236 ¤Î¤¤¤º¤ì¤«¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
237 .\"O .\" And possibly others from vma->vm_ops->populate()
238 .\"Osato:
239 .\"Osato: others ¤¬²¿¤ò»Ø¤¹¤Î¤«¤è¤¯Ê¬¤«¤é¤Ê¤¤¡£
240 .\"Osato:
241 .\" ¤Þ¤¿¤Ï vma->vm_ops->populate() ¤«¤é¤Î¾¤Î¥¨¥é¡¼¤«¤â¤·¤ì¤Ê¤¤¡£
242 .\"O .SH VERSIONS
243 .SH ¥Ð¡¼¥¸¥ç¥ó
244 .\"O The
245 .\"O .BR remap_file_pages ()
246 .\"O system call appeared in Linux 2.5.46;
247 .\"O glibc support was added in version 2.3.3.
248 .BR remap_file_pages ()
249 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 2.5.46 ¤ÇÅо줷¤¿¡£
250 glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.3.3 ¤ÇÄɲ䵤줿¡£
251 .\"O .SH "CONFORMING TO"
252 .SH ½àµò
253 .\"O The
254 .\"O .BR remap_file_pages ()
255 .\"O system call is Linux-specific.
256 .BR remap_file_pages ()
257 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇÍ­¤Î¤â¤Î¤Ç¤¢¤ë¡£
258 .\"O .SH "SEE ALSO"
259 .SH ´ØÏ¢¹àÌÜ
260 .BR getpagesize (2),
261 .BR mmap (2),
262 .BR mmap2 (2),
263 .BR mprotect (2),
264 .BR mremap (2),
265 .BR msync (2),
266 .BR feature_test_macros (7)