]>
Commit | Line | Data |
---|---|---|
a62f5121 | 1 | .\" Copyright (C) 1996 Andries Brouwer <aeb@cwi.nl> |
c11b1abf | 2 | .\" and Copyright (C) 2006, 2007 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 3 | .\" |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
fea681da MK |
25 | .\" |
26 | .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com> | |
27 | .\" Modified 2000-03-25 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
28 | .\" Modified 2001-10-04 by John Levon <moz@compsoc.man.ac.uk> | |
29 | .\" Modified 2003-02-02 by Andi Kleen <ak@muc.de> | |
c11b1abf | 30 | .\" Modified 2003-05-21 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 31 | .\" MAP_LOCKED works from 2.5.37 |
c11b1abf | 32 | .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 33 | .\" Modified 2004-09-11 by aeb |
1a956089 MK |
34 | .\" Modified 2004-12-08, from Eric Estievenart <eric.estievenart@free.fr> |
35 | .\" Modified 2004-12-08, mtk, formatting tidy-ups | |
a62f5121 | 36 | .\" Modified 2006-12-04, mtk, various parts rewritten |
74fa61b7 | 37 | .\" 2007-07-10, mtk, Added an example program. |
e6205b0c | 38 | .\" 2008-11-18, mtk, document MAP_STACK |
fea681da | 39 | .\" |
09b8afdc | 40 | .TH MMAP 2 2018-04-30 "Linux" "Linux Programmer's Manual" |
fea681da MK |
41 | .SH NAME |
42 | mmap, munmap \- map or unmap files or devices into memory | |
43 | .SH SYNOPSIS | |
e0037472 | 44 | .nf |
fea681da | 45 | .B #include <sys/mman.h> |
68e4db0a | 46 | .PP |
14f5ae6d | 47 | .BI "void *mmap(void *" addr ", size_t " length \ |
a62f5121 | 48 | ", int " prot ", int " flags , |
e0037472 | 49 | .BI " int " fd ", off_t " offset ); |
14f5ae6d | 50 | .BI "int munmap(void *" addr ", size_t " length ); |
e0037472 | 51 | .fi |
dbfe9c70 | 52 | .PP |
45e97e2a | 53 | See NOTES for information on feature test macro requirements. |
fea681da | 54 | .SH DESCRIPTION |
1a956089 | 55 | .BR mmap () |
c13182ef | 56 | creates a new mapping in the virtual address space of |
5e8cde2f MK |
57 | the calling process. |
58 | The starting address for the new mapping is specified in | |
14f5ae6d | 59 | .IR addr . |
5e8cde2f MK |
60 | The |
61 | .I length | |
c19250ad | 62 | argument specifies the length of the mapping (which must be greater than 0). |
efeece04 | 63 | .PP |
5e8cde2f | 64 | If |
14f5ae6d | 65 | .I addr |
5e8cde2f | 66 | is NULL, |
365a54c7 MK |
67 | then the kernel chooses the (page-aligned) address |
68 | at which to create the mapping; | |
5e8cde2f | 69 | this is the most portable method of creating a new mapping. |
c13182ef | 70 | If |
14f5ae6d | 71 | .I addr |
5e8cde2f MK |
72 | is not NULL, |
73 | then the kernel takes it as a hint about where to place the mapping; | |
6aa7db0a MK |
74 | on Linux, the mapping will be created at a nearby page boundary. |
75 | .\" Before Linux 2.6.24, the address was rounded up to the next page | |
29328361 | 76 | .\" boundary; since 2.6.24, it is rounded down! |
5e8cde2f | 77 | The address of the new mapping is returned as the result of the call. |
efeece04 | 78 | .PP |
5e8cde2f MK |
79 | The contents of a file mapping (as opposed to an anonymous mapping; see |
80 | .B MAP_ANONYMOUS | |
d9bfdb9c | 81 | below), are initialized using |
fea681da MK |
82 | .I length |
83 | bytes starting at offset | |
84 | .I offset | |
5e8cde2f MK |
85 | in the file (or other object) referred to by the file descriptor |
86 | .IR fd . | |
a62f5121 MK |
87 | .I offset |
88 | must be a multiple of the page size as returned by | |
89 | .IR sysconf(_SC_PAGE_SIZE) . | |
fa38cc32 MK |
90 | .PP |
91 | After the | |
92 | .BR mmap () | |
93 | call has returned, the file descriptor, | |
94 | .IR fd , | |
95 | can be closed immediately without invalidating the mapping. | |
dd3568a1 | 96 | .PP |
fea681da MK |
97 | The |
98 | .I prot | |
c13182ef | 99 | argument describes the desired memory protection of the mapping |
5e8cde2f MK |
100 | (and must not conflict with the open mode of the file). |
101 | It is either | |
fea681da | 102 | .B PROT_NONE |
a62f5121 | 103 | or the bitwise OR of one or more of the following flags: |
fea681da MK |
104 | .TP 1.1i |
105 | .B PROT_EXEC | |
106 | Pages may be executed. | |
107 | .TP | |
108 | .B PROT_READ | |
109 | Pages may be read. | |
110 | .TP | |
111 | .B PROT_WRITE | |
112 | Pages may be written. | |
113 | .TP | |
114 | .B PROT_NONE | |
115 | Pages may not be accessed. | |
dd3568a1 | 116 | .PP |
fea681da MK |
117 | The |
118 | .I flags | |
a62f5121 MK |
119 | argument determines whether updates to the mapping |
120 | are visible to other processes mapping the same region, | |
ba7cb080 | 121 | and whether updates are carried through to the underlying file. |
d9bfdb9c | 122 | This behavior is determined by including exactly one |
a62f5121 | 123 | of the following values in |
5e8cde2f | 124 | .IR flags : |
ca90e95a | 125 | .TP |
fea681da | 126 | .B MAP_SHARED |
c13182ef | 127 | Share this mapping. |
bf525e90 MK |
128 | Updates to the mapping are visible to other processes mapping the same region, |
129 | and (in the case of file-backed mappings) | |
130 | are carried through to the underlying file. | |
72e8bdae MK |
131 | (To precisely control when updates are carried through |
132 | to the underlying file requires the use of | |
133 | .BR msync (2).) | |
fea681da | 134 | .TP |
d8aeb42d | 135 | .BR MAP_SHARED_VALIDATE " (since Linux 4.15)" |
79da08c8 | 136 | This flag provides the same behavior as |
d8aeb42d JK |
137 | .B MAP_SHARED |
138 | except that | |
139 | .B MAP_SHARED | |
140 | mappings ignore unknown flags in | |
141 | .IR flags . | |
79da08c8 | 142 | By contrast, when creating a mapping using |
08a239f3 | 143 | .BR MAP_SHARED_VALIDATE , |
79da08c8 MK |
144 | the kernel verifies all passed flags are known and fails the |
145 | mapping with the error | |
d8aeb42d | 146 | .BR EOPNOTSUPP |
79da08c8 MK |
147 | for unknown flags. |
148 | This mapping type is also required to be able to use some mapping flags | |
149 | (e.g., | |
150 | .BR MAP_SYNC ). | |
d8aeb42d | 151 | .TP |
fea681da MK |
152 | .B MAP_PRIVATE |
153 | Create a private copy-on-write mapping. | |
a62f5121 MK |
154 | Updates to the mapping are not visible to other processes |
155 | mapping the same file, and are not carried through to | |
156 | the underlying file. | |
fea681da | 157 | It is unspecified whether changes made to the file after the |
1a956089 | 158 | .BR mmap () |
fea681da | 159 | call are visible in the mapped region. |
dd3568a1 | 160 | .PP |
421508eb MK |
161 | Both |
162 | .B MAP_SHARED | |
163 | and | |
164 | .B MAP_PRIVATE | |
165 | are described in POSIX.1-2001 and POSIX.1-2008. | |
79da08c8 MK |
166 | .B MAP_SHARED_VALIDATE |
167 | is a Linux extension. | |
efeece04 | 168 | .PP |
a62f5121 MK |
169 | In addition, zero or more of the following values can be ORed in |
170 | .IR flags : | |
fea681da | 171 | .TP |
c368e7ca MK |
172 | .BR MAP_32BIT " (since Linux 2.4.20, 2.6)" |
173 | Put the mapping into the first 2 Gigabytes of the process address space. | |
33a0ccb2 | 174 | This flag is supported only on x86-64, for 64-bit programs. |
c368e7ca | 175 | It was added to allow thread stacks to be allocated somewhere |
ee8655b5 | 176 | in the first 2\ GB of memory, |
c368e7ca MK |
177 | so as to improve context-switch performance on some early |
178 | 64-bit processors. | |
179 | .\" See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08 | |
180 | Modern x86-64 processors no longer have this performance problem, | |
181 | so use of this flag is not required on those systems. | |
182 | The | |
83314009 | 183 | .B MAP_32BIT |
c368e7ca | 184 | flag is ignored when |
a62f5121 | 185 | .B MAP_FIXED |
83314009 | 186 | is set. |
fea681da | 187 | .TP |
a62f5121 | 188 | .B MAP_ANON |
c13182ef MK |
189 | Synonym for |
190 | .BR MAP_ANONYMOUS . | |
a62f5121 MK |
191 | Deprecated. |
192 | .TP | |
fea681da | 193 | .B MAP_ANONYMOUS |
5e8cde2f | 194 | The mapping is not backed by any file; |
d9bfdb9c | 195 | its contents are initialized to zero. |
5e8cde2f | 196 | The |
fea681da | 197 | .I fd |
423cb9f7 | 198 | argument is ignored; |
c13182ef | 199 | however, some implementations require |
a62f5121 | 200 | .I fd |
c13182ef MK |
201 | to be \-1 if |
202 | .B MAP_ANONYMOUS | |
203 | (or | |
204 | .BR MAP_ANON ) | |
a62f5121 MK |
205 | is specified, |
206 | and portable applications should ensure this. | |
423cb9f7 JH |
207 | The |
208 | .I offset | |
209 | argument should be zero. | |
210 | .\" See the pgoff overflow check in do_mmap(). | |
211 | .\" See the offset check in sys_mmap in arch/x86/kernel/sys_x86_64.c. | |
c13182ef | 212 | The use of |
a62f5121 | 213 | .B MAP_ANONYMOUS |
c13182ef | 214 | in conjunction with |
51ffcca0 | 215 | .B MAP_SHARED |
33a0ccb2 | 216 | is supported on Linux only since kernel 2.4. |
fea681da | 217 | .TP |
83314009 MK |
218 | .B MAP_DENYWRITE |
219 | This flag is ignored. | |
220 | .\" Introduced in 1.1.36, removed in 1.3.24. | |
a7a21482 MK |
221 | (Long ago\(emLinux 2.0 and earlier\(emit signaled |
222 | that attempts to write to the underlying file should fail with | |
83314009 MK |
223 | .BR ETXTBUSY . |
224 | But this was a source of denial-of-service attacks.) | |
225 | .TP | |
226 | .B MAP_EXECUTABLE | |
227 | This flag is ignored. | |
228 | .\" Introduced in 1.1.38, removed in 1.3.24. Flag tested in proc_follow_link. | |
d9bfdb9c | 229 | .\" (Long ago, it signaled that the underlying file is an executable. |
83314009 MK |
230 | .\" However, that information was not really used anywhere.) |
231 | .\" Linus talked about DOS related to MAP_EXECUTABLE, but he was thinking of | |
232 | .\" MAP_DENYWRITE? | |
233 | .TP | |
fea681da | 234 | .B MAP_FILE |
c13182ef MK |
235 | Compatibility flag. |
236 | Ignored. | |
988db661 | 237 | .\" On some systems, this was required as the opposite of |
83314009 | 238 | .\" MAP_ANONYMOUS -- mtk, 1 May 2007 |
fea681da | 239 | .TP |
51ffcca0 | 240 | .B MAP_FIXED |
83314009 | 241 | Don't interpret |
14f5ae6d | 242 | .I addr |
83314009 | 243 | as a hint: place the mapping at exactly that address. |
14f5ae6d | 244 | .I addr |
87c8ded5 | 245 | must be suitably aligned: for most architectures a multiple of the page |
04bb0b99 | 246 | size is sufficient; however, some architectures may impose additional |
e2da344f MK |
247 | restrictions. |
248 | If the memory region specified by | |
14f5ae6d | 249 | .I addr |
83314009 MK |
250 | and |
251 | .I len | |
252 | overlaps pages of any existing mapping(s), then the overlapped | |
253 | part of the existing mapping(s) will be discarded. | |
254 | If the specified address cannot be used, | |
255 | .BR mmap () | |
256 | will fail. | |
0113b287 | 257 | .IP |
56a033af MK |
258 | Software that aspires to be portable should use the |
259 | .BR MAP_FIXED | |
260 | flag with care, | |
9b92bc14 | 261 | keeping in mind that the exact layout of a process's memory mappings |
e2da344f MK |
262 | is allowed to change significantly between kernel versions, |
263 | C library versions, and operating system releases. | |
49a8d3a1 | 264 | .IR "Carefully read the discussion of this flag in NOTES!" |
c6a51c06 MH |
265 | .TP |
266 | .BR MAP_FIXED_NOREPLACE " (since Linux 4.17)" | |
3a548c59 MK |
267 | .\" commit a4ff8e8620d3f4f50ac4b41e8067b7d395056843 |
268 | This flag provides behavior that is similar to | |
228d889f MK |
269 | .B MAP_FIXED |
270 | with respect to the | |
271 | .I addr | |
3a548c59 | 272 | enforcement, but differs in that |
228d889f | 273 | .B MAP_FIXED_NOREPLACE |
509935b7 | 274 | never clobbers a preexisting mapped range. |
007d7833 | 275 | If the requested range would collide with an existing mapping, |
3a548c59 | 276 | then this call fails with the error |
c6a51c06 | 277 | .B EEXIST. |
007d7833 MK |
278 | This flag can therefore be used as a way to atomically |
279 | (with respect to other threads) attempt to map an address range: | |
280 | one thread will succeed; all others will report failure. | |
08a239f3 | 281 | .IP |
a8fd3403 MK |
282 | Note that older kernels which do not recognize the |
283 | .BR MAP_FIXED_NOREPLACE | |
509935b7 | 284 | flag will typically (upon detecting a collision with a preexisting mapping) |
73cb50e2 MK |
285 | fall back to a "non-\c |
286 | .B MAP_FIXED\c | |
287 | " type of behavior: | |
3a548c59 | 288 | they will return an address that is different from the requested address. |
007d7833 | 289 | Therefore, backward-compatible software |
c6a51c06 | 290 | should check the returned address against the requested address. |
fea681da | 291 | .TP |
83314009 | 292 | .B MAP_GROWSDOWN |
86f12eb0 MK |
293 | This flag is used for stacks. |
294 | It indicates to the kernel virtual memory system that the mapping | |
5fab2e7c | 295 | should extend downward in memory. |
176b1a76 MK |
296 | The return address is one page lower than the memory area that is |
297 | actually created in the process's virtual address space. | |
298 | Touching an address in the "guard" page below the mapping will cause | |
299 | the mapping to grow by a page. | |
300 | This growth can be repeated until the mapping grows to within a | |
301 | page of the high end of the next lower mapping, | |
302 | at which point touching the "guard" page will result in a | |
303 | .B SIGSEGV | |
304 | signal. | |
83314009 | 305 | .TP |
76a34baa MK |
306 | .BR MAP_HUGETLB " (since Linux 2.6.32)" |
307 | Allocate the mapping using "huge pages." | |
66a9882e | 308 | See the Linux kernel source file |
a2463bae | 309 | .I Documentation/admin-guide/mm/hugetlbpage.rst |
f1461fe1 | 310 | for further information, as well as NOTES, below. |
76a34baa | 311 | .TP |
5d2038b6 MK |
312 | .BR MAP_HUGE_2MB ", " MAP_HUGE_1GB " (since Linux 3.8)" |
313 | .\" See https://lwn.net/Articles/533499/ | |
314 | Used in conjunction with | |
315 | .B MAP_HUGETLB | |
c4b7e5ac | 316 | to select alternative hugetlb page sizes (respectively, 2\ MB and 1\ GB) |
5d2038b6 | 317 | on systems that support multiple hugetlb page sizes. |
efeece04 | 318 | .IP |
5d2038b6 MK |
319 | More generally, the desired huge page size can be configured by encoding |
320 | the base-2 logarithm of the desired page size in the six bits at the offset | |
321 | .BR MAP_HUGE_SHIFT . | |
322 | (A value of zero in this bit field provides the default huge page size; | |
a6bf8e7e | 323 | the default huge page size can be discovered via the |
5d2038b6 MK |
324 | .I Hugepagesize |
325 | field exposed by | |
326 | .IR /proc/meminfo .) | |
327 | Thus, the above two constants are defined as: | |
efeece04 | 328 | .IP |
5d2038b6 | 329 | .in +4n |
b8302363 | 330 | .EX |
5d2038b6 MK |
331 | #define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT) |
332 | #define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT) | |
b8302363 | 333 | .EE |
e646a1ba | 334 | .in |
efeece04 | 335 | .IP |
5d2038b6 MK |
336 | The range of huge page sizes that are supported by the system |
337 | can be discovered by listing the subdirectories in | |
338 | .IR /sys/kernel/mm/hugepages . | |
339 | .TP | |
83314009 | 340 | .BR MAP_LOCKED " (since Linux 2.5.37)" |
db4e8e25 | 341 | Mark the mapped region to be locked in the same way as |
74d32233 | 342 | .BR mlock (2). |
db4e8e25 MK |
343 | This implementation will try to populate (prefault) the whole range but the |
344 | .BR mmap () | |
345 | call doesn't fail with | |
7e3786bc | 346 | .B ENOMEM |
911f1c7a MK |
347 | if this fails. |
348 | Therefore major faults might happen later on. | |
349 | So the semantic is not as strong as | |
7e3786bc | 350 | .BR mlock (2). |
911f1c7a | 351 | One should use |
bf7bc8b8 | 352 | .BR mmap () |
911f1c7a | 353 | plus |
7e3786bc | 354 | .BR mlock (2) |
911f1c7a MK |
355 | when major faults are not acceptable after the initialization of the mapping. |
356 | The | |
357 | .BR MAP_LOCKED | |
358 | flag is ignored in older kernels. | |
83314009 | 359 | .\" If set, the mapped pages will not be swapped out. |
fea681da MK |
360 | .TP |
361 | .BR MAP_NONBLOCK " (since Linux 2.5.46)" | |
3f06ade3 | 362 | This flag is meaningful only in conjunction with |
51ffcca0 | 363 | .BR MAP_POPULATE . |
c13182ef | 364 | Don't perform read-ahead: |
33a0ccb2 | 365 | create page tables entries only for pages |
51ffcca0 | 366 | that are already present in RAM. |
7c40de08 | 367 | Since Linux 2.6.23, this flag causes |
f38fa944 MK |
368 | .BR MAP_POPULATE |
369 | to do nothing. | |
487c2f05 | 370 | One day, the combination of |
f38fa944 MK |
371 | .BR MAP_POPULATE |
372 | and | |
373 | .BR MAP_NONBLOCK | |
3b777aff | 374 | may be reimplemented. |
83314009 MK |
375 | .TP |
376 | .B MAP_NORESERVE | |
377 | Do not reserve swap space for this mapping. | |
378 | When swap space is reserved, one has the guarantee | |
379 | that it is possible to modify the mapping. | |
8bd58774 MK |
380 | When swap space is not reserved one might get |
381 | .B SIGSEGV | |
382 | upon a write | |
83314009 MK |
383 | if no physical memory is available. |
384 | See also the discussion of the file | |
385 | .I /proc/sys/vm/overcommit_memory | |
386 | in | |
387 | .BR proc (5). | |
33a0ccb2 | 388 | In kernels before 2.6, this flag had effect only for |
83314009 MK |
389 | private writable mappings. |
390 | .TP | |
391 | .BR MAP_POPULATE " (since Linux 2.5.46)" | |
f38fa944 MK |
392 | Populate (prefault) page tables for a mapping. |
393 | For a file mapping, this causes read-ahead on the file. | |
bbebbb6d | 394 | This will help to reduce blocking on page faults later. |
f38fa944 | 395 | .BR MAP_POPULATE |
33a0ccb2 | 396 | is supported for private mappings only since Linux 2.6.23. |
e6205b0c MK |
397 | .TP |
398 | .BR MAP_STACK " (since Linux 2.6.27)" | |
399 | Allocate the mapping at an address suitable for a process | |
400 | or thread stack. | |
401 | This flag is currently a no-op, | |
402 | but is used in the glibc threading implementation so that | |
403 | if some architectures require special treatment for stack allocations, | |
404 | support can later be transparently implemented for glibc. | |
67b59ff5 | 405 | .\" See http://lwn.net/Articles/294642 "Tangled up in threads", 19 Aug 08 |
e6205b0c MK |
406 | .\" commit cd98a04a59e2f94fa64d5bf1e26498d27427d5e7 |
407 | .\" http://thread.gmane.org/gmane.linux.kernel/720412 | |
408 | .\" "pthread_create() slow for many threads; also time to revisit 64b | |
409 | .\" context switch optimization?" | |
12062404 | 410 | .TP |
d8aeb42d | 411 | .BR MAP_SYNC " (since Linux 4.15)" |
79da08c8 | 412 | This flag is available only with the |
d8aeb42d | 413 | .B MAP_SHARED_VALIDATE |
79da08c8 MK |
414 | mapping type; |
415 | mappings of type | |
d8aeb42d | 416 | .B MAP_SHARED |
79da08c8 | 417 | will silently ignore this flag. |
b138773b MK |
418 | This flag is supported only for files supporting DAX |
419 | (direct mapping of persistent memory). | |
79da08c8 | 420 | For other files, creating a mapping with this flag results in an |
d8aeb42d | 421 | .B EOPNOTSUPP |
b138773b | 422 | error. |
79da08c8 | 423 | .IP |
b138773b | 424 | Shared file mappings with this flag provide the guarantee that while |
79da08c8 | 425 | some memory is writably mapped in the address space of the process, |
b138773b MK |
426 | it will be visible in the same file at the same offset even after |
427 | the system crashes or is rebooted. | |
5bc2d858 MK |
428 | In conjunction with the use of appropriate CPU instructions, |
429 | this provides users of such mappings with a more efficient way | |
430 | of making data modifications persistent. | |
d8aeb42d | 431 | .TP |
12062404 MK |
432 | .BR MAP_UNINITIALIZED " (since Linux 2.6.33)" |
433 | Don't clear anonymous pages. | |
434 | This flag is intended to improve performance on embedded devices. | |
33a0ccb2 | 435 | This flag is honored only if the kernel was configured with the |
12062404 MK |
436 | .B CONFIG_MMAP_ALLOW_UNINITIALIZED |
437 | option. | |
438 | Because of the security implications, | |
439 | that option is normally enabled only on embedded devices | |
440 | (i.e., devices where one has complete control of the contents of user memory). | |
dd3568a1 | 441 | .PP |
7c7adcbe MK |
442 | Of the above flags, only |
443 | .B MAP_FIXED | |
78cdbef7 | 444 | is specified in POSIX.1-2001 and POSIX.1-2008. |
7c7adcbe MK |
445 | However, most systems also support |
446 | .B MAP_ANONYMOUS | |
447 | (or its synonym | |
448 | .BR MAP_ANON ). | |
f5f41651 MK |
449 | .\" FIXME . for later review when Issue 8 is one day released... |
450 | .\" POSIX may add MAP_ANON in the future | |
451 | .\" http://austingroupbugs.net/tag_view_page.php?tag_id=8 | |
452 | .\" http://austingroupbugs.net/view.php?id=850 | |
dd3568a1 | 453 | .PP |
fea681da | 454 | Memory mapped by |
1a956089 | 455 | .BR mmap () |
fea681da MK |
456 | is preserved across |
457 | .BR fork (2), | |
458 | with the same attributes. | |
dd3568a1 | 459 | .PP |
c13182ef MK |
460 | A file is mapped in multiples of the page size. |
461 | For a file that is not | |
fea681da | 462 | a multiple of the page size, the remaining memory is zeroed when mapped, |
c13182ef MK |
463 | and writes to that region are not written out to the file. |
464 | The effect of | |
fea681da MK |
465 | changing the size of the underlying file of a mapping on the pages that |
466 | correspond to added or removed regions of the file is unspecified. | |
de5f7e28 | 467 | .SS munmap() |
fea681da | 468 | The |
1a956089 | 469 | .BR munmap () |
fea681da MK |
470 | system call deletes the mappings for the specified address range, and |
471 | causes further references to addresses within the range to generate | |
c13182ef MK |
472 | invalid memory references. |
473 | The region is also automatically unmapped | |
474 | when the process is terminated. | |
475 | On the other hand, closing the file | |
fea681da | 476 | descriptor does not unmap the region. |
dd3568a1 | 477 | .PP |
fea681da | 478 | The address |
14f5ae6d | 479 | .I addr |
0e824bcb MK |
480 | must be a multiple of the page size (but |
481 | .I length | |
482 | need not be). | |
c13182ef | 483 | All pages containing a part |
fea681da | 484 | of the indicated range are unmapped, and subsequent references |
8bd58774 MK |
485 | to these pages will generate |
486 | .BR SIGSEGV . | |
c13182ef | 487 | It is not an error if the |
fea681da | 488 | indicated range does not contain any mapped pages. |
47297adb | 489 | .SH RETURN VALUE |
fea681da | 490 | On success, |
1a956089 | 491 | .BR mmap () |
fea681da MK |
492 | returns a pointer to the mapped area. |
493 | On error, the value | |
494 | .B MAP_FAILED | |
c13182ef | 495 | (that is, |
009df872 | 496 | .IR "(void\ *)\ \-1" ) |
5e8cde2f | 497 | is returned, and |
fea681da | 498 | .I errno |
80691a91 | 499 | is set to indicate the cause of the error. |
efeece04 | 500 | .PP |
fea681da | 501 | On success, |
1a956089 | 502 | .BR munmap () |
80691a91 MK |
503 | returns 0. |
504 | On failure, it returns \-1, and | |
fea681da | 505 | .I errno |
80691a91 | 506 | is set to indicate the cause of the error (probably to |
51ffcca0 | 507 | .BR EINVAL ). |
fea681da MK |
508 | .SH ERRORS |
509 | .TP | |
510 | .B EACCES | |
511 | A file descriptor refers to a non-regular file. | |
5e7c71f6 | 512 | Or a file mapping was requested, but |
fea681da MK |
513 | .I fd |
514 | is not open for reading. | |
c13182ef MK |
515 | Or |
516 | .B MAP_SHARED | |
517 | was requested and | |
518 | .B PROT_WRITE | |
51ffcca0 | 519 | is set, but |
fea681da | 520 | .I fd |
682edefb MK |
521 | is not open in read/write |
522 | .RB ( O_RDWR ) | |
523 | mode. | |
c13182ef MK |
524 | Or |
525 | .B PROT_WRITE | |
51ffcca0 | 526 | is set, but the file is append-only. |
fea681da MK |
527 | .TP |
528 | .B EAGAIN | |
83cd3686 MK |
529 | The file has been locked, or too much memory has been locked (see |
530 | .BR setrlimit (2)). | |
fea681da MK |
531 | .TP |
532 | .B EBADF | |
533 | .I fd | |
c13182ef | 534 | is not a valid file descriptor (and |
51ffcca0 MK |
535 | .B MAP_ANONYMOUS |
536 | was not set). | |
fea681da | 537 | .TP |
c6a51c06 | 538 | .B EEXIST |
95b9ecbf MK |
539 | .BR MAP_FIXED_NOREPLACE |
540 | was specified in | |
541 | .IR flags , | |
542 | and the range covered by | |
543 | .IR addr | |
544 | and | |
c6a51c06 | 545 | .IR length |
c3617f39 | 546 | clashes with an existing mapping. |
c6a51c06 | 547 | .TP |
fea681da MK |
548 | .B EINVAL |
549 | We don't like | |
14f5ae6d | 550 | .IR addr , |
62a04c81 | 551 | .IR length , |
fea681da | 552 | or |
0daa9e92 | 553 | .I offset |
62a04c81 MK |
554 | (e.g., they are too large, or not aligned on a page boundary). |
555 | .TP | |
556 | .B EINVAL | |
f99fc197 | 557 | (since Linux 2.6.12) |
fea681da | 558 | .I length |
62a04c81 MK |
559 | was 0. |
560 | .TP | |
561 | .B EINVAL | |
562 | .I flags | |
563 | contained neither | |
564 | .B MAP_PRIVATE | |
fea681da | 565 | or |
62a04c81 MK |
566 | .BR MAP_SHARED , |
567 | or contained both of these values. | |
fea681da MK |
568 | .TP |
569 | .B ENFILE | |
570 | .\" This is for shared anonymous segments | |
571 | .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp() | |
e258766b | 572 | The system-wide limit on the total number of open files has been reached. |
fea681da MK |
573 | .\" .TP |
574 | .\" .B ENOEXEC | |
575 | .\" A file could not be mapped for reading. | |
576 | .TP | |
577 | .B ENODEV | |
9ee4a2b6 | 578 | The underlying filesystem of the specified file does not support |
fea681da MK |
579 | memory mapping. |
580 | .TP | |
581 | .B ENOMEM | |
74309bed MK |
582 | No memory is available. |
583 | .TP | |
584 | .B ENOMEM | |
585 | The process's maximum number of mappings would have been exceeded. | |
c0b89788 | 586 | This error can also occur for |
3804d39d | 587 | .BR munmap (), |
c0b89788 MK |
588 | when unmapping a region in the middle of an existing mapping, |
589 | since this results in two smaller mappings on either side of | |
590 | the region being unmapped. | |
fea681da | 591 | .TP |
c87d084b JG |
592 | .B ENOMEM |
593 | (since Linux 4.7) | |
594 | The process's | |
595 | .B RLIMIT_DATA | |
596 | limit, described in | |
597 | .BR getrlimit (2), | |
598 | would have been exceeded. | |
599 | .TP | |
038f5175 MK |
600 | .B EOVERFLOW |
601 | On 32-bit architecture together with the large file extension | |
602 | (i.e., using 64-bit | |
603 | .IR off_t ): | |
604 | the number of pages used for | |
605 | .I length | |
606 | plus number of pages used for | |
607 | .I offset | |
608 | would overflow | |
609 | .I "unsigned long" | |
610 | (32 bits). | |
611 | .TP | |
fea681da MK |
612 | .B EPERM |
613 | The | |
614 | .I prot | |
615 | argument asks for | |
616 | .B PROT_EXEC | |
9ee4a2b6 | 617 | but the mapped area belongs to a file on a filesystem that |
fea681da MK |
618 | was mounted no-exec. |
619 | .\" (Since 2.4.25 / 2.6.0.) | |
620 | .TP | |
fbab10e5 MK |
621 | .B EPERM |
622 | The operation was prevented by a file seal; see | |
623 | .BR fcntl (2). | |
624 | .TP | |
fea681da | 625 | .B ETXTBSY |
c13182ef | 626 | .B MAP_DENYWRITE |
51ffcca0 | 627 | was set but the object specified by |
fea681da MK |
628 | .I fd |
629 | is open for writing. | |
dd3568a1 | 630 | .PP |
fea681da MK |
631 | Use of a mapped region can result in these signals: |
632 | .TP | |
633 | .B SIGSEGV | |
1e321034 | 634 | Attempted write into a region mapped as read-only. |
fea681da MK |
635 | .TP |
636 | .B SIGBUS | |
637 | Attempted access to a portion of the buffer that does not correspond | |
638 | to the file (for example, beyond the end of the file, including the | |
639 | case where another process has truncated the file). | |
8fddf95a MS |
640 | .SH ATTRIBUTES |
641 | For an explanation of the terms used in this section, see | |
642 | .BR attributes (7). | |
643 | .TS | |
644 | allbox; | |
645 | lbw18 lb lb | |
646 | l l l. | |
647 | Interface Attribute Value | |
648 | T{ | |
649 | .BR mmap (), | |
650 | .BR munmap () | |
651 | T} Thread safety MT-Safe | |
652 | .TE | |
47297adb | 653 | .SH CONFORMING TO |
78cdbef7 | 654 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD. |
2b2581ee MK |
655 | .\" SVr4 documents additional error codes ENXIO and ENODEV. |
656 | .\" SUSv2 documents additional error codes EMFILE and EOVERFLOW. | |
fea681da MK |
657 | .SH AVAILABILITY |
658 | On POSIX systems on which | |
1a956089 | 659 | .BR mmap (), |
9af134cd | 660 | .BR msync (2), |
fea681da | 661 | and |
1a956089 | 662 | .BR munmap () |
fea681da MK |
663 | are available, |
664 | .B _POSIX_MAPPED_FILES | |
6387216b MK |
665 | is defined in \fI<unistd.h>\fP to a value greater than 0. |
666 | (See also | |
fea681da | 667 | .BR sysconf (3).) |
97c1eac8 | 668 | .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L. |
fea681da MK |
669 | .\" -1: unavailable, 0: ask using sysconf(). |
670 | .\" glibc defines it to 1. | |
a1d5f77c | 671 | .SH NOTES |
34ccb744 | 672 | On some hardware architectures (e.g., i386), |
0daa9e92 | 673 | .B PROT_WRITE |
f3edaabb MK |
674 | implies |
675 | .BR PROT_READ . | |
a1d5f77c MK |
676 | It is architecture dependent whether |
677 | .B PROT_READ | |
678 | implies | |
679 | .B PROT_EXEC | |
680 | or not. | |
681 | Portable programs should always set | |
682 | .B PROT_EXEC | |
683 | if they intend to execute code in the new mapping. | |
efeece04 | 684 | .PP |
80d17cfa MK |
685 | The portable way to create a mapping is to specify |
686 | .I addr | |
687 | as 0 (NULL), and omit | |
688 | .B MAP_FIXED | |
689 | from | |
690 | .IR flags . | |
691 | In this case, the system chooses the address for the mapping; | |
46cdb997 | 692 | the address is chosen so as not to conflict with any existing mapping, |
80d17cfa MK |
693 | and will not be 0. |
694 | If the | |
695 | .B MAP_FIXED | |
696 | flag is specified, and | |
697 | .I addr | |
491cd2f0 | 698 | is 0 (NULL), then the mapped address will be 0 (NULL). |
efeece04 | 699 | .PP |
45e97e2a MK |
700 | Certain |
701 | .I flags | |
f8619b6a MK |
702 | constants are defined only if suitable feature test macros are defined |
703 | (possibly by default): | |
704 | .BR _DEFAULT_SOURCE | |
705 | with glibc 2.19 or later; | |
706 | or | |
45e97e2a MK |
707 | .BR _BSD_SOURCE |
708 | or | |
709 | .BR _SVID_SOURCE | |
f8619b6a | 710 | in glibc 2.19 and earlier. |
50efeef8 | 711 | (Employing |
45e97e2a MK |
712 | .BR _GNU_SOURCE |
713 | also suffices, | |
714 | and requiring that macro specifically would have been more logical, | |
76c637e1 | 715 | since these flags are all Linux-specific.) |
45e97e2a MK |
716 | The relevant flags are: |
717 | .BR MAP_32BIT , | |
718 | .BR MAP_ANONYMOUS | |
719 | (and the synonym | |
720 | .BR MAP_ANON ), | |
721 | .BR MAP_DENYWRITE , | |
722 | .BR MAP_EXECUTABLE , | |
723 | .BR MAP_FILE , | |
724 | .BR MAP_GROWSDOWN , | |
725 | .BR MAP_HUGETLB , | |
726 | .BR MAP_LOCKED , | |
727 | .BR MAP_NONBLOCK , | |
728 | .BR MAP_NORESERVE , | |
729 | .BR MAP_POPULATE , | |
730 | and | |
731 | .BR MAP_STACK . | |
efeece04 | 732 | .PP |
3bd859bf MK |
733 | An application can determine which pages of a mapping are |
734 | currently resident in the buffer/page cache using | |
735 | .BR mincore (2). | |
35c189fb | 736 | .\" |
49a8d3a1 MK |
737 | .SS Using MAP_FIXED safely |
738 | The only safe use for | |
739 | .BR MAP_FIXED | |
740 | is where the address range specified by | |
741 | .IR addr | |
742 | and | |
743 | .I length | |
744 | was previously reserved using another mapping; | |
745 | otherwise, the use of | |
746 | .BR MAP_FIXED | |
747 | is hazardous because it forcibly removes preexisting mappings, | |
748 | making it easy for a multithreaded process to corrupt its own address space. | |
749 | .PP | |
750 | For example, suppose that thread A looks through | |
751 | .I /proc/<pid>/maps | |
56f85b84 MK |
752 | and in order to locate an unused address range that it can map using |
753 | .BR MAP_FIXED , | |
49a8d3a1 MK |
754 | while thread B simultaneously acquires part or all of that same |
755 | address range. | |
56f85b84 | 756 | When thread A subsequently employs |
49a8d3a1 | 757 | .BR mmap(MAP_FIXED) , |
56f85b84 | 758 | it will effectively clobber the mapping that thread B created. |
49a8d3a1 MK |
759 | In this scenario, |
760 | thread B need not create a mapping directly; simply making a library call | |
761 | that, internally, uses | |
762 | .BR dlopen (3) | |
763 | to load some other shared library, will suffice. | |
764 | The | |
765 | .BR dlopen (3) | |
766 | call will map the library into the process's address space. | |
767 | Furthermore, almost any library call may be implemented in a way that | |
768 | adds memory mappings to the address space, either with this technique, | |
769 | or by simply allocating memory. | |
770 | Examples include | |
771 | .BR brk (2), | |
772 | .BR malloc (3), | |
773 | .BR pthread_create (3), | |
774 | and the PAM libraries | |
775 | .UR http://www.linux-pam.org | |
776 | .UE . | |
777 | .PP | |
0949fa5e | 778 | Since Linux 4.17, a multithreaded program can use the |
49a8d3a1 | 779 | .BR MAP_FIXED_NOREPLACE |
0949fa5e MK |
780 | flag to avoid the hazard described above |
781 | when attempting to create a mapping at a fixed address | |
782 | that has not been reserved by a preexisting mapping. | |
49a8d3a1 | 783 | .\" |
0f319769 MK |
784 | .SS Timestamps changes for file-backed mappings |
785 | For file-backed mappings, the | |
786 | .I st_atime | |
787 | field for the mapped file may be updated at any time between the | |
788 | .BR mmap () | |
789 | and the corresponding unmapping; the first reference to a mapped | |
790 | page will update the field if it has not been already. | |
dd3568a1 | 791 | .PP |
0f319769 MK |
792 | The |
793 | .I st_ctime | |
794 | and | |
795 | .I st_mtime | |
796 | field for a file mapped with | |
797 | .B PROT_WRITE | |
798 | and | |
799 | .B MAP_SHARED | |
800 | will be updated after | |
801 | a write to the mapped region, and before a subsequent | |
802 | .BR msync (2) | |
803 | with the | |
804 | .B MS_SYNC | |
805 | or | |
806 | .B MS_ASYNC | |
807 | flag, if one occurs. | |
808 | .\" | |
f1461fe1 MK |
809 | .SS Huge page (Huge TLB) mappings |
810 | For mappings that employ huge pages, the requirements for the arguments of | |
811 | .BR mmap () | |
812 | and | |
813 | .BR munmap () | |
814 | differ somewhat from the requirements for mappings | |
815 | that use the native system page size. | |
efeece04 | 816 | .PP |
f1461fe1 MK |
817 | For |
818 | .BR mmap (), | |
819 | .I offset | |
820 | must be a multiple of the underlying huge page size. | |
821 | The system automatically aligns | |
822 | .I length | |
823 | to be a multiple of the underlying huge page size. | |
efeece04 | 824 | .PP |
f1461fe1 MK |
825 | For |
826 | .BR munmap (), | |
827 | .I addr | |
828 | and | |
829 | .I length | |
830 | must both be a multiple of the underlying huge page size. | |
831 | .\" | |
0722a578 | 832 | .SS C library/kernel differences |
35c189fb MK |
833 | This page describes the interface provided by the glibc |
834 | .BR mmap () | |
835 | wrapper function. | |
836 | Originally, this function invoked a system call of the same name. | |
837 | Since kernel 2.4, that system call has been superseded by | |
838 | .BR mmap2 (2), | |
839 | and nowadays | |
840 | .\" Since around glibc 2.1/2.2, depending on the platform. | |
841 | the glibc | |
842 | .BR mmap () | |
843 | wrapper function invokes | |
844 | .BR mmap2 (2) | |
845 | with a suitably adjusted value for | |
846 | .IR offset . | |
fea681da | 847 | .SH BUGS |
329ad271 | 848 | On Linux, there are no guarantees like those suggested above under |
c13182ef | 849 | .BR MAP_NORESERVE . |
dbc53ca8 | 850 | By default, any process can be killed |
fea681da | 851 | at any moment when the system runs out of memory. |
efeece04 | 852 | .PP |
dbc53ca8 MK |
853 | In kernels before 2.6.7, the |
854 | .B MAP_POPULATE | |
33a0ccb2 | 855 | flag has effect only if |
dbc53ca8 MK |
856 | .I prot |
857 | is specified as | |
858 | .BR PROT_NONE . | |
efeece04 | 859 | .PP |
c13182ef | 860 | SUSv3 specifies that |
c8f3e580 MK |
861 | .BR mmap () |
862 | should fail if | |
863 | .I length | |
864 | is 0. | |
865 | However, in kernels before 2.6.12, | |
866 | .BR mmap () | |
867 | succeeded in this case: no mapping was created and the call returned | |
14f5ae6d | 868 | .IR addr . |
c8f3e580 MK |
869 | Since kernel 2.6.12, |
870 | .BR mmap () | |
871 | fails with the error | |
872 | .B EINVAL | |
873 | for this case. | |
efeece04 | 874 | .PP |
a780f17b MK |
875 | POSIX specifies that the system shall always |
876 | zero fill any partial page at the end | |
b072a788 | 877 | of the object and that system will never write any modification of the |
a780f17b MK |
878 | object beyond its end. |
879 | On Linux, when you write data to such partial page after the end | |
b072a788 | 880 | of the object, the data stays in the page cache even after the file |
a780f17b MK |
881 | is closed and unmapped |
882 | and even though the data is never written to the file itself, | |
883 | subsequent mappings may see the modified content. | |
884 | In some cases, this could be fixed by calling | |
885 | .BR msync (2) | |
886 | before the unmap takes place; | |
4e07c70f MK |
887 | however, this doesn't work on |
888 | .BR tmpfs (5) | |
b758a50a | 889 | (for example, when using the POSIX shared memory interface documented in |
a780f17b | 890 | .BR shm_overview (7)). |
74fa61b7 | 891 | .SH EXAMPLE |
2e001ad4 MK |
892 | .\" FIXME . Add an example here that uses an anonymous shared region for |
893 | .\" IPC between parent and child. | |
74fa61b7 MK |
894 | .PP |
895 | The following program prints part of the file specified in | |
896 | its first command-line argument to standard output. | |
897 | The range of bytes to be printed is specified via offset and length | |
898 | values in the second and third command-line arguments. | |
899 | The program creates a memory mapping of the required | |
900 | pages of the file and then uses | |
901 | .BR write (2) | |
902 | to output the desired bytes. | |
f30b7415 | 903 | .SS Program source |
e7d0bb47 | 904 | .EX |
74fa61b7 MK |
905 | #include <sys/mman.h> |
906 | #include <sys/stat.h> | |
907 | #include <fcntl.h> | |
908 | #include <stdio.h> | |
909 | #include <stdlib.h> | |
910 | #include <unistd.h> | |
911 | ||
4407d3d8 MK |
912 | #define handle_error(msg) \\ |
913 | do { perror(msg); exit(EXIT_FAILURE); } while (0) | |
914 | ||
74fa61b7 MK |
915 | int |
916 | main(int argc, char *argv[]) | |
917 | { | |
918 | char *addr; | |
919 | int fd; | |
920 | struct stat sb; | |
921 | off_t offset, pa_offset; | |
922 | size_t length; | |
923 | ssize_t s; | |
924 | ||
fbbfa7ce | 925 | if (argc < 3 || argc > 4) { |
74fa61b7 MK |
926 | fprintf(stderr, "%s file offset [length]\\n", argv[0]); |
927 | exit(EXIT_FAILURE); | |
928 | } | |
929 | ||
930 | fd = open(argv[1], O_RDONLY); | |
4407d3d8 | 931 | if (fd == \-1) |
8568021d | 932 | handle_error("open"); |
74fa61b7 | 933 | |
4407d3d8 MK |
934 | if (fstat(fd, &sb) == \-1) /* To obtain file size */ |
935 | handle_error("fstat"); | |
74fa61b7 MK |
936 | |
937 | offset = atoi(argv[2]); | |
938 | pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) \- 1); | |
939 | /* offset for mmap() must be page aligned */ | |
940 | ||
941 | if (offset >= sb.st_size) { | |
942 | fprintf(stderr, "offset is past end of file\\n"); | |
943 | exit(EXIT_FAILURE); | |
944 | } | |
945 | ||
946 | if (argc == 4) { | |
947 | length = atoi(argv[3]); | |
948 | if (offset + length > sb.st_size) | |
949 | length = sb.st_size \- offset; | |
f81fb444 | 950 | /* Can\(aqt display bytes past end of file */ |
5b6adad1 | 951 | |
74fa61b7 MK |
952 | } else { /* No length arg ==> display to end of file */ |
953 | length = sb.st_size \- offset; | |
954 | } | |
955 | ||
956 | addr = mmap(NULL, length + offset \- pa_offset, PROT_READ, | |
957 | MAP_PRIVATE, fd, pa_offset); | |
4407d3d8 MK |
958 | if (addr == MAP_FAILED) |
959 | handle_error("mmap"); | |
74fa61b7 MK |
960 | |
961 | s = write(STDOUT_FILENO, addr + offset \- pa_offset, length); | |
962 | if (s != length) { | |
963 | if (s == \-1) | |
4407d3d8 MK |
964 | handle_error("write"); |
965 | ||
966 | fprintf(stderr, "partial write"); | |
74fa61b7 MK |
967 | exit(EXIT_FAILURE); |
968 | } | |
969 | ||
40142309 MK |
970 | munmap(addr, length + offset \- pa_offset); |
971 | close(fd); | |
972 | ||
74fa61b7 | 973 | exit(EXIT_SUCCESS); |
c54ed37e | 974 | } |
e7d0bb47 | 975 | .EE |
47297adb | 976 | .SH SEE ALSO |
74f25490 | 977 | .BR ftruncate (2), |
fea681da | 978 | .BR getpagesize (2), |
c4d76cd9 | 979 | .BR memfd_create (2), |
f75c3a3b | 980 | .BR mincore (2), |
fea681da MK |
981 | .BR mlock (2), |
982 | .BR mmap2 (2), | |
54504ac3 | 983 | .BR mprotect (2), |
fea681da MK |
984 | .BR mremap (2), |
985 | .BR msync (2), | |
931e4e25 | 986 | .BR remap_file_pages (2), |
83cd3686 | 987 | .BR setrlimit (2), |
7921f13b | 988 | .BR shmat (2), |
13acca70 | 989 | .BR userfaultfd (2), |
f93af9c6 MK |
990 | .BR shm_open (3), |
991 | .BR shm_overview (7) | |
efeece04 | 992 | .PP |
0bf14b87 MK |
993 | The descriptions of the following files in |
994 | .BR proc (5): | |
995 | .IR /proc/[pid]/maps , | |
996 | .IR /proc/[pid]/map_files , | |
997 | and | |
998 | .IR /proc/[pid]/smaps . | |
efeece04 | 999 | .PP |
d2fdb1e3 | 1000 | B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128\(en129 and 389\(en391. |
fea681da MK |
1001 | .\" |
1002 | .\" Repeat after me: private read-only mappings are 100% equivalent to | |
1003 | .\" shared read-only mappings. No ifs, buts, or maybes. -- Linus |