On success, a call to mmap() returns the location of the mapping. On failure, the call returns MAP_FAILED, and setserrnoappropriately. A call tommap()never returns0.
Possibleerrnovalues include:
EACCESS The given file descriptor is not a regular file, or the mode with which it was opened conflicts withprot orflags.
EAGAIN The file has been locked via a file lock.
EBADF The given file descriptor is not valid.
EINVAL One or more of the parametersaddr,len, oroff are invalid.
ENFILE The system-wide limit on open files has been reached.
ENODEV The filesystem on which the file to map resides does not support memory mapping.
ENOMEM The process does not have enough memory.
EOVERFLOW The result ofaddr+lenexceeds the size of the address space.
EPERM PROT_EXECwas given, but the filesystem is mounted noexec.