1 .\" Copyright (C) 2002, Michael Kerrisk
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified 31 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Added description of mmap2
7 .\" Modified, 2004-11-25, mtk -- removed stray #endif in prototype
9 .TH MMAP2 2 2022-09-09 "Linux man-pages (unreleased)"
11 mmap2 \- map files or devices into memory
14 .RI ( libc ", " \-lc )
17 .BR "#include <sys/mman.h>" " /* Definition of " MAP_* " and " PROT_* " constants */"
18 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
19 .B #include <unistd.h>
21 .BI "void *syscall(SYS_mmap2, unsigned long " addr ", unsigned long " length ,
22 .BI " unsigned long " prot ", unsigned long " flags ,
23 .BI " unsigned long " fd ", unsigned long " pgoffset );
26 This is probably not the system call that you are interested in; instead, see
28 which describes the glibc wrapper function that invokes this system call.
32 system call provides the same interface as
34 except that the final argument specifies the offset into the
35 file in 4096-byte units (instead of bytes, as is done by
37 This enables applications that use a 32-bit
39 to map large files (up to 2^44 bytes).
43 returns a pointer to the mapped area.
44 On error, \-1 is returned and
46 is set to indicate the error.
50 Problem with getting the data from user space.
53 (Various platforms where the page size is not 4096 bytes.)
55 is not a multiple of the system page size.
58 can also return any of the errors described in
62 is available since Linux 2.3.31.
64 This system call is Linux-specific.
66 On architectures where this system call is present,
69 wrapper function invokes this system call rather than the
73 This system call does not exist on x86-64.
77 is actually the system page size, rather than 4096 bytes.
78 .\" ia64 can have page sizes ranging from 4 kB to 64 kB.
79 .\" On cris, it looks like the unit might also be the page size,
80 .\" which is 8192 bytes. -- mtk, June 2007