Copyright © tutorialspoint.com
#include <sys/mman.h> |
prot is a bitwise-or of the following values:
Tag | Description |
---|---|
PROT_NONE | The memory cannot be accessed at all. |
PROT_READ | The memory can be read. |
PROT_WRITE | The memory can be written to. |
PROT_EXEC | The memory can contain executing code. |
Tag | Description |
---|---|
EACCES | The memory cannot be given the specified access. This can happen, for example, if you mmap(2) a file to which you have read-only access, then ask mprotect() to mark it PROT_WRITE. |
EFAULT | The memory cannot be accessed. |
EINVAL | addr is not a valid pointer, or not a multiple of PAGESIZE. |
ENOMEM | Internal kernel structures could not be allocated. Or: addresses in the range [addr, addr+len] are invalid for the address space of the process, or specify one or more pages that are not mapped. |
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/mman.h> |
Whether PROT_EXEC has any effect different from PROT_READ is architecture and kernel version dependent.
Copyright © tutorialspoint.com