summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/mmap.2
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/sys/mmap.2')
-rw-r--r--lib/libc/sys/mmap.275
1 files changed, 51 insertions, 24 deletions
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index 7313134..17a3603 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -31,7 +31,7 @@
.\"
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\"
-.Dd "May 11, 1995"
+.Dd May 11, 1995
.Dt MMAP 2
.Os BSD 4
.Sh NAME
@@ -44,7 +44,7 @@
.Fn mmap "caddr_t addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
.Sh DESCRIPTION
The
-.Nm mmap
+.Fn mmap
function causes the pages starting at
.Fa addr
and continuing for at most
@@ -113,7 +113,7 @@ parameter is ignored.
Do not permit the system to select a different address than the one
specified.
If the specified address cannot be used,
-.Nm mmap
+.Fn mmap
will fail.
If MAP_FIXED is specified,
.Fa addr
@@ -124,7 +124,7 @@ Notify the kernel that the region may contain semaphores and that special
handling may be necessary.
.It Dv MAP_INHERIT
Permit regions to be inherited across
-.Xr exec 2
+.Xr execve 2
system calls.
.It Dv MAP_PRIVATE
Modifications are private.
@@ -147,9 +147,9 @@ the file descriptor argument specifies a file or device to which swapping
should be done.
.Sh RETURN VALUES
Upon successful completion,
-.Nm mmap
+.Fn mmap
returns a pointer to the mapped region.
-Otherwise, a value of -1 is returned and
+Otherwise, a value of MAP_FAILED is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
@@ -179,25 +179,27 @@ was not open for writing.
.Fa Fd
is not a valid open file descriptor.
.It Bq Er EINVAL
-.\"One of
-.\".Dv MAP_ANON
-.\"or
-.\".Dv MAP_FILE
-.\"was not specified as part of the
-.\".Fa flags
-.\"parameter.
.Dv MAP_FIXED
was specified and the
.Fa addr
-parameter was not page aligned or was outside of the
-valid address range for a process.
-.Dv MAP_ANON was specified and
+parameter was not page aligned, or part of the desired address space
+resides out of the valid address space for a user process.
+.It Bq Er EINVAL
+.Fa Len
+was negative.
+.It Bq Er EINVAL
+.Dv MAP_ANON
+was specified and the
+.Fa fd
+parameter was not -1.
+.It Bq Er EINVAL
+.Dv MAP_ANON
+has not been specified and
.Fa fd
-was not \-1.
-.Fa Fd
did not reference a regular or character special file.
-.Fa Len
-was less than zero.
+.It Bq Er EINVAL
+.Fa Offset
+was not page-aligned. (See BUGS below.)
.It Bq Er ENOMEM
.Dv MAP_FIXED
was specified and the
@@ -206,9 +208,34 @@ parameter wasn't available.
.Dv MAP_ANON
was specified and insufficient memory was available.
.Sh "SEE ALSO"
-.Xr getpagesize 2 ,
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr mlock 2 ,
+.Xr mprotect 2 ,
.Xr msync 2 ,
+.Xr munlock 2 ,
.Xr munmap 2 ,
-.Xr mprotect 2 ,
-.Xr madvise 2 ,
-.Xr mincore 2
+.Xr getpagesize 3
+.Sh BUGS
+.Ar len
+is limited to 2GB. Mmapping slightly more than 2GB doesn't work, but
+it is possible to map a window of size (filesize % 2GB) for file sizes
+of slightly less than 2G, 4GB, 6GB and 8GB.
+.Pp
+The limit is imposed for a variety of reasons. Most of them have to do
+with
+.Tn FreeBSD
+not wanting to use 64 bit offsets in the VM system due to
+the extreme performance penalty. So
+.Tn FreeBSD
+uses 32bit page indexes and
+this gives
+.Tn FreeBSD
+a maximum of 8TB filesizes. It's actually bugs in
+the filesystem code that causes the limit to be further restricted to
+1TB (loss of precision when doing blockno calculations).
+.Pp
+Another reason for the 2GB limit is that filesystem metadata can
+reside at negative offsets.
+.Pp
+We currently can only deal with page aligned file offsets.
OpenPOWER on IntegriCloud