Skip to content

Commit 2b3dd81

Browse files
Add MAP_SHARED_VALIDATE & MAP_SYNC
This pull adds two flags: MAP_SHARED_VALIDATE & MAP_SYNC implemented on https://github.com/rust-lang/libc The MAP_SHARED_VALIDATE flag was added to linux since 4.15, its a flag that does two things: provide backwards compatibility with old mmap implementations that don't check for flags, and allow new flags to be added. MAP_SYNC, on the other hand, was added to allow mmap to utilize Direct Accses (DAX) on hardware that support it (non-volatile memory devices) or in general: any ram-shaped filesystem. both flags are available on both linux and android.
1 parent 12e1f5a commit 2b3dd81

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sys/mman.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ libc_bitflags! {
4141
MAP_FILE;
4242
/// Share this mapping. Mutually exclusive with `MAP_PRIVATE`.
4343
MAP_SHARED;
44+
/// Force mmap to check and fail on unknown flags. This also enables `MAP_SYNC`.
45+
#[cfg(any(linux_android, target_os = "linux"))]
46+
MAP_SHARED_VALIDATE;
4447
/// Create a private copy-on-write mapping. Mutually exclusive with `MAP_SHARED`.
4548
MAP_PRIVATE;
4649
/// Place the mapping at exactly the address specified in `addr`.
@@ -142,6 +145,9 @@ libc_bitflags! {
142145
/// Region grows down, like a stack.
143146
#[cfg(any(linux_android, freebsdlike, target_os = "openbsd"))]
144147
MAP_STACK;
148+
/// Do not write through the page caches, write directly to the file. Used for Direct Access (DAX) enabled file systems.
149+
#[cfg(any(linux_android, target_os = "linux"))]
150+
MAP_SYNC;
145151
/// Pages in this mapping are not retained in the kernel's memory cache.
146152
#[cfg(apple_targets)]
147153
MAP_NOCACHE;

0 commit comments

Comments
 (0)