diff options
| author | Michael Kerrisk <mtk.manpages@gmail.com> | 2004-12-08 13:47:41 +0000 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2004-12-08 13:47:41 +0000 |
| commit | 1a956089b028b19528a3b133fe797e071ad0365a (patch) | |
| tree | 945ae20b5bbdd31689286f1a20927e1ca1fb8b85 | |
| parent | e263839c06db50f1e5e972eeef1189c556baa380 (diff) | |
| download | man-pages-1a956089b028b19528a3b133fe797e071ad0365a.tar.gz | |
Eric Estievenart <eric.estievenart@free.fr>
Note that MAP_FIXED replaces existing mappings
| -rw-r--r-- | man2/mmap.2 | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/man2/mmap.2 b/man2/mmap.2 index af1aa8ae05..485da90b5f 100644 --- a/man2/mmap.2 +++ b/man2/mmap.2 @@ -30,8 +30,10 @@ .\" MAP_LOCKED works from 2.5.37 .\" Modified 2004-06-17 by Michael Kerrisk <mtk-manpages@gmx.net> .\" Modified 2004-09-11 by aeb +.\" Modified 2004-12-08, from Eric Estievenart <eric.estievenart@free.fr> +.\" Modified 2004-12-08, mtk, formatting tidy-ups .\" -.TH MMAP 2 2004-09-11 "Linux 2.6.7" "Linux Programmer's Manual" +.TH MMAP 2 2004-12-08 "Linux 2.6.9" "Linux Programmer's Manual" .SH NAME mmap, munmap \- map or unmap files or devices into memory .SH SYNOPSIS @@ -43,7 +45,7 @@ mmap, munmap \- map or unmap files or devices into memory .BI "int munmap(void *" start ", size_t " length ); .SH DESCRIPTION The -.B mmap +.BR mmap () function asks to map .I length bytes starting at offset @@ -54,7 +56,7 @@ into memory, preferably at address .IR start . This latter address is a hint only, and is usually specified as 0. The actual place where the object is mapped is returned by -.BR mmap , +.BR mmap (), and is never 0. .LP The @@ -84,9 +86,16 @@ the process or are to be shared with other references. It has bits .TP 1.1i .B MAP_FIXED Do not select a different address than the one specified. +If the memory region specified by +.B start +and +.B len +overlaps pages of any existing mapping(s), then the overlapped +part of the existing mapping(s) will be discarded. If the specified address cannot be used, -.B mmap -will fail. If MAP_FIXED is specified, +.BR mmap () +will fail. +If MAP_FIXED is specified, .I start must be a multiple of the pagesize. Use of this option is discouraged. .TP @@ -103,7 +112,7 @@ are called. Create a private copy-on-write mapping. Stores to the region do not affect the original file. It is unspecified whether changes made to the file after the -.B mmap +.BR mmap () call are visible in the mapped region. .LP You must specify exactly one of MAP_SHARED and MAP_PRIVATE. @@ -134,7 +143,7 @@ when no memory is available. .TP .BR MAP_LOCKED " (since Linux 2.5.37)" Lock the pages of the mapped region into memory in the manner of -.BR mlock() . +.BR mlock () . This flag is ignored in older kernels. .\" If set, the mapped pages will not be swapped out. .TP @@ -180,7 +189,7 @@ should be a multiple of the page size as returned by .BR getpagesize (2). .LP Memory mapped by -.B mmap +.BR mmap () is preserved across .BR fork (2), with the same attributes. @@ -192,7 +201,7 @@ changing the size of the underlying file of a mapping on the pages that correspond to added or removed regions of the file is unspecified. The -.B munmap +.BR munmap () system call deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory references. The region is also automatically unmapped @@ -209,7 +218,7 @@ indicated range does not contain any mapped pages. For file-backed mappings, the .B st_atime field for the mapped file may be updated at any time between the -.B mmap() +.BR mmap () and the corresponding unmapping; the first reference to a mapped page will update the field if it has not been already. .LP @@ -219,11 +228,11 @@ and .B st_mtime field for a file mapped with PROT_WRITE and MAP_SHARED will be updated after a write to the mapped region, and before a subsequent -.I msync() +.BR msync () with the MS_SYNC or MS_ASYNC flag, if one occurs. .SH "RETURN VALUE" On success, -.B mmap +.BR mmap () returns a pointer to the mapped area. On error, the value .B MAP_FAILED @@ -231,7 +240,7 @@ On error, the value .I errno is set appropriately. On success, -.B munmap +.BR munmap () returns 0, on failure \-1, and .I errno is set (probably to EINVAL). @@ -314,10 +323,10 @@ to the file (for example, beyond the end of the file, including the case where another process has truncated the file). .SH AVAILABILITY On POSIX systems on which -.BR mmap , -.B msync +.BR mmap (), +.BR msync () and -.B munmap +.BR munmap () are available, .B _POSIX_MAPPED_FILES is defined in <unistd.h> to a value greater than 0. (See also |
