Skip to content

Commit 5cd1027

Browse files
committed
add mman::mprotect
1 parent 3749858 commit 5cd1027

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1414
- Added `symlinkat` wrapper.
1515
([#997](https://github.com/nix-rust/nix/pull/997))
1616

17+
- Added an `mprotect` wrapper.
18+
([#991](https://github.com/nix-rust/nix/pull/991))
1719
### Changed
1820
### Fixed
1921
### Removed

src/sys/mman.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ pub unsafe fn madvise(addr: *mut c_void, length: size_t, advise: MmapAdvise) ->
258258
Errno::result(libc::madvise(addr, length, advise as i32)).map(drop)
259259
}
260260

261+
pub unsafe fn mprotect(addr: *mut c_void, length: size_t, prot: ProtFlags) -> Result<()> {
262+
Errno::result(libc::mprotect(addr, length, prot.bits())).map(drop)
263+
}
264+
261265
pub unsafe fn msync(addr: *mut c_void, length: size_t, flags: MsFlags) -> Result<()> {
262266
Errno::result(libc::msync(addr, length, flags.bits())).map(drop)
263267
}

0 commit comments

Comments
 (0)