.\" Copyright (c) 1991 Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)mmap.2 6.6 (Berkeley) %G%
.Nd map files or devices into memory
.Fd #include <sys/types.h>
.Fd #include <sys/mman.h>
.Fn mmap "caddr_t addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
function causes the pages starting at
and continuing for at most
bytes to be mapped from the object described by
is not a multiple of the pagesize, the mapped region may extend past the
is non-zero, it is used as a hint to the system.
(As a convenience to the system, the actual address of the region may differ
from the address supplied.)
is zero, an address will be selected by the system.
The actual starting address of the region is returned.
deletes any previous mapping in the allocated address range.
The protections (region accessibility) are specified in the
.Bl -tag -width MAP_FIXEDX
parameter specifies the type of the mapped object, mapping options and
whether modifications made to the mapped copy of the page are private
to the process or are to be shared with other references.
Sharing, mapping type and options are specified in the
.Bl -tag -width MAP_FIXEDX
Map anonymous memory not associated with any specific file.
The file descriptor used for creating
naming, and may be specified as \-1 if no name is associated with the
.\"Mapped from a regular file or character-special device memory.
Do not permit the system to select a different address than the one
If the specified address cannot be used,
If MAP_FIXED is specified,
must be a multiple of the pagesize.
Use of this option is discouraged.
Notify the kernel that the region may contain semaphores and that special
handling may be necessary.
Permit regions to be inherited across
Modifications are private.
Modifications are shared.
function does not unmap pages, see
The current design does not allow a process to specify the location of
In the future we may define an additional mapping type,
the file descriptor argument specifies a file or device to which swapping
Upon successful completion,
returns a pointer to the mapped region.
Otherwise, a value of -1 is returned and
is set to indicate the error.
was specified as part of the
was not open for reading.
was not open for writing.
is not a valid open file descriptor.
.\"was not specified as part of the
parameter was not page aligned.
did not reference a regular or character special file.
parameter wasn't available.
was specified and insufficient memory was available.