Go to the previous, next section.
caddr_t mmap(caddr_t addr, size_t len, int
prot, int flags, int fd, off_t
offset);
int munmap(caddr_t addr, size_t len);
addr: for mmap, [in] where to map the object. For
munmap, [in] the region to unmap.
len: [in] length of the mapped region.
prot: [in] protection for the mapping space.
flags: [in] see description.
fd: [in] the object to map.
offset: [in] begining of the part of the object to map.
Maps an file object in the virtual address space of the task. In the case
where offset or len are not multiple of a page size, the
mapping space may extend beyond the specified range. addr is only a
clue to the system as where to place the mapping region. The system may choose
to map the object elsewhere. A value of zero for addr tells the
system to map the object where it sees fit. A sucessfull mmap on a
previously mapped region cancel the previous mapping on that region. The
prot parameter may be one or more or'ed values among the following:
PROT_EXEC
PROT_READ
PROT_WRITE
The flags parameter my be one or more or'ed values among the
following:
MAP_ANON
MAP_FILE
MAP_FIXED
MAP_HASSEMAPHORE
MAP_INHERIT
exec
system call.
MAP_PRIVATE
MAP_SHARED
munmap unmaps the region.
On success mmap returns the address of the newly mapped region,
munmap returns zero. On error, those calls return -1 and sets
errno to one of the following:
EACCESS: the protection requested for the mapped region is
not consistent with the mode of fd.
EINVAL: the flags value is incorrect or
MAP_FIXED was requested but the address range is not a multiple
of a page size.
ENOMEM: MAP_FIXED was requested but the memory
range can not be used for mapping or there is insufficient memory to complete
the call.
ENODEV: the file descriptor cannot be mapped.
EBADF, EFAULT.