Blob Blame History Raw
From f703950fc461d87b9833246be8721593aa5ec460 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Thu, 8 Aug 2019 16:59:54 +0200
Subject: [PATCH 2/6] mmap.2: fix EINVAL conditions
---
 man-pages/man2/mmap.2 | 60 +++++++++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 8 deletions(-)

diff --git a/man-pages/man2/mmap.2 b/man-pages/man2/mmap.2
index 798e0dd..6a9248c 100644
--- a/man-pages/man2/mmap.2
+++ b/man-pages/man2/mmap.2
@@ -126,6 +126,23 @@ or
 .BR munmap ()
 is called.
 .TP
+.BR MAP_SHARED_VALIDATE " (since Linux 4.15)"
+This flag provides the same behavior as
+.B MAP_SHARED
+except that
+.B MAP_SHARED
+mappings ignore unknown flags in
+.IR flags .
+By contrast, when creating a mapping using
+.BR MAP_SHARED_VALIDATE ,
+the kernel verifies all passed flags are known and fails the
+mapping with the error
+.BR EOPNOTSUPP
+for unknown flags.
+This mapping type is also required to be able to use some mapping flags
+(e.g.,
+.BR MAP_SYNC ).
+.TP
 .B MAP_PRIVATE
 Create a private copy-on-write mapping.
 Updates to the mapping are not visible to other processes
@@ -135,8 +152,14 @@ It is unspecified whether changes made to the file after the
 .BR mmap ()
 call are visible in the mapped region.
 .LP
-Both of these flags are described in POSIX.1-2001.
-
+Both
+.B MAP_SHARED
+and
+.B MAP_PRIVATE
+are described in POSIX.1-2001 and POSIX.1-2008.
+.B MAP_SHARED_VALIDATE
+is a Linux extension.
+.LP
 In addition, zero or more of the following values can be ORed in
 .IR flags :
 .TP
@@ -290,6 +313,27 @@ support can later be transparently implemented for glibc.
 .\" "pthread_create() slow for many threads; also time to revisit 64b
 .\"  context switch optimization?"
 .TP
+.BR MAP_SYNC " (since Linux 4.15)"
+This flag is available only with the
+.B MAP_SHARED_VALIDATE
+mapping type;
+mappings of type
+.B MAP_SHARED
+will silently ignore this flag.
+This flag is supported only for files supporting DAX
+(direct mapping of persistent memory).
+For other files, creating a mapping with this flag results in an
+.B EOPNOTSUPP
+error.
+.IP
+Shared file mappings with this flag provide the guarantee that while
+some memory is writably mapped in the address space of the process,
+it will be visible in the same file at the same offset even after
+the system crashes or is rebooted.
+In conjunction with the use of appropriate CPU instructions,
+this provides users of such mappings with a more efficient way
+of making data modifications persistent.
+.TP
 .BR MAP_UNINITIALIZED " (since Linux 2.6.33)"
 Don't clear anonymous pages.
 This flag is intended to improve performance on embedded devices.
@@ -302,7 +346,7 @@ that option is normally enabled only on embedded devices
 .LP
 Of the above flags, only
 .B MAP_FIXED
-is specified in POSIX.1-2001.
+is specified in POSIX.1-2001 and POSIX.1-2008.
 However, most systems also support
 .B MAP_ANONYMOUS
 (or its synonym
@@ -436,11 +480,11 @@ was 0.
 .TP
 .B EINVAL
 .I flags
-contained neither
-.B MAP_PRIVATE
+contained none of
+.BR MAP_PRIVATE ,
+.B MAP_SHARED
 or
-.BR MAP_SHARED ,
-or contained both of these values.
+.BR MAP_SHARED_VALIDATE .
 .TP
 .B ENFILE
 .\" This is for shared anonymous segments
@@ -495,7 +539,7 @@ Attempted access to a portion of the buffer that does not correspond
 to the file (for example, beyond the end of the file, including the
 case where another process has truncated the file).
 .SH CONFORMING TO
-SVr4, 4.4BSD, POSIX.1-2001.
+POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
 .\" SVr4 documents additional error codes ENXIO and ENODEV.
 .\" SUSv2 documents additional error codes EMFILE and EOVERFLOW.
 .SH AVAILABILITY
-- 
2.21.0