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