HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
m
mprotect(2) mprotect(2)
NAME
mprotect - set or check protection of memory mapping
SYNOPSIS
#include <sys/mman.h>
int mprotect(void *addr, size_t len, int prot);
DESCRIPTION
The mprotect() function changes the access protections on the mappings specified by the range [addr,
addr+len], rounding len up to the next multiple of the page size as returned by sysconf(), to be that
specified by prot. Legitimate values for prot are the same as those permitted for mmap() and are defined
in <sys/mman.h> :
PROT_READ Page can be read.
PROT_WRITE Page can be written.
PROT_EXEC Page can be executed.
PROT_NONE Page cannot be accessed.
PROT_CHECK Check page effective permissions
If PROT_CHECK flag is specified, mprotect() checks the access protections on the mappings specified
with the rest of prot value to see if the requested permissions are set.
When mprotect() fails for reasons other than EINVAL, the protections on some of the pages in the
range [addr, addr+len] may have been changed.
RETURN VALUE
Upon successful completion, mprotect() returns 0. Otherwise, it returns -1 and sets errno to indicate
the error.
ERRORS
The mprotect() function will fail if:
[EACCES] The prot argument specifies a protection that violates, or is different than (in the case
where flag PROT_CHECK is present), the access permission the process has to the
underlying memory object.
[EINVAL] The addr argument is not a multiple of the page size as returned by
sysconf().
[ENOMEM] Addresses in the range [addr, addr+len] are invalid for the address space of a process,
or specify one or more pages which are not mapped.
The
mprotect() function may fail if:
[EAGAIN] The prot argument specifies PROT_WRITE over a MAP_PRIVATE mapping and
there are insufficient memory resources to reserve for locking the private page.
SEE ALSO
mmap(2), sysconf(2), <sys/mman.h>.
CHANGE HISTORY
First released in Issue 4, Version 2.
Section 2−−170 − 1 − HP-UX Release 11i: December 2000
___
___