aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-11-22 23:28:40 +0100
committerLemonBoy <thatlemon@gmail.com>2020-11-23 18:00:05 +0100
commitf8ddc3d8732feece71d6ee55cdfc4d61a5a7e16e (patch)
tree725d930ad3dcba14370029dc649df54ef1a772e4 /lib/std/os.zig
parent9d2fe1682f19bd21a393deeea2c4173b4429b482 (diff)
downloadzig-f8ddc3d8732feece71d6ee55cdfc4d61a5a7e16e.tar.gz
zig-f8ddc3d8732feece71d6ee55cdfc4d61a5a7e16e.zip
std: Fix file locking logic for BSD targets
Diffstat (limited to 'lib/std/os.zig')
-rw-r--r--lib/std/os.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig
index e7c618431c..c93f8d72a5 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -1020,6 +1020,8 @@ pub const OpenError = error{
BadPathName,
InvalidUtf8,
+
+ WouldBlock,
} || UnexpectedError;
/// Open and possibly create a file. Keeps trying if it gets interrupted.
@@ -1201,6 +1203,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t)
EEXIST => return error.PathAlreadyExists,
EBUSY => return error.DeviceBusy,
EOPNOTSUPP => return error.FileLocksNotSupported,
+ EWOULDBLOCK => return error.WouldBlock,
else => |err| return unexpectedErrno(err),
}
}
@@ -4187,6 +4190,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
const flags = if (builtin.os.tag == .linux) O_PATH | O_NONBLOCK | O_CLOEXEC else O_NONBLOCK | O_CLOEXEC;
const fd = openZ(pathname, flags, 0) catch |err| switch (err) {
error.FileLocksNotSupported => unreachable,
+ error.WouldBlock => unreachable,
else => |e| return e,
};
defer close(fd);