MMAP(2) — SYSTEM CALLS
NAME
mmap − map pages of memory
SYNOPSIS
#include <sys/mman.h>
#include <sys/types.h>
mmap(addr, len, prot, share, fd, off)
caddr_t addr; int len, prot, share, fd; off_t off;
DESCRIPTION
This call is not completely implemented in 4.2 BSD.
Mmap maps the pages starting at addr and continuing for len bytes from the object represented by the descriptor fd, at the current file position of offset off. The parameter share specifies whether modifications made to this mapped copy of the page are to be kept private or are to be shared with other references. The parameter prot specifies the accessibility of the mapped pages. The addr and len parameters and the sum of the current position in fd and the off parameters must be multiples of the page size (found using the getpagesize(2) call).
Pages are automatically unmapped at close.
When called to map an area of 128k or more, the kernel will RELEASE the swap area previously associated with the mapped area. When this area is unmapped (using munmap), pages within the area are marked invalid. When using valloc and malloc to allcoate such areas, do not free the area as you normally would. Instead, call valloc or malloc.
RETURN VALUE
The call returns 0 on success, −1 on failure.
ERRORS
The mmap call will fail if:
[EINVAL] The argument address or length is not a multiple of the page size as returned by getpagesize(2),or the length is negative.
[EINVAL] The entire range of pages specified in the call is not part of data space.
[EINVAL] The specified fd does not refer to a character special device which supports mapping (e.g. a frame buffer).
[EINVAL] The specified fd is not open for reading and read access is requested, or not open for writing when write access is requested.
[EINVAL] The sharing mode was not specified as MAP_SHARED.
SEE ALSO
getpagesize(2), munmap(2), close(2)
BUGS
The kernel may panic when more than 128k of memory has been unmapped with munmap and mmap is subsequently called with an incorrect length value.
Sun Release 3.0β — Last change: 20 August 1985