namespaces.7: ffix
[man-pages.git] / man2 / mmap2.2
blobd579a285d88b935d3b7d05e2d906c4bc1a3cb148
1 .\" Copyright (C) 2002, Michael Kerrisk
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified 31 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\"     Added description of mmap2
27 .\" Modified, 2004-11-25, mtk -- removed stray #endif in prototype
28 .\"
29 .TH MMAP2 2 2021-03-22 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 mmap2 \- map files or devices into memory
32 .SH SYNOPSIS
33 .nf
34 .BR "#include <sys/mman.h>" "    /* Definition of " MAP_* " and " PROT_* " constants */"
35 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
36 .BR "#include <unistd.h>
37 .PP
38 .BI "void *syscall(SYS_mmap2, unsigned long " addr ", unsigned long " length ,
39 .BI "              unsigned long " prot ", unsigned long " flags ,
40 .BI "              unsigned long " fd ", unsigned long " pgoffset );
41 .fi
42 .SH DESCRIPTION
43 This is probably not the system call that you are interested in; instead, see
44 .BR mmap (2),
45 which describes the glibc wrapper function that invokes this system call.
46 .PP
47 The
48 .BR mmap2 ()
49 system call provides the same interface as
50 .BR mmap (2),
51 except that the final argument specifies the offset into the
52 file in 4096-byte units (instead of bytes, as is done by
53 .BR mmap (2)).
54 This enables applications that use a 32-bit
55 .I off_t
56 to map large files (up to 2^44 bytes).
57 .SH RETURN VALUE
58 On success,
59 .BR mmap2 ()
60 returns a pointer to the mapped area.
61 On error, \-1 is returned and
62 .I errno
63 is set to indicate the error.
64 .SH ERRORS
65 .TP
66 .B EFAULT
67 Problem with getting the data from user space.
68 .TP
69 .B EINVAL
70 (Various platforms where the page size is not 4096 bytes.)
71 .I "offset\ *\ 4096"
72 is not a multiple of the system page size.
73 .PP
74 .BR mmap2 ()
75 can also return any of the errors described in
76 .BR mmap (2).
77 .SH VERSIONS
78 .BR mmap2 ()
79 is available since Linux 2.3.31.
80 .SH CONFORMING TO
81 This system call is Linux-specific.
82 .SH NOTES
83 On architectures where this system call is present,
84 the glibc
85 .BR mmap ()
86 wrapper function invokes this system call rather than the
87 .BR mmap (2)
88 system call.
89 .PP
90 This system call does not exist on x86-64.
91 .PP
92 On ia64, the unit for
93 .I offset
94 is actually the system page size, rather than 4096 bytes.
95 .\" ia64 can have page sizes ranging from 4 kB to 64 kB.
96 .\" On cris, it looks like the unit might also be the page size,
97 .\" which is 8192 bytes. -- mtk, June 2007
98 .SH SEE ALSO
99 .BR getpagesize (2),
100 .BR mmap (2),
101 .BR mremap (2),
102 .BR msync (2),
103 .BR shm_open (3)