On most platforms the unit for 'offset' is 4096 bytes, not the system page size.

Rewrote NOTES to note that glibc mmap() wrapper nowadays
invokes this system call.
This commit is contained in:
Michael Kerrisk 2007-06-29 16:36:27 +00:00
parent 5636a29a5e
commit 257f138a5c
1 changed files with 26 additions and 18 deletions

View File

@ -26,7 +26,7 @@
.\" Added description of mmap2
.\" Modified, 2004-11-25, mtk -- removed stray #endif in prototype
.\"
.TH MMAP2 2 2007-06-01 "Linux" "Linux Programmer's Manual"
.TH MMAP2 2 2007-07-08 "Linux" "Linux Programmer's Manual"
.SH NAME
mmap2 \- map files or devices into memory
.SH SYNOPSIS
@ -42,38 +42,46 @@ The
system call operates in exactly the same way as
.BR mmap (2),
except that the final argument specifies the offset into the
file in units of the system page size (instead of bytes).
file in 4096-byte units (instead of bytes, as is done by
.BR mmap (2)).
This enables applications that use a 32-bit
.I off_t
to map
larger files (typically up to 2^44 bytes).
to map large files (up to 2^44 bytes).
.SH "RETURN VALUE"
On success,
.BR mmap2 ()
returns a pointer to the mapped area.
On error \-1 is returned
and
On error \-1 is returned and
.I errno
is set appropriately.
.SH ERRORS
.TP
.B EFAULT
Problem with getting the
data from userspace.
Problem with getting the data from userspace.
.TP
.B EINVAL
(Various platforms where the page size is not 4096 bytes.)
.I offset * 4096
is not a multiple of the system page size.
.PP
.BR mmap2 ()
can return any of the same errors as
.BR mmap (2).
.SH VERSIONS
.BR mmap2 ()
is available since Linux 2.3.31.
.SH "CONFORMING TO"
This system call is Linux specific.
.SH NOTES
Glibc does not provide a wrapper for this system call; call it using
.BR syscall (2).
Nowadays, the glibc
.BR mmap ()
wrapper function invokes this system call rather than the
.BR mmap (2)
system call.
.BR mmap2 ()
is available since Linux 2.3.31.
It is Linux specific, and should be avoided in portable applications.
On 32-bit systems,
.BR mmap2 ()
is used to implement the
.BR mmap64 ()
function that is part of the LFS (Large File Summit).
On ia64, the unit for
.I offset
is actually the system page size, rather than 4096 bytes.
.SH "SEE ALSO"
.BR getpagesize (2),
.BR mmap (2),