sys_mmap2  [arch/i386/kernel/sys_i386.c]


Maps files or devices into memory. This system call can be used for dynamic memory allocation.

Arguments

eax 192
ebx Address where pages will be mapped. If ebx is non-zero, it is used as a hint to the system. (As a convenience to the system, the actual address of the region may differ from the address supplied.) If ebx is zero, an address will be selected by the system.
ecx Size of the mapped region.
edx Protection flags:
PROT_EXEC Pages may be executed.
PROT_READ Pages may be read.
PROT_WRITE Pages may be written.
esi Mode flags:
MAP_ANON Map anonymous memory not associated with any specific file. The file descriptor used for creating MAP_ANON regions is used only for naming, and may be specified as -1 if no name is associated with the region.
MAP_FILE Mapped from a regular file or character-special device memory. (This is the default mapping type, and need not be specified.)
MAP_FIXED Do not permit the system to select a different address than the one specified. If the specified address cannot be used, sys_mmap will fail. If MAP_FIXED is specified, ebx must be a multiple of the pagesize. Use of this option is discouraged.
MAP_HASSEMAPHORE Notify the kernel that the region may contain semaphores and that special handling may be necessary.
MAP_PRIVATE Modifications are private.
MAP_SHARED Modifications are shared.
edi File descriptor. See mode flags descriptions for more info.
ebp Offset (within the file) of the data to be mapped. It's ignored if MAP_ANON is specified.

Return values

If the system call succeeds the return value is a pointer to the mapped region.
If the system call fails the return value is one of the following errno values:

-EACCES The flag PROT_READ was specified as part of the edx and edi was not open for reading. The flags PROT_WRITE and MAP_SHARED were specified as part of the esi and edx parameters and edi was not open for writing.
-EBADF edi is not a valid open file descriptor.
-EINVAL MAP_FIXED was specified and the parameter was not page aligned. edi did not reference a regular or character special file.
-ENOMEM MAP_FIXED was specified and the ecx parameter wasn't available. MAP_ANON was specified and insufficient memory was available.

Remarks

To unmap pages sys_munmap should be used.

Compatibility

n/a