|
|
HP-UX Reference > Mmprotect(2)HP-UX 11i Version 2: December 2007 Update |
|
NAMEmprotect() — set or check protection of memory mapping DESCRIPTIONThe 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>:
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. If the address range does not correspond to one created by a successful call to mmap(), mprotect() returns an error. If the address range being modified corresponds to a mapped file that was mapped with MAP_SHARED, mprotect() grants write access permission only if the file descriptor used to map the file was opened for writing. If the address range corresponds to a mapped file that was mapped with the MAP_PRIVATE or the MAP_ANONYMOUS flag, mprotect() grants all requested access permissions. 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. For example, if an error occurs on some page at an addr2, then mprotect() may have modified the protections of all whole pages in the range [addr,addr2]. RETURN VALUEUpon successful completion, mprotect() returns 0. Otherwise, it returns -1 and sets errno to indicate the error. ERRORSThe mprotect() function will fail if:
|
|