diff --git a/CHANGELOG.md b/CHANGELOG.md index d974c7a1d9..2571022b29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Added an `mprotect` wrapper. + ([#991](https://github.com/nix-rust/nix/pull/991)) ### Changed ### Fixed ### Removed diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 48b5767e95..0ae29add4b 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -258,6 +258,10 @@ pub unsafe fn madvise(addr: *mut c_void, length: size_t, advise: MmapAdvise) -> Errno::result(libc::madvise(addr, length, advise as i32)).map(drop) } +pub unsafe fn mprotect(addr: *mut c_void, length: size_t, prot: ProtFlags) -> Result<()> { + Errno::result(libc::mprotect(addr, length, prot.bits())).map(drop) +} + pub unsafe fn msync(addr: *mut c_void, length: size_t, flags: MsFlags) -> Result<()> { Errno::result(libc::msync(addr, length, flags.bits())).map(drop) }