mmap.2 (108028) | mmap.2 (108087) |
---|---|
1.\" Copyright (c) 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 16 unchanged lines hidden (view full) --- 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 | 1.\" Copyright (c) 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 16 unchanged lines hidden (view full) --- 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 |
33.\" $FreeBSD: head/lib/libc/sys/mmap.2 108028 2002-12-18 09:22:32Z ru $ | 33.\" $FreeBSD: head/lib/libc/sys/mmap.2 108087 2002-12-19 09:40:28Z ru $ |
34.\" 35.Dd November 17, 2001 36.Dt MMAP 2 37.Os 38.Sh NAME 39.Nm mmap 40.Nd allocate memory, or map files or devices into memory 41.Sh LIBRARY --- 46 unchanged lines hidden (view full) --- 88.It Dv PROT_WRITE 89Pages may be written. 90.It Dv PROT_EXEC 91Pages may be executed. 92.El 93.Pp 94The 95.Fa flags | 34.\" 35.Dd November 17, 2001 36.Dt MMAP 2 37.Os 38.Sh NAME 39.Nm mmap 40.Nd allocate memory, or map files or devices into memory 41.Sh LIBRARY --- 46 unchanged lines hidden (view full) --- 88.It Dv PROT_WRITE 89Pages may be written. 90.It Dv PROT_EXEC 91Pages may be executed. 92.El 93.Pp 94The 95.Fa flags |
96parameter specifies the type of the mapped object, mapping options and | 96argument specifies the type of the mapped object, mapping options and |
97whether modifications made to the mapped copy of the page are private 98to the process or are to be shared with other references. 99Sharing, mapping type and options are specified in the 100.Fa flags 101argument by 102.Em or Ns 'ing 103the following values: 104.Bl -tag -width MAP_HASSEMAPHORE 105.It Dv MAP_ANON 106Map anonymous memory not associated with any specific file. 107The file descriptor used for creating 108.Dv MAP_ANON 109must be \-1. 110The 111.Fa offset | 97whether modifications made to the mapped copy of the page are private 98to the process or are to be shared with other references. 99Sharing, mapping type and options are specified in the 100.Fa flags 101argument by 102.Em or Ns 'ing 103the following values: 104.Bl -tag -width MAP_HASSEMAPHORE 105.It Dv MAP_ANON 106Map anonymous memory not associated with any specific file. 107The file descriptor used for creating 108.Dv MAP_ANON 109must be \-1. 110The 111.Fa offset |
112parameter is ignored. | 112argument is ignored. |
113.\".It Dv MAP_FILE 114.\"Mapped from a regular file or character-special device memory. 115.It Dv MAP_FIXED 116Do not permit the system to select a different address than the one 117specified. 118If the specified address cannot be used, 119.Fn mmap 120will fail. --- 86 unchanged lines hidden (view full) --- 207Modifications are shared. 208.It Dv MAP_STACK 209.Dv MAP_STACK 210implies 211.Dv MAP_ANON , 212and 213.Fa offset 214of 0. | 113.\".It Dv MAP_FILE 114.\"Mapped from a regular file or character-special device memory. 115.It Dv MAP_FIXED 116Do not permit the system to select a different address than the one 117specified. 118If the specified address cannot be used, 119.Fn mmap 120will fail. --- 86 unchanged lines hidden (view full) --- 207Modifications are shared. 208.It Dv MAP_STACK 209.Dv MAP_STACK 210implies 211.Dv MAP_ANON , 212and 213.Fa offset 214of 0. |
215The |
|
215.Fa fd | 216.Fa fd |
217argument |
|
216must be -1 and 217.Fa prot 218must include at least 219.Dv PROT_READ 220and 221.Dv PROT_WRITE . 222This option creates 223a memory region that grows to at most --- 35 unchanged lines hidden (view full) --- 259system call 260will fail if: 261.Bl -tag -width Er 262.It Bq Er EACCES 263The flag 264.Dv PROT_READ 265was specified as part of the 266.Fa prot | 218must be -1 and 219.Fa prot 220must include at least 221.Dv PROT_READ 222and 223.Dv PROT_WRITE . 224This option creates 225a memory region that grows to at most --- 35 unchanged lines hidden (view full) --- 261system call 262will fail if: 263.Bl -tag -width Er 264.It Bq Er EACCES 265The flag 266.Dv PROT_READ 267was specified as part of the 268.Fa prot |
267parameter and | 269argument and |
268.Fa fd 269was not open for reading. 270The flags 271.Dv MAP_SHARED 272and 273.Dv PROT_WRITE 274were specified as part of the 275.Fa flags 276and 277.Fa prot | 270.Fa fd 271was not open for reading. 272The flags 273.Dv MAP_SHARED 274and 275.Dv PROT_WRITE 276were specified as part of the 277.Fa flags 278and 279.Fa prot |
278parameters and | 280argument and |
279.Fa fd 280was not open for writing. 281.It Bq Er EBADF | 281.Fa fd 282was not open for writing. 283.It Bq Er EBADF |
284The |
|
282.Fa fd | 285.Fa fd |
286argument |
|
283is not a valid open file descriptor. 284.It Bq Er EINVAL 285.Dv MAP_FIXED 286was specified and the 287.Fa addr | 287is not a valid open file descriptor. 288.It Bq Er EINVAL 289.Dv MAP_FIXED 290was specified and the 291.Fa addr |
288parameter was not page aligned, or part of the desired address space | 292argument was not page aligned, or part of the desired address space |
289resides out of the valid address space for a user process. 290.It Bq Er EINVAL | 293resides out of the valid address space for a user process. 294.It Bq Er EINVAL |
291.Fa Len | 295The 296.Fa len 297argument |
292was negative. 293.It Bq Er EINVAL 294.Dv MAP_ANON 295was specified and the 296.Fa fd | 298was negative. 299.It Bq Er EINVAL 300.Dv MAP_ANON 301was specified and the 302.Fa fd |
297parameter was not -1. | 303argument was not -1. |
298.It Bq Er EINVAL 299.Dv MAP_ANON 300has not been specified and 301.Fa fd 302did not reference a regular or character special file. 303.It Bq Er EINVAL | 304.It Bq Er EINVAL 305.Dv MAP_ANON 306has not been specified and 307.Fa fd 308did not reference a regular or character special file. 309.It Bq Er EINVAL |
304.Fa Offset | 310The 311.Fa offset 312argument |
305was not page-aligned. 306(See 307.Sx BUGS 308below.) 309.It Bq Er ENOMEM 310.Dv MAP_FIXED 311was specified and the 312.Fa addr | 313was not page-aligned. 314(See 315.Sx BUGS 316below.) 317.It Bq Er ENOMEM 318.Dv MAP_FIXED 319was specified and the 320.Fa addr |
313parameter was not available. | 321argument was not available. |
314.Dv MAP_ANON 315was specified and insufficient memory was available. 316The system has reached the per-process mmap limit specified in the 317.Va vm.max_proc_mmap 318sysctl. 319.El 320.Sh SEE ALSO 321.Xr madvise 2 , 322.Xr mincore 2 , 323.Xr minherit 2 , 324.Xr mlock 2 , 325.Xr mprotect 2 , 326.Xr msync 2 , 327.Xr munlock 2 , 328.Xr munmap 2 , 329.Xr getpagesize 3 , 330.Xr make.conf 5 331.Sh BUGS | 322.Dv MAP_ANON 323was specified and insufficient memory was available. 324The system has reached the per-process mmap limit specified in the 325.Va vm.max_proc_mmap 326sysctl. 327.El 328.Sh SEE ALSO 329.Xr madvise 2 , 330.Xr mincore 2 , 331.Xr minherit 2 , 332.Xr mlock 2 , 333.Xr mprotect 2 , 334.Xr msync 2 , 335.Xr munlock 2 , 336.Xr munmap 2 , 337.Xr getpagesize 3 , 338.Xr make.conf 5 339.Sh BUGS |
340The |
|
332.Fa len | 341.Fa len |
342argument |
|
333is limited to 2GB. 334Mmapping slightly more than 2GB does not work, but 335it is possible to map a window of size (filesize % 2GB) for file sizes 336of slightly less than 2G, 4GB, 6GB and 8GB. 337.Pp 338The limit is imposed for a variety of reasons. 339Most of them have to do 340with --- 15 unchanged lines hidden --- | 343is limited to 2GB. 344Mmapping slightly more than 2GB does not work, but 345it is possible to map a window of size (filesize % 2GB) for file sizes 346of slightly less than 2G, 4GB, 6GB and 8GB. 347.Pp 348The limit is imposed for a variety of reasons. 349Most of them have to do 350with --- 15 unchanged lines hidden --- |