]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/mmap2.2
Ready for 5.00
[thirdparty/man-pages.git] / man2 / mmap2.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2002, Michael Kerrisk
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
c11b1abf 25.\" Modified 31 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 26.\" Added description of mmap2
3b851981 27.\" Modified, 2004-11-25, mtk -- removed stray #endif in prototype
fea681da 28.\"
4b8c67d9 29.TH MMAP2 2 2017-09-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31mmap2 \- map files or devices into memory
32.SH SYNOPSIS
cb2431bf 33.nf
fea681da 34.B #include <sys/mman.h>
68e4db0a 35.PP
14f5ae6d 36.BI "void *mmap2(void *" addr ", size_t " length ", int " prot ,
cb2431bf
MK
37.BI " int " flags ", int " fd ", off_t " pgoffset );
38.fi
fea681da 39.SH DESCRIPTION
e49b8d67 40This is probably not the system call that you are interested in; instead, see
02ddee60
MK
41.BR mmap (2),
42which describes the glibc wrapper function that invokes this system call.
efeece04 43.PP
c13182ef 44The
e511ffb6 45.BR mmap2 ()
02ddee60 46system call provides the same interface as
fea681da
MK
47.BR mmap (2),
48except that the final argument specifies the offset into the
257f138a
MK
49file in 4096-byte units (instead of bytes, as is done by
50.BR mmap (2)).
3b851981 51This enables applications that use a 32-bit
60603198 52.I off_t
257f138a 53to map large files (up to 2^44 bytes).
47297adb 54.SH RETURN VALUE
c13182ef 55On success,
e511ffb6 56.BR mmap2 ()
c13182ef 57returns a pointer to the mapped area.
dec985f9 58On error, \-1 is returned and
fea681da
MK
59.I errno
60is set appropriately.
61.SH ERRORS
62.TP
7f8aa9e3 63.B EFAULT
7fac88a9 64Problem with getting the data from user space.
257f138a
MK
65.TP
66.B EINVAL
67(Various platforms where the page size is not 4096 bytes.)
5049da5b 68.I "offset\ *\ 4096"
257f138a
MK
69is not a multiple of the system page size.
70.PP
71.BR mmap2 ()
02ddee60 72can also return any of the errors described in
257f138a
MK
73.BR mmap (2).
74.SH VERSIONS
75.BR mmap2 ()
76is available since Linux 2.3.31.
47297adb 77.SH CONFORMING TO
8382f16d 78This system call is Linux-specific.
fea681da 79.SH NOTES
f4e8dfa7
MK
80On architectures where this system call is present,
81the glibc
257f138a
MK
82.BR mmap ()
83wrapper function invokes this system call rather than the
84.BR mmap (2)
85system call.
efeece04 86.PP
bc9bb309 87This system call does not exist on x86-64.
efeece04 88.PP
257f138a
MK
89On ia64, the unit for
90.I offset
91is actually the system page size, rather than 4096 bytes.
ee8655b5 92.\" ia64 can have page sizes ranging from 4 kB to 64 kB.
88276dad
MK
93.\" On cris, it looks like the unit might also be the page size,
94.\" which is 8192 bytes. -- mtk, June 2007
47297adb 95.SH SEE ALSO
fea681da
MK
96.BR getpagesize (2),
97.BR mmap (2),
98.BR mremap (2),
99.BR msync (2),
424a8950 100.BR shm_open (3)