Debian Codegraph @

upstream/debian-unstable/man2/mmap2.2

raw
1 .\" Copyright 2002, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH mmap2 2 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 mmap2 \- map files or devices into memory
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .nf
14 .BR "#include <sys/mman.h>" " /* Definition of " MAP_* " and " PROT_* " constants */"
15 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
16 .B #include <unistd.h>
17 .P
18 .BI "void *syscall(SYS_mmap2, unsigned long " addr ", unsigned long " length ,
19 .BI " unsigned long " prot ", unsigned long " flags ,
20 .BI " unsigned long " fd ", unsigned long " pgoffset );
21 .fi
22 .SH DESCRIPTION
23 This is probably not the system call that you are interested in;
24 instead, see
25 .BR mmap (2),
26 which describes the glibc wrapper function that invokes this system call.
27 .P
28 The
29 .BR mmap2 ()
30 system call provides the same interface as
31 .BR mmap (2),
32 except that the final argument specifies the offset into the
33 file in 4096-byte units (instead of bytes, as is done by
34 .BR mmap (2)).
35 This enables applications that use a 32-bit
36 .I off_t
37 to map large files (up to 2\[ha]44 bytes).
38 .SH RETURN VALUE
39 On success,
40 .BR mmap2 ()
41 returns a pointer to the mapped area.
42 On error, \-1 is returned and
43 .I errno
44 is set to indicate the error.
45 .SH ERRORS
46 .TP
47 .B EFAULT
48 Problem with getting the data from user space.
49 .TP
50 .B EINVAL
51 (Various platforms where the page size is not 4096 bytes.)
52 .I "offset\ *\ 4096"
53 is not a multiple of the system page size.
54 .P
55 .BR mmap2 ()
56 can also return any of the errors described in
57 .BR mmap (2).
58 .SH VERSIONS
59 On architectures where this system call is present,
60 the glibc
61 .BR mmap ()
62 wrapper function invokes this system call rather than the
63 .BR mmap (2)
64 system call.
65 .P
66 This system call does not exist on x86-64.
67 .P
68 On ia64, the unit for
69 .I offset
70 is actually the system page size, rather than 4096 bytes.
71 .\" ia64 can have page sizes ranging from 4 kB to 64 kB.
72 .\" On cris, it looks like the unit might also be the page size,
73 .\" which is 8192 bytes. -- mtk, June 2007
74 .SH STANDARDS
75 Linux.
76 .SH HISTORY
77 Linux 2.3.31.
78 .SH SEE ALSO
79 .BR getpagesize (2),
80 .BR mmap (2),
81 .BR mremap (2),
82 .BR msync (2),
83 .BR shm_open (3)