HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)

m
mmap(2) mmap(2)
flag. The advisory locks of the
lockf() or fcntl() interfaces have no effect on memory mapped
access, but they can be used to coordinate shared access to a
MAP_SHARED mapped file region.
For a memory mapped file, the st_atime and st_mtime values returned by
stat() are updated when a
page in the memory mapped region is read from or written to the file system.
After a call to
fork(), the child process inherits all mapped regions with the same data and the same
sharing and protection attributes as in the parent process. Each mapped file and anonymous memory
region created with mmap() is unmapped upon process exit, and by a successful call to any of the
exec
functions.
MAP_NORESERVE
attribute is inherited across a fork() call; at the time of the
fork(), swap space for
a mapping is reserved in the child only for dirtied private pages that currently exist in the parent;
thereafter the child’s mapping reservation policy is as described above.
A
SIGBUS signal is delivered to a process when a write reference to a mapped file region would cause a
file system error condition such as exceeding quota or file system space limits.
A SIGBUS signal is delivered to a process upon a write reference to a region without
PROT_WRITE pro-
tection, or any reference to a region with
PROT_NONE protection.
A call to
mmap() with PROT_EXECUTE specified, but without PROT_WRITE specified for a
MAP_SHARED|MAP_FILE
mapping is treated by the system as the execution of the underlying file. This
implies that such a call fails if the file is currently open for writing or mapped with
MAP_SHARED|PROT_WRITE
options by any process, and that if the call succeeds, the file cannot be
opened for writing or subsequently mapped with
MAP_SHARED|PROT_WRITE
options as long as such
mappings are present. A file’s status as an active executable file is determined only at the time of an
exec(), exit(),ormmap() operation. mprotect() operations on a MAP_FILE|MAP_SHARED
mapping have no effect on the underlying file’s status as an active executable file.
Specifying MAP_GLOBAL in a call to mmap() forces the allocation to happen from the global quadrant as
compared to the private quadrants. See setmemwindow(1M) for further details.
ERRORS
[EACCES] The file referred to by fildes is not open for read access, or the file is not open for write
access and PROT_WRITE was set for a MAP_SHARED mapping operation, or
PROT_EXECUTE was set for a MAP_SHARED mapping operation and the underlying
file does not have execute permission.
[EBUSY] MAP_IO was set but the range of I/O memory is unavailable.
[EINVAL] The value of off+len exceeds the maximum supported offset for mapped files,
MAP_IO
was set but was not the only flag set, MAP_IO was set but addr was not NULL, or
MAP_IO was set but off+len is not a range of I/O memory.
[ENXIO] MAP_IO was set and the calling process was 32-bit but no 32-bit address within the
range 0xf1000000 to 0xffffffff (32-bit I/O space) was available.
[EOVERFLOW] The file is a regular file and the value of off+len exceeds the offset maximum established
in the open file description associated with fildes.
[EPERM]
MAP_IO was set but the calling process does not have superuser privilege and is not a
Real Time process.
[ETXTBSY] MAP_SHARED and MAP_FILE are set, and PROT_EXECUTE is set and
PROT_WRITE is not set, and the file being mapped is currently open for writing.
WARNING
Incorrect or inappropriate accesses to I/O devices can result in a system crash. Please use caution when
creating and using I/O ranges created using mmap().
DEPENDENCIES
Series 700/800
Because the PA-RISC memory architecture utilizes a globally shared virtual address space between
processes and discourages multiple virtual address translations to the same physical address, all con-
currently existing MAP_SHARED mappings of a file range must share the same virtual address offsets and
hardware translations.
Section 2158 Hewlett-Packard Company 3 HP-UX 11i Version 1: September 2005