1MMAP2(2)                   Linux Programmer's Manual                  MMAP2(2)
2
3
4

NAME

6       mmap2 - map files or devices into memory
7

SYNOPSIS

9       #include <sys/mman.h>    /* Definition of MAP_* and PROT_* constants */
10       #include <sys/syscall.h> /* Definition of SYS_* constants */
11       #include <unistd.h>
12
13       void *syscall(SYS_mmap2, unsigned long addr, unsigned long length,
14                     unsigned long prot, unsigned long flags,
15                     unsigned long fd, unsigned long pgoffset);
16

DESCRIPTION

18       This  is  probably  not the system call that you are interested in; in‐
19       stead, see mmap(2), which describes the glibc wrapper function that in‐
20       vokes this system call.
21
22       The  mmap2() system call provides the same interface as mmap(2), except
23       that the final argument specifies the offset into the file in 4096-byte
24       units (instead of bytes, as is done by mmap(2)).  This enables applica‐
25       tions that use a 32-bit off_t to map large files (up to 2^44 bytes).
26

RETURN VALUE

28       On success, mmap2() returns a pointer to the mapped area.  On error, -1
29       is returned and errno is set to indicate the error.
30

ERRORS

32       EFAULT Problem with getting the data from user space.
33
34       EINVAL (Various platforms where the page size is not 4096 bytes.)  off‐
35              set * 4096 is not a multiple of the system page size.
36
37       mmap2() can also return any of the errors described in mmap(2).
38

VERSIONS

40       mmap2() is available since Linux 2.3.31.
41

CONFORMING TO

43       This system call is Linux-specific.
44

NOTES

46       On architectures where this system call is present,  the  glibc  mmap()
47       wrapper  function invokes this system call rather than the mmap(2) sys‐
48       tem call.
49
50       This system call does not exist on x86-64.
51
52       On ia64, the unit for offset is actually the system page  size,  rather
53       than 4096 bytes.
54

SEE ALSO

56       getpagesize(2), mmap(2), mremap(2), msync(2), shm_open(3)
57

COLOPHON

59       This  page  is  part of release 5.13 of the Linux man-pages project.  A
60       description of the project, information about reporting bugs,  and  the
61       latest     version     of     this    page,    can    be    found    at
62       https://www.kernel.org/doc/man-pages/.
63
64
65
66Linux                             2021-03-22                          MMAP2(2)
Impressum