OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / mmap2.2
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 2014-02-25 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 mmap2 \- map files or devices into memory
32 .SH SYNOPSIS
33 .nf
34 .B #include <sys/mman.h>
35 .sp
36 .BI "void *mmap2(void *" addr ", size_t " length ", int " prot ,
37 .BI "             int " flags ", int " fd ", off_t " pgoffset );
38 .fi
39 .SH DESCRIPTION
40 This is probably not the system call that you are interested in; instead, see
41 .BR mmap (2),
42 which describes the glibc wrapper function that invokes this system call.
43
44 The
45 .BR mmap2 ()
46 system call provides the same interface as
47 .BR mmap (2),
48 except that the final argument specifies the offset into the
49 file in 4096-byte units (instead of bytes, as is done by
50 .BR mmap (2)).
51 This enables applications that use a 32-bit
52 .I off_t
53 to map large files (up to 2^44 bytes).
54 .SH RETURN VALUE
55 On success,
56 .BR mmap2 ()
57 returns a pointer to the mapped area.
58 On error, \-1 is returned and
59 .I errno
60 is set appropriately.
61 .SH ERRORS
62 .TP
63 .B EFAULT
64 Problem with getting the data from user space.
65 .TP
66 .B EINVAL
67 (Various platforms where the page size is not 4096 bytes.)
68 .I "offset\ *\ 4096"
69 is not a multiple of the system page size.
70 .PP
71 .BR mmap2 ()
72 can also return any of the errors described in
73 .BR mmap (2).
74 .SH VERSIONS
75 .BR mmap2 ()
76 is available since Linux 2.3.31.
77 .SH CONFORMING TO
78 This system call is Linux-specific.
79 .SH NOTES
80 On architectures where this system call is present,
81 the glibc
82 .BR mmap ()
83 wrapper function invokes this system call rather than the
84 .BR mmap (2)
85 system call.
86
87 This system call does not exist on x86-64.
88
89 On ia64, the unit for
90 .I offset
91 is actually the system page size, rather than 4096 bytes.
92 .\" ia64 can have page sizes ranging from 4kB to 64kB.
93 .\" On cris, it looks like the unit might also be the page size,
94 .\" which is 8192 bytes. -- mtk, June 2007
95 .SH SEE ALSO
96 .BR getpagesize (2),
97 .BR mmap (2),
98 .BR mremap (2),
99 .BR msync (2),
100 .BR shm_open (3)
101 .SH COLOPHON
102 This page is part of release 3.79 of the Linux
103 .I man-pages
104 project.
105 A description of the project,
106 information about reporting bugs,
107 and the latest version of this page,
108 can be found at
109 \%http://www.kernel.org/doc/man\-pages/.