Skip to content

Commit 0778851

Browse files
committed
add mman::mprotect
1 parent f278094 commit 0778851

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77
### Added
8+
- Added an `mprotect` wrapper.
9+
([#991](https://github.com/nix-rust/nix/pull/991))
810
### Changed
911
### Fixed
1012
### Removed

src/sys/mman.rs

+4
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)