MPROTECT(2) Domain/OS BSD MPROTECT(2)
NAME
mprotect - assign protection to region mapped in virtual memory
SYNOPSIS
#include <sys/mman.h>
mprotect(addr, len, prot)
caddr_t addr;
int len, prot;
DESCRIPTION
mprotect ignores len. It sets the protection for the entire region
mapped beginning at addr. <sys/mman.h> defines the possible settings for
prot:
/* protections are chosen from these bits, ORed together */
#define PROT_READ 0x04 /* pages can be read */
#define PROT_WRITE 0x02 /* pages can be written */
#define PROT_EXEC 0x01 /* pages can be executed */
NOTES
This implementation is based upon a proposal by McKusick and Karels, and
upon other sources. Its details may change in a future release.
SEE ALSO
McKusick, M.K. and Karels, M.J. A New Virtual Memory Implementation for
Berkeley UNIX. Berkeley, California: Department of Electrical
Engineering and Computer Science, University of California, 1986.
madvise(2), mmap(2), mset(2).
DIAGNOSTICS
A successful call returns 0. An unsuccessful call returns -1 and sets
errno as indicated below.
ERRORS
mprotect will fail if any of the following is true:
[EINVAL] An invalid protection mode was specified.
[ENOENT] No region is mapped at the specified address.
[EACCESS] Attempt to change the protection to a mode precluded by file
access proctections.
[ETXTBSY] The file is a pure-procedure (shared text) file that is being
executed and the protections request write access.
[EROFS] The mapped file resides on a read-only file system and the
protections request write access.