share/mk/: build-html: Don't build mbind.2 and set_mempolicy.2
[man-pages.git] / man2 / mmap2.2
blob594a207ec1789d6125c9e8da92f2e819a4862e8d
1 .\" Copyright (C) 2002, Michael Kerrisk
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
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
8 .\"
9 .TH mmap2 2 (date) "Linux man-pages (unreleased)"
10 .SH NAME
11 mmap2 \- map files or devices into memory
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
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 );
24 .fi
25 .SH DESCRIPTION
26 This is probably not the system call that you are interested in; instead, see
27 .BR mmap (2),
28 which describes the glibc wrapper function that invokes this system call.
30 The
31 .BR mmap2 ()
32 system call provides the same interface as
33 .BR mmap (2),
34 except that the final argument specifies the offset into the
35 file in 4096-byte units (instead of bytes, as is done by
36 .BR mmap (2)).
37 This enables applications that use a 32-bit
38 .I off_t
39 to map large files (up to 2\[ha]44 bytes).
40 .SH RETURN VALUE
41 On success,
42 .BR mmap2 ()
43 returns a pointer to the mapped area.
44 On error, \-1 is returned and
45 .I errno
46 is set to indicate the error.
47 .SH ERRORS
48 .TP
49 .B EFAULT
50 Problem with getting the data from user space.
51 .TP
52 .B EINVAL
53 (Various platforms where the page size is not 4096 bytes.)
54 .I "offset\ *\ 4096"
55 is not a multiple of the system page size.
57 .BR mmap2 ()
58 can also return any of the errors described in
59 .BR mmap (2).
60 .SH VERSIONS
61 On architectures where this system call is present,
62 the glibc
63 .BR mmap ()
64 wrapper function invokes this system call rather than the
65 .BR mmap (2)
66 system call.
68 This system call does not exist on x86-64.
70 On ia64, the unit for
71 .I offset
72 is actually the system page size, rather than 4096 bytes.
73 .\" ia64 can have page sizes ranging from 4 kB to 64 kB.
74 .\" On cris, it looks like the unit might also be the page size,
75 .\" which is 8192 bytes. -- mtk, June 2007
76 .SH STANDARDS
77 Linux.
78 .SH HISTORY
79 Linux 2.3.31.
80 .SH SEE ALSO
81 .BR getpagesize (2),
82 .BR mmap (2),
83 .BR mremap (2),
84 .BR msync (2),
85 .BR shm_open (3)