MMAP(2) — NEWS-OS Programmer’s Manual
NAME
mmap − mapping pages of a 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 system-call is not implemented completely in NEWS-OS 4.x. mmap maps len bytes of a memory from the first position of the memory device reffered by fd adding off, into the address space beginning at addr. share specifies if the mapped pages can be shared with others. prot specifies the protection for read/write of the mapped pages. addr, len, and the sum of the current position of fd and off must be multiples of a page size. The page size can be obtained from getpagesize(2). All of the mapped pages is unmapped automatically by using close. When the area more than 128KB is mapped, the kernel release the swap area given to it. And when the mapped area is unmapped, this area become invalid. Therefore, do not free when mapping area is obtained using by valloc, or malloc .
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned.
ERRORS
[EINVAL] The address or the length is not multiples of the page size obtained by getpagesize(2), or the length is a negative.
[EINVAL] The specified area is not found on the data area.
[EINVAL] The file specified by fd is not the character device which supports a mapping.
[EINVAL] The file specified by fd is not open for reading in spite of the request to access, or is not open for writing in spite of the request to write.
[EINVAL] The sharing mode is not set as MAP_SHARED.
[ENODEV] The device does not support mmap.
SEE ALSO
getpagesize(2), munmap(2), close(2)
BUGS
If invalid mmap which has incorrect length is called after the area more than 128KB is munmapped, the system may panic and will be down.
NEWS-OSRelease 4.2.1R