mirror of https://github.com/mkerrisk/man-pages
Rewrote various parts to be clearer.
This commit is contained in:
parent
b28f7a67d7
commit
5e8cde2f2e
55
man2/mmap.2
55
man2/mmap.2
|
@ -46,26 +46,43 @@ mmap, munmap \- map or unmap files or devices into memory
|
||||||
.BI "int munmap(void *" start ", size_t " length );
|
.BI "int munmap(void *" start ", size_t " length );
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
The
|
|
||||||
.BR mmap ()
|
.BR mmap ()
|
||||||
function asks to map
|
creates a new mapping in the virtual address space of
|
||||||
|
the calling process.
|
||||||
|
The starting address for the new mapping is specified in
|
||||||
|
.IR start .
|
||||||
|
The
|
||||||
|
.I length
|
||||||
|
argument specifies the length of the mapping.
|
||||||
|
|
||||||
|
If
|
||||||
|
.I start
|
||||||
|
is NULL,
|
||||||
|
then the kernel chooses the address at which to create the mapping;
|
||||||
|
this is the most portable method of creating a new mapping.
|
||||||
|
If
|
||||||
|
.I start
|
||||||
|
is not NULL,
|
||||||
|
then the kernel takes it as a hint about where to place the mapping;
|
||||||
|
on Linux, the mapping will be created at the next higher page boundary.
|
||||||
|
The address of the new mapping is returned as the result of the call.
|
||||||
|
|
||||||
|
The contents of a file mapping (as opposed to an anonymous mapping; see
|
||||||
|
.B MAP_ANONYMOUS
|
||||||
|
below), are initialised using
|
||||||
.I length
|
.I length
|
||||||
bytes starting at offset
|
bytes starting at offset
|
||||||
.I offset
|
.I offset
|
||||||
from the file (or other object) specified by the file descriptor
|
in the file (or other object) referred to by the file descriptor
|
||||||
.I fd
|
.IR fd .
|
||||||
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 ().
|
|
||||||
.LP
|
.LP
|
||||||
The
|
The
|
||||||
.I prot
|
.I prot
|
||||||
argument describes the desired memory protection (and must not
|
argument describes the desired memory protection of the mapping
|
||||||
conflict with the open mode of the file). It is either
|
(and must not conflict with the open mode of the file).
|
||||||
|
It is either
|
||||||
.B PROT_NONE
|
.B PROT_NONE
|
||||||
or is the bitwise OR of one or more of the other PROT_* flags.
|
or is the bitwise OR of one or more of the following flags:
|
||||||
.TP 1.1i
|
.TP 1.1i
|
||||||
.B PROT_EXEC
|
.B PROT_EXEC
|
||||||
Pages may be executed.
|
Pages may be executed.
|
||||||
|
@ -84,7 +101,8 @@ The
|
||||||
parameter specifies the type of the mapped object, mapping options and
|
parameter specifies the type of the mapped object, mapping options and
|
||||||
whether modifications made to the mapped copy of the page are private to
|
whether modifications made to the mapped copy of the page are private to
|
||||||
the process or are to be shared with other references.
|
the process or are to be shared with other references.
|
||||||
It has bits
|
The following values can be ORed in
|
||||||
|
.IR flags :
|
||||||
.TP 1.1i
|
.TP 1.1i
|
||||||
.B MAP_FIXED
|
.B MAP_FIXED
|
||||||
Do not select a different address than the one specified.
|
Do not select a different address than the one specified.
|
||||||
|
@ -127,6 +145,7 @@ and
|
||||||
.LP
|
.LP
|
||||||
The above three flags are described in POSIX.1-2001.
|
The above three flags are described in POSIX.1-2001.
|
||||||
Linux also knows about the following non-standard flags:
|
Linux also knows about the following non-standard flags:
|
||||||
|
.\" FIXME ? Place the following list in alphabetical order?
|
||||||
.TP
|
.TP
|
||||||
.B MAP_DENYWRITE
|
.B MAP_DENYWRITE
|
||||||
This flag is ignored.
|
This flag is ignored.
|
||||||
|
@ -168,7 +187,9 @@ Used for stacks. Indicates to the kernel VM system that the mapping
|
||||||
should extend downwards in memory.
|
should extend downwards in memory.
|
||||||
.TP
|
.TP
|
||||||
.B MAP_ANONYMOUS
|
.B MAP_ANONYMOUS
|
||||||
The mapping is not backed by any file; the
|
The mapping is not backed by any file;
|
||||||
|
its contents are initialised to zero.
|
||||||
|
The
|
||||||
.I fd
|
.I fd
|
||||||
and
|
and
|
||||||
.I offset
|
.I offset
|
||||||
|
@ -178,7 +199,7 @@ The use of this flag in conjunction with
|
||||||
is only supported on Linux since kernel 2.4.
|
is only supported on Linux since kernel 2.4.
|
||||||
.TP
|
.TP
|
||||||
.B MAP_ANON
|
.B MAP_ANON
|
||||||
Alias for
|
Synonym for
|
||||||
.BR MAP_ANONYMOUS .
|
.BR MAP_ANONYMOUS .
|
||||||
Deprecated.
|
Deprecated.
|
||||||
.TP
|
.TP
|
||||||
|
@ -285,7 +306,9 @@ On success,
|
||||||
returns a pointer to the mapped area.
|
returns a pointer to the mapped area.
|
||||||
On error, the value
|
On error, the value
|
||||||
.B MAP_FAILED
|
.B MAP_FAILED
|
||||||
(that is, (void *) \-1) is returned, and
|
(that is,
|
||||||
|
.I "(void *) \-1)"
|
||||||
|
is returned, and
|
||||||
.I errno
|
.I errno
|
||||||
is set appropriately.
|
is set appropriately.
|
||||||
On success,
|
On success,
|
||||||
|
|
Loading…
Reference in New Issue