mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
std.process: add PermissionDenied to ProtectMemoryError (for OpenBSD)
See EPERM notes on https://man.openbsd.org/mprotect.2.
This commit is contained in:
parent
ec25b13848
commit
9acfd167fa
1 changed files with 5 additions and 0 deletions
|
|
@ -1004,6 +1004,10 @@ pub fn unlockMemoryAll() UnlockMemoryError!void {
|
|||
|
||||
pub const ProtectMemoryError = error{
|
||||
UnsupportedOperation,
|
||||
/// OpenBSD will refuse to change memory protection if the specified region
|
||||
/// contains any pages that have previously been marked immutable using the
|
||||
/// `mimmutable` function.
|
||||
PermissionDenied,
|
||||
/// The memory cannot be given the specified access. This can happen, for
|
||||
/// example, if you memory map a file to which you have read-only access,
|
||||
/// then use `protectMemory` to mark it writable.
|
||||
|
|
@ -1052,6 +1056,7 @@ pub fn protectMemory(
|
|||
};
|
||||
switch (posix.errno(posix.system.mprotect(memory.ptr, memory.len, flags))) {
|
||||
.SUCCESS => return,
|
||||
.PERM => return error.PermissionDenied,
|
||||
.INVAL => |err| return std.Io.Threaded.errnoBug(err),
|
||||
.ACCES => return error.AccessDenied,
|
||||
.NOMEM => return error.OutOfMemory,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue