SYNOPSIS
#include <sys/mman.h>
int mprotect(void *addr, size_t len, int prot);
DESCRIPTION
The
The system does not permit a write to succeed where PROT_WRITE has not been set or permit any access where PROT_NONE alone has been set. If PROT_WRITE is specified, the application must have opened the mapped objects in the specified address range with write permission, unless MAP_PRIVATE was specified in the original mapping. It is irrelevant whether the file descriptors used to map the objects have since been closed.
addr must be a multiple
of the page size as returned by
PARAMETERS
- addr
-
Is the starting address of the region for which the protection has to be changed.
- len
-
Is the length of the region, in bytes, whose protection has to be changed.
- prot
-
Is the desired protection of the memory mapped region.
RETURN VALUES
On success, the
- EACCES
-
The prot argument specifies a protection that violates the access permission the process has to the underlying memory object.
- 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.
- EINVAL
-
The addr argument is not a multiple of the page size as returned by
sysconf() . - EINVAL
-
The len argument is has a value less than 0.
- 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.
- ENOMEM
-
The prot argument specifies PROT_WRITE on a MAP_PRIVATE mapping, and it would require more space than the system is able to supply for locking the private pages, if required.
- ENOTSUP
-
The implementation does not support the combination of accesses requested in the prot argument.
CONFORMANCE
UNIX 98, with exceptions.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
Windows 9x does not support the PROT_EXEC flag, nor does it
support
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.