authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-25 11:21:05+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-03-25 11:21:05+01:00
logc94d926bba9344cfab9b00b2bb418ca0e7a32b51
tree296210af462e64e022af113095ebcd61d432994d
parent5bb4fef30a1b12fde3e3a20c2def301f7fd32fab
parent14c046fc0728070c575c0e849b7be649cbb2b9a0
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #23007 from rootbeer/posix-eaccess-eperm

lib/std: Make usage of PermissionDenied & AccessDenied consistent

10 files changed, 113 insertions(+), 98 deletions(-)

lib/std/fs/Dir.zig+20-15
...@@ -247,7 +247,7 @@ pub const Iterator = switch (native_os) {...@@ -247,7 +247,7 @@ pub const Iterator = switch (native_os) {
247 .NOTDIR => unreachable,247 .NOTDIR => unreachable,
248 .INVAL => unreachable,248 .INVAL => unreachable,
249 .ACCES => return error.AccessDenied,249 .ACCES => return error.AccessDenied,
250 .PERM => return error.AccessDenied,250 .PERM => return error.PermissionDenied,
251 else => |err| return posix.unexpectedErrno(err),251 else => |err| return posix.unexpectedErrno(err),
252 }252 }
253 self.first_iter = false;253 self.first_iter = false;
...@@ -267,7 +267,7 @@ pub const Iterator = switch (native_os) {...@@ -267,7 +267,7 @@ pub const Iterator = switch (native_os) {
267 .INVAL => unreachable,267 .INVAL => unreachable,
268 .OVERFLOW => unreachable,268 .OVERFLOW => unreachable,
269 .ACCES => return error.AccessDenied,269 .ACCES => return error.AccessDenied,
270 .PERM => return error.AccessDenied,270 .PERM => return error.PermissionDenied,
271 else => |err| return posix.unexpectedErrno(err),271 else => |err| return posix.unexpectedErrno(err),
272 }272 }
273 }273 }
...@@ -294,7 +294,7 @@ pub const Iterator = switch (native_os) {...@@ -294,7 +294,7 @@ pub const Iterator = switch (native_os) {
294 .BADF => unreachable, // Dir is invalid294 .BADF => unreachable, // Dir is invalid
295 .NOMEM => return error.SystemResources,295 .NOMEM => return error.SystemResources,
296 .ACCES => return error.AccessDenied,296 .ACCES => return error.AccessDenied,
297 .PERM => return error.AccessDenied,297 .PERM => return error.PermissionDenied,
298 .FAULT => unreachable,298 .FAULT => unreachable,
299 .NAMETOOLONG => unreachable,299 .NAMETOOLONG => unreachable,
300 .LOOP => unreachable,300 .LOOP => unreachable,
...@@ -768,6 +768,7 @@ pub const OpenError = error{...@@ -768,6 +768,7 @@ pub const OpenError = error{
768 FileNotFound,768 FileNotFound,
769 NotDir,769 NotDir,
770 AccessDenied,770 AccessDenied,
771 PermissionDenied,
771 SymLinkLoop,772 SymLinkLoop,
772 ProcessFdQuotaExceeded,773 ProcessFdQuotaExceeded,
773 NameTooLong,774 NameTooLong,
...@@ -1503,7 +1504,7 @@ pub fn openDirZ(self: Dir, sub_path_c: [*:0]const u8, args: OpenOptions) OpenErr...@@ -1503,7 +1504,7 @@ pub fn openDirZ(self: Dir, sub_path_c: [*:0]const u8, args: OpenOptions) OpenErr
1503 .NOENT => return error.FileNotFound,1504 .NOENT => return error.FileNotFound,
1504 .NOMEM => return error.SystemResources,1505 .NOMEM => return error.SystemResources,
1505 .NOTDIR => return error.NotDir,1506 .NOTDIR => return error.NotDir,
1506 .PERM => return error.AccessDenied,1507 .PERM => return error.PermissionDenied,
1507 .BUSY => return error.DeviceBusy,1508 .BUSY => return error.DeviceBusy,
1508 else => |err| return posix.unexpectedErrno(err),1509 else => |err| return posix.unexpectedErrno(err),
1509 }1510 }
...@@ -1652,9 +1653,9 @@ pub fn deleteFile(self: Dir, sub_path: []const u8) DeleteFileError!void {...@@ -1652,9 +1653,9 @@ pub fn deleteFile(self: Dir, sub_path: []const u8) DeleteFileError!void {
1652pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {1653pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
1653 posix.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {1654 posix.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {
1654 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR1655 error.DirNotEmpty => unreachable, // not passing AT.REMOVEDIR
1655 error.AccessDenied => |e| switch (native_os) {1656 error.AccessDenied, error.PermissionDenied => |e| switch (native_os) {
1656 // non-Linux POSIX systems return EPERM when trying to delete a directory, so1657 // non-Linux POSIX systems return permission errors when trying to delete a
1657 // we need to handle that case specifically and translate the error1658 // directory, so we need to handle that case specifically and translate the error
1658 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {1659 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {
1659 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)1660 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
1660 const fstat = posix.fstatatZ(self.fd, sub_path_c, posix.AT.SYMLINK_NOFOLLOW) catch return e;1661 const fstat = posix.fstatatZ(self.fd, sub_path_c, posix.AT.SYMLINK_NOFOLLOW) catch return e;
...@@ -1679,6 +1680,7 @@ pub const DeleteDirError = error{...@@ -1679,6 +1680,7 @@ pub const DeleteDirError = error{
1679 DirNotEmpty,1680 DirNotEmpty,
1680 FileNotFound,1681 FileNotFound,
1681 AccessDenied,1682 AccessDenied,
1683 PermissionDenied,
1682 FileBusy,1684 FileBusy,
1683 FileSystem,1685 FileSystem,
1684 SymLinkLoop,1686 SymLinkLoop,
...@@ -1991,6 +1993,7 @@ pub fn readFileAllocOptions(...@@ -1991,6 +1993,7 @@ pub fn readFileAllocOptions(
19911993
1992pub const DeleteTreeError = error{1994pub const DeleteTreeError = error{
1993 AccessDenied,1995 AccessDenied,
1996 PermissionDenied,
1994 FileTooBig,1997 FileTooBig,
1995 SymLinkLoop,1998 SymLinkLoop,
1996 ProcessFdQuotaExceeded,1999 ProcessFdQuotaExceeded,
...@@ -2073,6 +2076,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {...@@ -2073,6 +2076,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2073 },2076 },
20742077
2075 error.AccessDenied,2078 error.AccessDenied,
2079 error.PermissionDenied,
2076 error.SymLinkLoop,2080 error.SymLinkLoop,
2077 error.ProcessFdQuotaExceeded,2081 error.ProcessFdQuotaExceeded,
2078 error.NameTooLong,2082 error.NameTooLong,
...@@ -2112,6 +2116,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {...@@ -2112,6 +2116,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2112 },2116 },
21132117
2114 error.AccessDenied,2118 error.AccessDenied,
2119 error.PermissionDenied,
2115 error.InvalidUtf8,2120 error.InvalidUtf8,
2116 error.InvalidWtf8,2121 error.InvalidWtf8,
2117 error.SymLinkLoop,2122 error.SymLinkLoop,
...@@ -2168,6 +2173,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {...@@ -2168,6 +2173,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2168 },2173 },
21692174
2170 error.AccessDenied,2175 error.AccessDenied,
2176 error.PermissionDenied,
2171 error.SymLinkLoop,2177 error.SymLinkLoop,
2172 error.ProcessFdQuotaExceeded,2178 error.ProcessFdQuotaExceeded,
2173 error.NameTooLong,2179 error.NameTooLong,
...@@ -2197,6 +2203,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {...@@ -2197,6 +2203,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2197 },2203 },
21982204
2199 error.AccessDenied,2205 error.AccessDenied,
2206 error.PermissionDenied,
2200 error.InvalidUtf8,2207 error.InvalidUtf8,
2201 error.InvalidWtf8,2208 error.InvalidWtf8,
2202 error.SymLinkLoop,2209 error.SymLinkLoop,
...@@ -2273,6 +2280,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint...@@ -2273,6 +2280,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
2273 },2280 },
22742281
2275 error.AccessDenied,2282 error.AccessDenied,
2283 error.PermissionDenied,
2276 error.SymLinkLoop,2284 error.SymLinkLoop,
2277 error.ProcessFdQuotaExceeded,2285 error.ProcessFdQuotaExceeded,
2278 error.NameTooLong,2286 error.NameTooLong,
...@@ -2309,6 +2317,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint...@@ -2309,6 +2317,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
2309 },2317 },
23102318
2311 error.AccessDenied,2319 error.AccessDenied,
2320 error.PermissionDenied,
2312 error.InvalidUtf8,2321 error.InvalidUtf8,
2313 error.InvalidWtf8,2322 error.InvalidWtf8,
2314 error.SymLinkLoop,2323 error.SymLinkLoop,
...@@ -2371,6 +2380,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File...@@ -2371,6 +2380,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
2371 },2380 },
23722381
2373 error.AccessDenied,2382 error.AccessDenied,
2383 error.PermissionDenied,
2374 error.SymLinkLoop,2384 error.SymLinkLoop,
2375 error.ProcessFdQuotaExceeded,2385 error.ProcessFdQuotaExceeded,
2376 error.NameTooLong,2386 error.NameTooLong,
...@@ -2397,6 +2407,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File...@@ -2397,6 +2407,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
2397 },2407 },
23982408
2399 error.AccessDenied,2409 error.AccessDenied,
2410 error.PermissionDenied,
2400 error.InvalidUtf8,2411 error.InvalidUtf8,
2401 error.InvalidWtf8,2412 error.InvalidWtf8,
2402 error.SymLinkLoop,2413 error.SymLinkLoop,
...@@ -2447,10 +2458,7 @@ pub const AccessError = posix.AccessError;...@@ -2447,10 +2458,7 @@ pub const AccessError = posix.AccessError;
2447/// open it and handle the error for file not found.2458/// open it and handle the error for file not found.
2448pub fn access(self: Dir, sub_path: []const u8, flags: File.OpenFlags) AccessError!void {2459pub fn access(self: Dir, sub_path: []const u8, flags: File.OpenFlags) AccessError!void {
2449 if (native_os == .windows) {2460 if (native_os == .windows) {
2450 const sub_path_w = windows.sliceToPrefixedFileW(self.fd, sub_path) catch |err| switch (err) {2461 const sub_path_w = try windows.sliceToPrefixedFileW(self.fd, sub_path);
2451 error.AccessDenied => return error.PermissionDenied,
2452 else => |e| return e,
2453 };
2454 return self.accessW(sub_path_w.span().ptr, flags);2462 return self.accessW(sub_path_w.span().ptr, flags);
2455 }2463 }
2456 const path_c = try posix.toPosixPath(sub_path);2464 const path_c = try posix.toPosixPath(sub_path);
...@@ -2460,10 +2468,7 @@ pub fn access(self: Dir, sub_path: []const u8, flags: File.OpenFlags) AccessErro...@@ -2460,10 +2468,7 @@ pub fn access(self: Dir, sub_path: []const u8, flags: File.OpenFlags) AccessErro
2460/// Same as `access` except the path parameter is null-terminated.2468/// Same as `access` except the path parameter is null-terminated.
2461pub fn accessZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) AccessError!void {2469pub fn accessZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) AccessError!void {
2462 if (native_os == .windows) {2470 if (native_os == .windows) {
2463 const sub_path_w = windows.cStrToPrefixedFileW(self.fd, sub_path) catch |err| switch (err) {2471 const sub_path_w = try windows.cStrToPrefixedFileW(self.fd, sub_path);
2464 error.AccessDenied => return error.PermissionDenied,
2465 else => |e| return e,
2466 };
2467 return self.accessW(sub_path_w.span().ptr, flags);2472 return self.accessW(sub_path_w.span().ptr, flags);
2468 }2473 }
2469 const os_mode = switch (flags.mode) {2474 const os_mode = switch (flags.mode) {
lib/std/fs/test.zig+1-1
...@@ -383,7 +383,7 @@ test "openDirAbsolute" {...@@ -383,7 +383,7 @@ test "openDirAbsolute" {
383383
384test "openDir cwd parent '..'" {384test "openDir cwd parent '..'" {
385 var dir = fs.cwd().openDir("..", .{}) catch |err| {385 var dir = fs.cwd().openDir("..", .{}) catch |err| {
386 if (native_os == .wasi and err == error.AccessDenied) {386 if (native_os == .wasi and err == error.PermissionDenied) {
387 return; // This is okay. WASI disallows escaping from the fs sandbox387 return; // This is okay. WASI disallows escaping from the fs sandbox
388 }388 }
389 return err;389 return err;
lib/std/io/c_writer.zig+1-1
...@@ -23,7 +23,7 @@ fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!u...@@ -23,7 +23,7 @@ fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!u
23 .FBIG => return error.FileTooBig,23 .FBIG => return error.FileTooBig,
24 .IO => return error.InputOutput,24 .IO => return error.InputOutput,
25 .NOSPC => return error.NoSpaceLeft,25 .NOSPC => return error.NoSpaceLeft,
26 .PERM => return error.AccessDenied,26 .PERM => return error.PermissionDenied,
27 .PIPE => return error.BrokenPipe,27 .PIPE => return error.BrokenPipe,
28 else => |err| return std.posix.unexpectedErrno(err),28 else => |err| return std.posix.unexpectedErrno(err),
29 }29 }
lib/std/os.zig+1-1
...@@ -65,7 +65,7 @@ pub fn accessW(path: [*:0]const u16) windows.GetFileAttributesError!void {...@@ -65,7 +65,7 @@ pub fn accessW(path: [*:0]const u16) windows.GetFileAttributesError!void {
65 switch (windows.GetLastError()) {65 switch (windows.GetLastError()) {
66 .FILE_NOT_FOUND => return error.FileNotFound,66 .FILE_NOT_FOUND => return error.FileNotFound,
67 .PATH_NOT_FOUND => return error.FileNotFound,67 .PATH_NOT_FOUND => return error.FileNotFound,
68 .ACCESS_DENIED => return error.PermissionDenied,68 .ACCESS_DENIED => return error.AccessDenied,
69 else => |err| return windows.unexpectedError(err),69 else => |err| return windows.unexpectedError(err),
70 }70 }
71}71}
lib/std/os/linux/bpf.zig+6-6
...@@ -1548,7 +1548,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries...@@ -1548,7 +1548,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
1548 .SUCCESS => return @as(fd_t, @intCast(rc)),1548 .SUCCESS => return @as(fd_t, @intCast(rc)),
1549 .INVAL => return error.MapTypeOrAttrInvalid,1549 .INVAL => return error.MapTypeOrAttrInvalid,
1550 .NOMEM => return error.SystemResources,1550 .NOMEM => return error.SystemResources,
1551 .PERM => return error.AccessDenied,1551 .PERM => return error.PermissionDenied,
1552 else => |err| return unexpectedErrno(err),1552 else => |err| return unexpectedErrno(err),
1553 }1553 }
1554}1554}
...@@ -1574,7 +1574,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {...@@ -1574,7 +1574,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
1574 .FAULT => unreachable,1574 .FAULT => unreachable,
1575 .INVAL => return error.FieldInAttrNeedsZeroing,1575 .INVAL => return error.FieldInAttrNeedsZeroing,
1576 .NOENT => return error.NotFound,1576 .NOENT => return error.NotFound,
1577 .PERM => return error.AccessDenied,1577 .PERM => return error.PermissionDenied,
1578 else => |err| return unexpectedErrno(err),1578 else => |err| return unexpectedErrno(err),
1579 }1579 }
1580}1580}
...@@ -1597,7 +1597,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)...@@ -1597,7 +1597,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
1597 .FAULT => unreachable,1597 .FAULT => unreachable,
1598 .INVAL => return error.FieldInAttrNeedsZeroing,1598 .INVAL => return error.FieldInAttrNeedsZeroing,
1599 .NOMEM => return error.SystemResources,1599 .NOMEM => return error.SystemResources,
1600 .PERM => return error.AccessDenied,1600 .PERM => return error.PermissionDenied,
1601 else => |err| return unexpectedErrno(err),1601 else => |err| return unexpectedErrno(err),
1602 }1602 }
1603}1603}
...@@ -1617,7 +1617,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {...@@ -1617,7 +1617,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {
1617 .FAULT => unreachable,1617 .FAULT => unreachable,
1618 .INVAL => return error.FieldInAttrNeedsZeroing,1618 .INVAL => return error.FieldInAttrNeedsZeroing,
1619 .NOENT => return error.NotFound,1619 .NOENT => return error.NotFound,
1620 .PERM => return error.AccessDenied,1620 .PERM => return error.PermissionDenied,
1621 else => |err| return unexpectedErrno(err),1621 else => |err| return unexpectedErrno(err),
1622 }1622 }
1623}1623}
...@@ -1638,7 +1638,7 @@ pub fn map_get_next_key(fd: fd_t, key: []const u8, next_key: []u8) !bool {...@@ -1638,7 +1638,7 @@ pub fn map_get_next_key(fd: fd_t, key: []const u8, next_key: []u8) !bool {
1638 .FAULT => unreachable,1638 .FAULT => unreachable,
1639 .INVAL => return error.FieldInAttrNeedsZeroing,1639 .INVAL => return error.FieldInAttrNeedsZeroing,
1640 .NOENT => return false,1640 .NOENT => return false,
1641 .PERM => return error.AccessDenied,1641 .PERM => return error.PermissionDenied,
1642 else => |err| return unexpectedErrno(err),1642 else => |err| return unexpectedErrno(err),
1643 }1643 }
1644}1644}
...@@ -1712,7 +1712,7 @@ pub fn prog_load(...@@ -1712,7 +1712,7 @@ pub fn prog_load(
1712 .ACCES => error.UnsafeProgram,1712 .ACCES => error.UnsafeProgram,
1713 .FAULT => unreachable,1713 .FAULT => unreachable,
1714 .INVAL => error.InvalidProgram,1714 .INVAL => error.InvalidProgram,
1715 .PERM => error.AccessDenied,1715 .PERM => error.PermissionDenied,
1716 else => |err| unexpectedErrno(err),1716 else => |err| unexpectedErrno(err),
1717 };1717 };
1718}1718}
lib/std/os/windows.zig+4-4
...@@ -1517,7 +1517,7 @@ pub fn GetFileSizeEx(hFile: HANDLE) GetFileSizeError!u64 {...@@ -1517,7 +1517,7 @@ pub fn GetFileSizeEx(hFile: HANDLE) GetFileSizeError!u64 {
15171517
1518pub const GetFileAttributesError = error{1518pub const GetFileAttributesError = error{
1519 FileNotFound,1519 FileNotFound,
1520 PermissionDenied,1520 AccessDenied,
1521 Unexpected,1521 Unexpected,
1522};1522};
15231523
...@@ -1532,7 +1532,7 @@ pub fn GetFileAttributesW(lpFileName: [*:0]const u16) GetFileAttributesError!DWO...@@ -1532,7 +1532,7 @@ pub fn GetFileAttributesW(lpFileName: [*:0]const u16) GetFileAttributesError!DWO
1532 switch (GetLastError()) {1532 switch (GetLastError()) {
1533 .FILE_NOT_FOUND => return error.FileNotFound,1533 .FILE_NOT_FOUND => return error.FileNotFound,
1534 .PATH_NOT_FOUND => return error.FileNotFound,1534 .PATH_NOT_FOUND => return error.FileNotFound,
1535 .ACCESS_DENIED => return error.PermissionDenied,1535 .ACCESS_DENIED => return error.AccessDenied,
1536 else => |err| return unexpectedError(err),1536 else => |err| return unexpectedError(err),
1537 }1537 }
1538 }1538 }
...@@ -1747,12 +1747,12 @@ pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) Ge...@@ -1747,12 +1747,12 @@ pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) Ge
1747 return buf_ptr[0..rc :0];1747 return buf_ptr[0..rc :0];
1748}1748}
17491749
1750pub const TerminateProcessError = error{ PermissionDenied, Unexpected };1750pub const TerminateProcessError = error{ AccessDenied, Unexpected };
17511751
1752pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) TerminateProcessError!void {1752pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) TerminateProcessError!void {
1753 if (kernel32.TerminateProcess(hProcess, uExitCode) == 0) {1753 if (kernel32.TerminateProcess(hProcess, uExitCode) == 0) {
1754 switch (GetLastError()) {1754 switch (GetLastError()) {
1755 Win32Error.ACCESS_DENIED => return error.PermissionDenied,1755 Win32Error.ACCESS_DENIED => return error.AccessDenied,
1756 else => |err| return unexpectedError(err),1756 else => |err| return unexpectedError(err),
1757 }1757 }
1758 }1758 }
lib/std/posix.zig+73-68
...@@ -281,6 +281,7 @@ pub fn close(fd: fd_t) void {...@@ -281,6 +281,7 @@ pub fn close(fd: fd_t) void {
281281
282pub const FChmodError = error{282pub const FChmodError = error{
283 AccessDenied,283 AccessDenied,
284 PermissionDenied,
284 InputOutput,285 InputOutput,
285 SymLinkLoop,286 SymLinkLoop,
286 FileNotFound,287 FileNotFound,
...@@ -310,7 +311,7 @@ pub fn fchmod(fd: fd_t, mode: mode_t) FChmodError!void {...@@ -310,7 +311,7 @@ pub fn fchmod(fd: fd_t, mode: mode_t) FChmodError!void {
310 .NOENT => return error.FileNotFound,311 .NOENT => return error.FileNotFound,
311 .NOMEM => return error.SystemResources,312 .NOMEM => return error.SystemResources,
312 .NOTDIR => return error.FileNotFound,313 .NOTDIR => return error.FileNotFound,
313 .PERM => return error.AccessDenied,314 .PERM => return error.PermissionDenied,
314 .ROFS => return error.ReadOnlyFileSystem,315 .ROFS => return error.ReadOnlyFileSystem,
315 else => |err| return unexpectedErrno(err),316 else => |err| return unexpectedErrno(err),
316 }317 }
...@@ -387,7 +388,7 @@ fn fchmodat1(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -387,7 +388,7 @@ fn fchmodat1(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
387 .NOTDIR => return error.FileNotFound,388 .NOTDIR => return error.FileNotFound,
388 .NOMEM => return error.SystemResources,389 .NOMEM => return error.SystemResources,
389 .OPNOTSUPP => return error.OperationNotSupported,390 .OPNOTSUPP => return error.OperationNotSupported,
390 .PERM => return error.AccessDenied,391 .PERM => return error.PermissionDenied,
391 .ROFS => return error.ReadOnlyFileSystem,392 .ROFS => return error.ReadOnlyFileSystem,
392 else => |err| return unexpectedErrno(err),393 else => |err| return unexpectedErrno(err),
393 }394 }
...@@ -418,7 +419,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -418,7 +419,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
418 .NOMEM => return error.SystemResources,419 .NOMEM => return error.SystemResources,
419 .NOTDIR => return error.FileNotFound,420 .NOTDIR => return error.FileNotFound,
420 .OPNOTSUPP => return error.OperationNotSupported,421 .OPNOTSUPP => return error.OperationNotSupported,
421 .PERM => return error.AccessDenied,422 .PERM => return error.PermissionDenied,
422 .ROFS => return error.ReadOnlyFileSystem,423 .ROFS => return error.ReadOnlyFileSystem,
423424
424 .NOSYS => {425 .NOSYS => {
...@@ -447,7 +448,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -447,7 +448,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
447 .FAULT => unreachable,448 .FAULT => unreachable,
448 .INVAL => unreachable,449 .INVAL => unreachable,
449 .ACCES => return error.AccessDenied,450 .ACCES => return error.AccessDenied,
450 .PERM => return error.AccessDenied,451 .PERM => return error.PermissionDenied,
451 .LOOP => return error.SymLinkLoop,452 .LOOP => return error.SymLinkLoop,
452 .MFILE => return error.ProcessFdQuotaExceeded,453 .MFILE => return error.ProcessFdQuotaExceeded,
453 .NAMETOOLONG => return error.NameTooLong,454 .NAMETOOLONG => return error.NameTooLong,
...@@ -486,7 +487,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -486,7 +487,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
486 .LOOP => return error.SymLinkLoop,487 .LOOP => return error.SymLinkLoop,
487 .NOMEM => return error.SystemResources,488 .NOMEM => return error.SystemResources,
488 .NOTDIR => return error.FileNotFound,489 .NOTDIR => return error.FileNotFound,
489 .PERM => return error.AccessDenied,490 .PERM => return error.PermissionDenied,
490 .ROFS => return error.ReadOnlyFileSystem,491 .ROFS => return error.ReadOnlyFileSystem,
491 else => |err| return unexpectedErrno(err),492 else => |err| return unexpectedErrno(err),
492 }493 }
...@@ -495,6 +496,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -495,6 +496,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
495496
496pub const FChownError = error{497pub const FChownError = error{
497 AccessDenied,498 AccessDenied,
499 PermissionDenied,
498 InputOutput,500 InputOutput,
499 SymLinkLoop,501 SymLinkLoop,
500 FileNotFound,502 FileNotFound,
...@@ -529,7 +531,7 @@ pub fn fchown(fd: fd_t, owner: ?uid_t, group: ?gid_t) FChownError!void {...@@ -529,7 +531,7 @@ pub fn fchown(fd: fd_t, owner: ?uid_t, group: ?gid_t) FChownError!void {
529 .NOENT => return error.FileNotFound,531 .NOENT => return error.FileNotFound,
530 .NOMEM => return error.SystemResources,532 .NOMEM => return error.SystemResources,
531 .NOTDIR => return error.FileNotFound,533 .NOTDIR => return error.FileNotFound,
532 .PERM => return error.AccessDenied,534 .PERM => return error.PermissionDenied,
533 .ROFS => return error.ReadOnlyFileSystem,535 .ROFS => return error.ReadOnlyFileSystem,
534 else => |err| return unexpectedErrno(err),536 else => |err| return unexpectedErrno(err),
535 }537 }
...@@ -1031,10 +1033,8 @@ pub const TruncateError = error{...@@ -1031,10 +1033,8 @@ pub const TruncateError = error{
1031 FileTooBig,1033 FileTooBig,
1032 InputOutput,1034 InputOutput,
1033 FileBusy,1035 FileBusy,
1034
1035 /// In WASI, this error occurs when the file descriptor does
1036 /// not hold the required rights to call `ftruncate` on it.
1037 AccessDenied,1036 AccessDenied,
1037 PermissionDenied,
1038} || UnexpectedError;1038} || UnexpectedError;
10391039
1040pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {1040pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
...@@ -1066,7 +1066,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {...@@ -1066,7 +1066,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
1066 .INTR => unreachable,1066 .INTR => unreachable,
1067 .FBIG => return error.FileTooBig,1067 .FBIG => return error.FileTooBig,
1068 .IO => return error.InputOutput,1068 .IO => return error.InputOutput,
1069 .PERM => return error.AccessDenied,1069 .PERM => return error.PermissionDenied,
1070 .TXTBSY => return error.FileBusy,1070 .TXTBSY => return error.FileBusy,
1071 .BADF => unreachable, // Handle not open for writing1071 .BADF => unreachable, // Handle not open for writing
1072 .INVAL => unreachable, // Handle not open for writing1072 .INVAL => unreachable, // Handle not open for writing
...@@ -1082,7 +1082,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {...@@ -1082,7 +1082,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
1082 .INTR => continue,1082 .INTR => continue,
1083 .FBIG => return error.FileTooBig,1083 .FBIG => return error.FileTooBig,
1084 .IO => return error.InputOutput,1084 .IO => return error.InputOutput,
1085 .PERM => return error.AccessDenied,1085 .PERM => return error.PermissionDenied,
1086 .TXTBSY => return error.FileBusy,1086 .TXTBSY => return error.FileBusy,
1087 .BADF => unreachable, // Handle not open for writing1087 .BADF => unreachable, // Handle not open for writing
1088 .INVAL => unreachable, // Handle not open for writing1088 .INVAL => unreachable, // Handle not open for writing
...@@ -1176,6 +1176,7 @@ pub const WriteError = error{...@@ -1176,6 +1176,7 @@ pub const WriteError = error{
11761176
1177 /// File descriptor does not hold the required rights to write to it.1177 /// File descriptor does not hold the required rights to write to it.
1178 AccessDenied,1178 AccessDenied,
1179 PermissionDenied,
1179 BrokenPipe,1180 BrokenPipe,
1180 SystemResources,1181 SystemResources,
1181 OperationAborted,1182 OperationAborted,
...@@ -1250,7 +1251,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {...@@ -1250,7 +1251,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
1250 .FBIG => return error.FileTooBig,1251 .FBIG => return error.FileTooBig,
1251 .IO => return error.InputOutput,1252 .IO => return error.InputOutput,
1252 .NOSPC => return error.NoSpaceLeft,1253 .NOSPC => return error.NoSpaceLeft,
1253 .PERM => return error.AccessDenied,1254 .PERM => return error.PermissionDenied,
1254 .PIPE => return error.BrokenPipe,1255 .PIPE => return error.BrokenPipe,
1255 .NOTCAPABLE => return error.AccessDenied,1256 .NOTCAPABLE => return error.AccessDenied,
1256 else => |err| return unexpectedErrno(err),1257 else => |err| return unexpectedErrno(err),
...@@ -1278,7 +1279,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {...@@ -1278,7 +1279,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
1278 .IO => return error.InputOutput,1279 .IO => return error.InputOutput,
1279 .NOSPC => return error.NoSpaceLeft,1280 .NOSPC => return error.NoSpaceLeft,
1280 .ACCES => return error.AccessDenied,1281 .ACCES => return error.AccessDenied,
1281 .PERM => return error.AccessDenied,1282 .PERM => return error.PermissionDenied,
1282 .PIPE => return error.BrokenPipe,1283 .PIPE => return error.BrokenPipe,
1283 .CONNRESET => return error.ConnectionResetByPeer,1284 .CONNRESET => return error.ConnectionResetByPeer,
1284 .BUSY => return error.DeviceBusy,1285 .BUSY => return error.DeviceBusy,
...@@ -1331,7 +1332,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {...@@ -1331,7 +1332,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
1331 .FBIG => return error.FileTooBig,1332 .FBIG => return error.FileTooBig,
1332 .IO => return error.InputOutput,1333 .IO => return error.InputOutput,
1333 .NOSPC => return error.NoSpaceLeft,1334 .NOSPC => return error.NoSpaceLeft,
1334 .PERM => return error.AccessDenied,1335 .PERM => return error.PermissionDenied,
1335 .PIPE => return error.BrokenPipe,1336 .PIPE => return error.BrokenPipe,
1336 .NOTCAPABLE => return error.AccessDenied,1337 .NOTCAPABLE => return error.AccessDenied,
1337 else => |err| return unexpectedErrno(err),1338 else => |err| return unexpectedErrno(err),
...@@ -1353,7 +1354,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {...@@ -1353,7 +1354,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
1353 .FBIG => return error.FileTooBig,1354 .FBIG => return error.FileTooBig,
1354 .IO => return error.InputOutput,1355 .IO => return error.InputOutput,
1355 .NOSPC => return error.NoSpaceLeft,1356 .NOSPC => return error.NoSpaceLeft,
1356 .PERM => return error.AccessDenied,1357 .PERM => return error.PermissionDenied,
1357 .PIPE => return error.BrokenPipe,1358 .PIPE => return error.BrokenPipe,
1358 .CONNRESET => return error.ConnectionResetByPeer,1359 .CONNRESET => return error.ConnectionResetByPeer,
1359 .BUSY => return error.DeviceBusy,1360 .BUSY => return error.DeviceBusy,
...@@ -1410,7 +1411,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {...@@ -1410,7 +1411,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
1410 .FBIG => return error.FileTooBig,1411 .FBIG => return error.FileTooBig,
1411 .IO => return error.InputOutput,1412 .IO => return error.InputOutput,
1412 .NOSPC => return error.NoSpaceLeft,1413 .NOSPC => return error.NoSpaceLeft,
1413 .PERM => return error.AccessDenied,1414 .PERM => return error.PermissionDenied,
1414 .PIPE => return error.BrokenPipe,1415 .PIPE => return error.BrokenPipe,
1415 .NXIO => return error.Unseekable,1416 .NXIO => return error.Unseekable,
1416 .SPIPE => return error.Unseekable,1417 .SPIPE => return error.Unseekable,
...@@ -1443,7 +1444,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {...@@ -1443,7 +1444,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
1443 .FBIG => return error.FileTooBig,1444 .FBIG => return error.FileTooBig,
1444 .IO => return error.InputOutput,1445 .IO => return error.InputOutput,
1445 .NOSPC => return error.NoSpaceLeft,1446 .NOSPC => return error.NoSpaceLeft,
1446 .PERM => return error.AccessDenied,1447 .PERM => return error.PermissionDenied,
1447 .PIPE => return error.BrokenPipe,1448 .PIPE => return error.BrokenPipe,
1448 .NXIO => return error.Unseekable,1449 .NXIO => return error.Unseekable,
1449 .SPIPE => return error.Unseekable,1450 .SPIPE => return error.Unseekable,
...@@ -1502,7 +1503,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz...@@ -1502,7 +1503,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
1502 .FBIG => return error.FileTooBig,1503 .FBIG => return error.FileTooBig,
1503 .IO => return error.InputOutput,1504 .IO => return error.InputOutput,
1504 .NOSPC => return error.NoSpaceLeft,1505 .NOSPC => return error.NoSpaceLeft,
1505 .PERM => return error.AccessDenied,1506 .PERM => return error.PermissionDenied,
1506 .PIPE => return error.BrokenPipe,1507 .PIPE => return error.BrokenPipe,
1507 .NXIO => return error.Unseekable,1508 .NXIO => return error.Unseekable,
1508 .SPIPE => return error.Unseekable,1509 .SPIPE => return error.Unseekable,
...@@ -1528,7 +1529,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz...@@ -1528,7 +1529,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
1528 .FBIG => return error.FileTooBig,1529 .FBIG => return error.FileTooBig,
1529 .IO => return error.InputOutput,1530 .IO => return error.InputOutput,
1530 .NOSPC => return error.NoSpaceLeft,1531 .NOSPC => return error.NoSpaceLeft,
1531 .PERM => return error.AccessDenied,1532 .PERM => return error.PermissionDenied,
1532 .PIPE => return error.BrokenPipe,1533 .PIPE => return error.BrokenPipe,
1533 .NXIO => return error.Unseekable,1534 .NXIO => return error.Unseekable,
1534 .SPIPE => return error.Unseekable,1535 .SPIPE => return error.Unseekable,
...@@ -1543,6 +1544,7 @@ pub const OpenError = error{...@@ -1543,6 +1544,7 @@ pub const OpenError = error{
1543 /// In WASI, this error may occur when the file descriptor does1544 /// In WASI, this error may occur when the file descriptor does
1544 /// not hold the required rights to open a new resource relative to it.1545 /// not hold the required rights to open a new resource relative to it.
1545 AccessDenied,1546 AccessDenied,
1547 PermissionDenied,
1546 SymLinkLoop,1548 SymLinkLoop,
1547 ProcessFdQuotaExceeded,1549 ProcessFdQuotaExceeded,
1548 SystemFdQuotaExceeded,1550 SystemFdQuotaExceeded,
...@@ -1660,7 +1662,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {...@@ -1660,7 +1662,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {
1660 .NOMEM => return error.SystemResources,1662 .NOMEM => return error.SystemResources,
1661 .NOSPC => return error.NoSpaceLeft,1663 .NOSPC => return error.NoSpaceLeft,
1662 .NOTDIR => return error.NotDir,1664 .NOTDIR => return error.NotDir,
1663 .PERM => return error.AccessDenied,1665 .PERM => return error.PermissionDenied,
1664 .EXIST => return error.PathAlreadyExists,1666 .EXIST => return error.PathAlreadyExists,
1665 .BUSY => return error.DeviceBusy,1667 .BUSY => return error.DeviceBusy,
1666 .ILSEQ => |err| if (native_os == .wasi)1668 .ILSEQ => |err| if (native_os == .wasi)
...@@ -1740,7 +1742,7 @@ pub fn openatWasi(...@@ -1740,7 +1742,7 @@ pub fn openatWasi(
1740 .NOMEM => return error.SystemResources,1742 .NOMEM => return error.SystemResources,
1741 .NOSPC => return error.NoSpaceLeft,1743 .NOSPC => return error.NoSpaceLeft,
1742 .NOTDIR => return error.NotDir,1744 .NOTDIR => return error.NotDir,
1743 .PERM => return error.AccessDenied,1745 .PERM => return error.PermissionDenied,
1744 .EXIST => return error.PathAlreadyExists,1746 .EXIST => return error.PathAlreadyExists,
1745 .BUSY => return error.DeviceBusy,1747 .BUSY => return error.DeviceBusy,
1746 .NOTCAPABLE => return error.AccessDenied,1748 .NOTCAPABLE => return error.AccessDenied,
...@@ -1831,7 +1833,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) O...@@ -1831,7 +1833,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) O
1831 .NOMEM => return error.SystemResources,1833 .NOMEM => return error.SystemResources,
1832 .NOSPC => return error.NoSpaceLeft,1834 .NOSPC => return error.NoSpaceLeft,
1833 .NOTDIR => return error.NotDir,1835 .NOTDIR => return error.NotDir,
1834 .PERM => return error.AccessDenied,1836 .PERM => return error.PermissionDenied,
1835 .EXIST => return error.PathAlreadyExists,1837 .EXIST => return error.PathAlreadyExists,
1836 .BUSY => return error.DeviceBusy,1838 .BUSY => return error.DeviceBusy,
1837 .OPNOTSUPP => return error.FileLocksNotSupported,1839 .OPNOTSUPP => return error.FileLocksNotSupported,
...@@ -1873,6 +1875,7 @@ pub fn dup2(old_fd: fd_t, new_fd: fd_t) !void {...@@ -1873,6 +1875,7 @@ pub fn dup2(old_fd: fd_t, new_fd: fd_t) !void {
1873pub const ExecveError = error{1875pub const ExecveError = error{
1874 SystemResources,1876 SystemResources,
1875 AccessDenied,1877 AccessDenied,
1878 PermissionDenied,
1876 InvalidExe,1879 InvalidExe,
1877 FileSystem,1880 FileSystem,
1878 IsDir,1881 IsDir,
...@@ -1899,7 +1902,7 @@ pub fn execveZ(...@@ -1899,7 +1902,7 @@ pub fn execveZ(
1899 .NFILE => return error.SystemFdQuotaExceeded,1902 .NFILE => return error.SystemFdQuotaExceeded,
1900 .NOMEM => return error.SystemResources,1903 .NOMEM => return error.SystemResources,
1901 .ACCES => return error.AccessDenied,1904 .ACCES => return error.AccessDenied,
1902 .PERM => return error.AccessDenied,1905 .PERM => return error.PermissionDenied,
1903 .INVAL => return error.InvalidExe,1906 .INVAL => return error.InvalidExe,
1904 .NOEXEC => return error.InvalidExe,1907 .NOEXEC => return error.InvalidExe,
1905 .IO => return error.FileSystem,1908 .IO => return error.FileSystem,
...@@ -2077,6 +2080,7 @@ pub const SymLinkError = error{...@@ -2077,6 +2080,7 @@ pub const SymLinkError = error{
2077 /// In WASI, this error may occur when the file descriptor does2080 /// In WASI, this error may occur when the file descriptor does
2078 /// not hold the required rights to create a new symbolic link relative to it.2081 /// not hold the required rights to create a new symbolic link relative to it.
2079 AccessDenied,2082 AccessDenied,
2083 PermissionDenied,
2080 DiskQuota,2084 DiskQuota,
2081 PathAlreadyExists,2085 PathAlreadyExists,
2082 FileSystem,2086 FileSystem,
...@@ -2130,7 +2134,7 @@ pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin...@@ -2130,7 +2134,7 @@ pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin
2130 .FAULT => unreachable,2134 .FAULT => unreachable,
2131 .INVAL => unreachable,2135 .INVAL => unreachable,
2132 .ACCES => return error.AccessDenied,2136 .ACCES => return error.AccessDenied,
2133 .PERM => return error.AccessDenied,2137 .PERM => return error.PermissionDenied,
2134 .DQUOT => return error.DiskQuota,2138 .DQUOT => return error.DiskQuota,
2135 .EXIST => return error.PathAlreadyExists,2139 .EXIST => return error.PathAlreadyExists,
2136 .IO => return error.FileSystem,2140 .IO => return error.FileSystem,
...@@ -2178,7 +2182,7 @@ pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []c...@@ -2178,7 +2182,7 @@ pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []c
2178 .INVAL => unreachable,2182 .INVAL => unreachable,
2179 .BADF => unreachable,2183 .BADF => unreachable,
2180 .ACCES => return error.AccessDenied,2184 .ACCES => return error.AccessDenied,
2181 .PERM => return error.AccessDenied,2185 .PERM => return error.PermissionDenied,
2182 .DQUOT => return error.DiskQuota,2186 .DQUOT => return error.DiskQuota,
2183 .EXIST => return error.PathAlreadyExists,2187 .EXIST => return error.PathAlreadyExists,
2184 .IO => return error.FileSystem,2188 .IO => return error.FileSystem,
...@@ -2208,7 +2212,7 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:...@@ -2208,7 +2212,7 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:
2208 .FAULT => unreachable,2212 .FAULT => unreachable,
2209 .INVAL => unreachable,2213 .INVAL => unreachable,
2210 .ACCES => return error.AccessDenied,2214 .ACCES => return error.AccessDenied,
2211 .PERM => return error.AccessDenied,2215 .PERM => return error.PermissionDenied,
2212 .DQUOT => return error.DiskQuota,2216 .DQUOT => return error.DiskQuota,
2213 .EXIST => return error.PathAlreadyExists,2217 .EXIST => return error.PathAlreadyExists,
2214 .IO => return error.FileSystem,2218 .IO => return error.FileSystem,
...@@ -2229,6 +2233,7 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:...@@ -2229,6 +2233,7 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:
22292233
2230pub const LinkError = UnexpectedError || error{2234pub const LinkError = UnexpectedError || error{
2231 AccessDenied,2235 AccessDenied,
2236 PermissionDenied,
2232 DiskQuota,2237 DiskQuota,
2233 PathAlreadyExists,2238 PathAlreadyExists,
2234 FileSystem,2239 FileSystem,
...@@ -2264,7 +2269,7 @@ pub fn linkZ(oldpath: [*:0]const u8, newpath: [*:0]const u8) LinkError!void {...@@ -2264,7 +2269,7 @@ pub fn linkZ(oldpath: [*:0]const u8, newpath: [*:0]const u8) LinkError!void {
2264 .NOENT => return error.FileNotFound,2269 .NOENT => return error.FileNotFound,
2265 .NOMEM => return error.SystemResources,2270 .NOMEM => return error.SystemResources,
2266 .NOSPC => return error.NoSpaceLeft,2271 .NOSPC => return error.NoSpaceLeft,
2267 .PERM => return error.AccessDenied,2272 .PERM => return error.PermissionDenied,
2268 .ROFS => return error.ReadOnlyFileSystem,2273 .ROFS => return error.ReadOnlyFileSystem,
2269 .XDEV => return error.NotSameFileSystem,2274 .XDEV => return error.NotSameFileSystem,
2270 .INVAL => unreachable,2275 .INVAL => unreachable,
...@@ -2318,7 +2323,7 @@ pub fn linkatZ(...@@ -2318,7 +2323,7 @@ pub fn linkatZ(
2318 .NOMEM => return error.SystemResources,2323 .NOMEM => return error.SystemResources,
2319 .NOSPC => return error.NoSpaceLeft,2324 .NOSPC => return error.NoSpaceLeft,
2320 .NOTDIR => return error.NotDir,2325 .NOTDIR => return error.NotDir,
2321 .PERM => return error.AccessDenied,2326 .PERM => return error.PermissionDenied,
2322 .ROFS => return error.ReadOnlyFileSystem,2327 .ROFS => return error.ReadOnlyFileSystem,
2323 .XDEV => return error.NotSameFileSystem,2328 .XDEV => return error.NotSameFileSystem,
2324 .INVAL => unreachable,2329 .INVAL => unreachable,
...@@ -2367,7 +2372,7 @@ pub fn linkat(...@@ -2367,7 +2372,7 @@ pub fn linkat(
2367 .NOMEM => return error.SystemResources,2372 .NOMEM => return error.SystemResources,
2368 .NOSPC => return error.NoSpaceLeft,2373 .NOSPC => return error.NoSpaceLeft,
2369 .NOTDIR => return error.NotDir,2374 .NOTDIR => return error.NotDir,
2370 .PERM => return error.AccessDenied,2375 .PERM => return error.PermissionDenied,
2371 .ROFS => return error.ReadOnlyFileSystem,2376 .ROFS => return error.ReadOnlyFileSystem,
2372 .XDEV => return error.NotSameFileSystem,2377 .XDEV => return error.NotSameFileSystem,
2373 .INVAL => unreachable,2378 .INVAL => unreachable,
...@@ -2386,6 +2391,7 @@ pub const UnlinkError = error{...@@ -2386,6 +2391,7 @@ pub const UnlinkError = error{
2386 /// In WASI, this error may occur when the file descriptor does2391 /// In WASI, this error may occur when the file descriptor does
2387 /// not hold the required rights to unlink a resource by path relative to it.2392 /// not hold the required rights to unlink a resource by path relative to it.
2388 AccessDenied,2393 AccessDenied,
2394 PermissionDenied,
2389 FileBusy,2395 FileBusy,
2390 FileSystem,2396 FileSystem,
2391 IsDir,2397 IsDir,
...@@ -2441,7 +2447,7 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void {...@@ -2441,7 +2447,7 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void {
2441 switch (errno(system.unlink(file_path))) {2447 switch (errno(system.unlink(file_path))) {
2442 .SUCCESS => return,2448 .SUCCESS => return,
2443 .ACCES => return error.AccessDenied,2449 .ACCES => return error.AccessDenied,
2444 .PERM => return error.AccessDenied,2450 .PERM => return error.PermissionDenied,
2445 .BUSY => return error.FileBusy,2451 .BUSY => return error.FileBusy,
2446 .FAULT => unreachable,2452 .FAULT => unreachable,
2447 .INVAL => unreachable,2453 .INVAL => unreachable,
...@@ -2502,7 +2508,7 @@ pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatErro...@@ -2502,7 +2508,7 @@ pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatErro
2502 switch (res) {2508 switch (res) {
2503 .SUCCESS => return,2509 .SUCCESS => return,
2504 .ACCES => return error.AccessDenied,2510 .ACCES => return error.AccessDenied,
2505 .PERM => return error.AccessDenied,2511 .PERM => return error.PermissionDenied,
2506 .BUSY => return error.FileBusy,2512 .BUSY => return error.FileBusy,
2507 .FAULT => unreachable,2513 .FAULT => unreachable,
2508 .IO => return error.FileSystem,2514 .IO => return error.FileSystem,
...@@ -2535,7 +2541,7 @@ pub fn unlinkatZ(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatEr...@@ -2535,7 +2541,7 @@ pub fn unlinkatZ(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatEr
2535 switch (errno(system.unlinkat(dirfd, file_path_c, flags))) {2541 switch (errno(system.unlinkat(dirfd, file_path_c, flags))) {
2536 .SUCCESS => return,2542 .SUCCESS => return,
2537 .ACCES => return error.AccessDenied,2543 .ACCES => return error.AccessDenied,
2538 .PERM => return error.AccessDenied,2544 .PERM => return error.PermissionDenied,
2539 .BUSY => return error.FileBusy,2545 .BUSY => return error.FileBusy,
2540 .FAULT => unreachable,2546 .FAULT => unreachable,
2541 .IO => return error.FileSystem,2547 .IO => return error.FileSystem,
...@@ -2573,6 +2579,7 @@ pub const RenameError = error{...@@ -2573,6 +2579,7 @@ pub const RenameError = error{
2573 /// On Windows, this error may be returned instead of PathAlreadyExists when2579 /// On Windows, this error may be returned instead of PathAlreadyExists when
2574 /// renaming a directory over an existing directory.2580 /// renaming a directory over an existing directory.
2575 AccessDenied,2581 AccessDenied,
2582 PermissionDenied,
2576 FileBusy,2583 FileBusy,
2577 DiskQuota,2584 DiskQuota,
2578 IsDir,2585 IsDir,
...@@ -2635,7 +2642,7 @@ pub fn renameZ(old_path: [*:0]const u8, new_path: [*:0]const u8) RenameError!voi...@@ -2635,7 +2642,7 @@ pub fn renameZ(old_path: [*:0]const u8, new_path: [*:0]const u8) RenameError!voi
2635 switch (errno(system.rename(old_path, new_path))) {2642 switch (errno(system.rename(old_path, new_path))) {
2636 .SUCCESS => return,2643 .SUCCESS => return,
2637 .ACCES => return error.AccessDenied,2644 .ACCES => return error.AccessDenied,
2638 .PERM => return error.AccessDenied,2645 .PERM => return error.PermissionDenied,
2639 .BUSY => return error.FileBusy,2646 .BUSY => return error.FileBusy,
2640 .DQUOT => return error.DiskQuota,2647 .DQUOT => return error.DiskQuota,
2641 .FAULT => unreachable,2648 .FAULT => unreachable,
...@@ -2698,7 +2705,7 @@ fn renameatWasi(old: RelativePathWasi, new: RelativePathWasi) RenameError!void {...@@ -2698,7 +2705,7 @@ fn renameatWasi(old: RelativePathWasi, new: RelativePathWasi) RenameError!void {
2698 switch (wasi.path_rename(old.dir_fd, old.relative_path.ptr, old.relative_path.len, new.dir_fd, new.relative_path.ptr, new.relative_path.len)) {2705 switch (wasi.path_rename(old.dir_fd, old.relative_path.ptr, old.relative_path.len, new.dir_fd, new.relative_path.ptr, new.relative_path.len)) {
2699 .SUCCESS => return,2706 .SUCCESS => return,
2700 .ACCES => return error.AccessDenied,2707 .ACCES => return error.AccessDenied,
2701 .PERM => return error.AccessDenied,2708 .PERM => return error.PermissionDenied,
2702 .BUSY => return error.FileBusy,2709 .BUSY => return error.FileBusy,
2703 .DQUOT => return error.DiskQuota,2710 .DQUOT => return error.DiskQuota,
2704 .FAULT => unreachable,2711 .FAULT => unreachable,
...@@ -2750,7 +2757,7 @@ pub fn renameatZ(...@@ -2750,7 +2757,7 @@ pub fn renameatZ(
2750 switch (errno(system.renameat(old_dir_fd, old_path, new_dir_fd, new_path))) {2757 switch (errno(system.renameat(old_dir_fd, old_path, new_dir_fd, new_path))) {
2751 .SUCCESS => return,2758 .SUCCESS => return,
2752 .ACCES => return error.AccessDenied,2759 .ACCES => return error.AccessDenied,
2753 .PERM => return error.AccessDenied,2760 .PERM => return error.PermissionDenied,
2754 .BUSY => return error.FileBusy,2761 .BUSY => return error.FileBusy,
2755 .DQUOT => return error.DiskQuota,2762 .DQUOT => return error.DiskQuota,
2756 .FAULT => unreachable,2763 .FAULT => unreachable,
...@@ -2903,7 +2910,7 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: mode_t) MakeDir...@@ -2903,7 +2910,7 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: mode_t) MakeDir
2903 .SUCCESS => return,2910 .SUCCESS => return,
2904 .ACCES => return error.AccessDenied,2911 .ACCES => return error.AccessDenied,
2905 .BADF => unreachable,2912 .BADF => unreachable,
2906 .PERM => return error.AccessDenied,2913 .PERM => return error.PermissionDenied,
2907 .DQUOT => return error.DiskQuota,2914 .DQUOT => return error.DiskQuota,
2908 .EXIST => return error.PathAlreadyExists,2915 .EXIST => return error.PathAlreadyExists,
2909 .FAULT => unreachable,2916 .FAULT => unreachable,
...@@ -2933,7 +2940,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: mode_t) MakeDir...@@ -2933,7 +2940,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: mode_t) MakeDir
2933 .SUCCESS => return,2940 .SUCCESS => return,
2934 .ACCES => return error.AccessDenied,2941 .ACCES => return error.AccessDenied,
2935 .BADF => unreachable,2942 .BADF => unreachable,
2936 .PERM => return error.AccessDenied,2943 .PERM => return error.PermissionDenied,
2937 .DQUOT => return error.DiskQuota,2944 .DQUOT => return error.DiskQuota,
2938 .EXIST => return error.PathAlreadyExists,2945 .EXIST => return error.PathAlreadyExists,
2939 .FAULT => unreachable,2946 .FAULT => unreachable,
...@@ -2978,6 +2985,7 @@ pub const MakeDirError = error{...@@ -2978,6 +2985,7 @@ pub const MakeDirError = error{
2978 /// In WASI, this error may occur when the file descriptor does2985 /// In WASI, this error may occur when the file descriptor does
2979 /// not hold the required rights to create a new directory relative to it.2986 /// not hold the required rights to create a new directory relative to it.
2980 AccessDenied,2987 AccessDenied,
2988 PermissionDenied,
2981 DiskQuota,2989 DiskQuota,
2982 PathAlreadyExists,2990 PathAlreadyExists,
2983 SymLinkLoop,2991 SymLinkLoop,
...@@ -3030,7 +3038,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: mode_t) MakeDirError!void {...@@ -3030,7 +3038,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: mode_t) MakeDirError!void {
3030 switch (errno(system.mkdir(dir_path, mode))) {3038 switch (errno(system.mkdir(dir_path, mode))) {
3031 .SUCCESS => return,3039 .SUCCESS => return,
3032 .ACCES => return error.AccessDenied,3040 .ACCES => return error.AccessDenied,
3033 .PERM => return error.AccessDenied,3041 .PERM => return error.PermissionDenied,
3034 .DQUOT => return error.DiskQuota,3042 .DQUOT => return error.DiskQuota,
3035 .EXIST => return error.PathAlreadyExists,3043 .EXIST => return error.PathAlreadyExists,
3036 .FAULT => unreachable,3044 .FAULT => unreachable,
...@@ -3071,6 +3079,7 @@ pub fn mkdirW(dir_path_w: []const u16, mode: mode_t) MakeDirError!void {...@@ -3071,6 +3079,7 @@ pub fn mkdirW(dir_path_w: []const u16, mode: mode_t) MakeDirError!void {
30713079
3072pub const DeleteDirError = error{3080pub const DeleteDirError = error{
3073 AccessDenied,3081 AccessDenied,
3082 PermissionDenied,
3074 FileBusy,3083 FileBusy,
3075 SymLinkLoop,3084 SymLinkLoop,
3076 NameTooLong,3085 NameTooLong,
...@@ -3123,7 +3132,7 @@ pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void {...@@ -3123,7 +3132,7 @@ pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void {
3123 switch (errno(system.rmdir(dir_path))) {3132 switch (errno(system.rmdir(dir_path))) {
3124 .SUCCESS => return,3133 .SUCCESS => return,
3125 .ACCES => return error.AccessDenied,3134 .ACCES => return error.AccessDenied,
3126 .PERM => return error.AccessDenied,3135 .PERM => return error.PermissionDenied,
3127 .BUSY => return error.FileBusy,3136 .BUSY => return error.FileBusy,
3128 .FAULT => unreachable,3137 .FAULT => unreachable,
3129 .INVAL => return error.BadPathName,3138 .INVAL => return error.BadPathName,
...@@ -3254,6 +3263,7 @@ pub const ReadLinkError = error{...@@ -3254,6 +3263,7 @@ pub const ReadLinkError = error{
3254 /// In WASI, this error may occur when the file descriptor does3263 /// In WASI, this error may occur when the file descriptor does
3255 /// not hold the required rights to read value of a symbolic link relative to it.3264 /// not hold the required rights to read value of a symbolic link relative to it.
3256 AccessDenied,3265 AccessDenied,
3266 PermissionDenied,
3257 FileSystem,3267 FileSystem,
3258 SymLinkLoop,3268 SymLinkLoop,
3259 NameTooLong,3269 NameTooLong,
...@@ -3534,7 +3544,7 @@ pub fn isatty(handle: fd_t) bool {...@@ -3534,7 +3544,7 @@ pub fn isatty(handle: fd_t) bool {
3534pub const SocketError = error{3544pub const SocketError = error{
3535 /// Permission to create a socket of the specified type and/or3545 /// Permission to create a socket of the specified type and/or
3536 /// pro‐tocol is denied.3546 /// pro‐tocol is denied.
3537 PermissionDenied,3547 AccessDenied,
35383548
3539 /// The implementation does not support the specified address family.3549 /// The implementation does not support the specified address family.
3540 AddressFamilyNotSupported,3550 AddressFamilyNotSupported,
...@@ -3604,7 +3614,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t...@@ -3604,7 +3614,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
3604 }3614 }
3605 return fd;3615 return fd;
3606 },3616 },
3607 .ACCES => return error.PermissionDenied,3617 .ACCES => return error.AccessDenied,
3608 .AFNOSUPPORT => return error.AddressFamilyNotSupported,3618 .AFNOSUPPORT => return error.AddressFamilyNotSupported,
3609 .INVAL => return error.ProtocolFamilyNotAvailable,3619 .INVAL => return error.ProtocolFamilyNotAvailable,
3610 .MFILE => return error.ProcessFdQuotaExceeded,3620 .MFILE => return error.ProcessFdQuotaExceeded,
...@@ -4188,6 +4198,9 @@ pub const ConnectError = error{...@@ -4188,6 +4198,9 @@ pub const ConnectError = error{
4188 /// or4198 /// or
4189 /// The user tried to connect to a broadcast address without having the socket broadcast flag enabled or4199 /// The user tried to connect to a broadcast address without having the socket broadcast flag enabled or
4190 /// the connection request failed because of a local firewall rule.4200 /// the connection request failed because of a local firewall rule.
4201 AccessDenied,
4202
4203 /// See AccessDenied
4191 PermissionDenied,4204 PermissionDenied,
41924205
4193 /// Local address is already in use.4206 /// Local address is already in use.
...@@ -4261,7 +4274,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne...@@ -4261,7 +4274,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
4261 while (true) {4274 while (true) {
4262 switch (errno(system.connect(sock, sock_addr, len))) {4275 switch (errno(system.connect(sock, sock_addr, len))) {
4263 .SUCCESS => return,4276 .SUCCESS => return,
4264 .ACCES => return error.PermissionDenied,4277 .ACCES => return error.AccessDenied,
4265 .PERM => return error.PermissionDenied,4278 .PERM => return error.PermissionDenied,
4266 .ADDRINUSE => return error.AddressInUse,4279 .ADDRINUSE => return error.AddressInUse,
4267 .ADDRNOTAVAIL => return error.AddressNotAvailable,4280 .ADDRNOTAVAIL => return error.AddressNotAvailable,
...@@ -4323,7 +4336,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {...@@ -4323,7 +4336,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
4323 switch (errno(rc)) {4336 switch (errno(rc)) {
4324 .SUCCESS => switch (@as(E, @enumFromInt(err_code))) {4337 .SUCCESS => switch (@as(E, @enumFromInt(err_code))) {
4325 .SUCCESS => return,4338 .SUCCESS => return,
4326 .ACCES => return error.PermissionDenied,4339 .ACCES => return error.AccessDenied,
4327 .PERM => return error.PermissionDenied,4340 .PERM => return error.PermissionDenied,
4328 .ADDRINUSE => return error.AddressInUse,4341 .ADDRINUSE => return error.AddressInUse,
4329 .ADDRNOTAVAIL => return error.AddressNotAvailable,4342 .ADDRNOTAVAIL => return error.AddressNotAvailable,
...@@ -4398,6 +4411,7 @@ pub const FStatError = error{...@@ -4398,6 +4411,7 @@ pub const FStatError = error{
4398 /// In WASI, this error may occur when the file descriptor does4411 /// In WASI, this error may occur when the file descriptor does
4399 /// not hold the required rights to get its filestat information.4412 /// not hold the required rights to get its filestat information.
4400 AccessDenied,4413 AccessDenied,
4414 PermissionDenied,
4401} || UnexpectedError;4415} || UnexpectedError;
44024416
4403/// Return information about a file descriptor.4417/// Return information about a file descriptor.
...@@ -4466,7 +4480,7 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S...@@ -4466,7 +4480,7 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S
4466 .BADF => unreachable, // Always a race condition.4480 .BADF => unreachable, // Always a race condition.
4467 .NOMEM => return error.SystemResources,4481 .NOMEM => return error.SystemResources,
4468 .ACCES => return error.AccessDenied,4482 .ACCES => return error.AccessDenied,
4469 .PERM => return error.AccessDenied,4483 .PERM => return error.PermissionDenied,
4470 .FAULT => unreachable,4484 .FAULT => unreachable,
4471 .NAMETOOLONG => return error.NameTooLong,4485 .NAMETOOLONG => return error.NameTooLong,
4472 .LOOP => return error.SymLinkLoop,4486 .LOOP => return error.SymLinkLoop,
...@@ -4870,6 +4884,7 @@ pub fn msync(memory: []align(page_size_min) u8, flags: i32) MSyncError!void {...@@ -4870,6 +4884,7 @@ pub fn msync(memory: []align(page_size_min) u8, flags: i32) MSyncError!void {
4870}4884}
48714885
4872pub const AccessError = error{4886pub const AccessError = error{
4887 AccessDenied,
4873 PermissionDenied,4888 PermissionDenied,
4874 FileNotFound,4889 FileNotFound,
4875 NameTooLong,4890 NameTooLong,
...@@ -4896,10 +4911,7 @@ pub const AccessError = error{...@@ -4896,10 +4911,7 @@ pub const AccessError = error{
4896/// Windows. See `fs` for the cross-platform file system API.4911/// Windows. See `fs` for the cross-platform file system API.
4897pub fn access(path: []const u8, mode: u32) AccessError!void {4912pub fn access(path: []const u8, mode: u32) AccessError!void {
4898 if (native_os == .windows) {4913 if (native_os == .windows) {
4899 const path_w = windows.sliceToPrefixedFileW(null, path) catch |err| switch (err) {4914 const path_w = try windows.sliceToPrefixedFileW(null, path);
4900 error.AccessDenied => return error.PermissionDenied,
4901 else => |e| return e,
4902 };
4903 _ = try windows.GetFileAttributesW(path_w.span().ptr);4915 _ = try windows.GetFileAttributesW(path_w.span().ptr);
4904 return;4916 return;
4905 } else if (native_os == .wasi and !builtin.link_libc) {4917 } else if (native_os == .wasi and !builtin.link_libc) {
...@@ -4912,10 +4924,7 @@ pub fn access(path: []const u8, mode: u32) AccessError!void {...@@ -4912,10 +4924,7 @@ pub fn access(path: []const u8, mode: u32) AccessError!void {
4912/// Same as `access` except `path` is null-terminated.4924/// Same as `access` except `path` is null-terminated.
4913pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {4925pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {
4914 if (native_os == .windows) {4926 if (native_os == .windows) {
4915 const path_w = windows.cStrToPrefixedFileW(null, path) catch |err| switch (err) {4927 const path_w = try windows.cStrToPrefixedFileW(null, path);
4916 error.AccessDenied => return error.PermissionDenied,
4917 else => |e| return e,
4918 };
4919 _ = try windows.GetFileAttributesW(path_w.span().ptr);4928 _ = try windows.GetFileAttributesW(path_w.span().ptr);
4920 return;4929 return;
4921 } else if (native_os == .wasi and !builtin.link_libc) {4930 } else if (native_os == .wasi and !builtin.link_libc) {
...@@ -4923,7 +4932,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {...@@ -4923,7 +4932,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {
4923 }4932 }
4924 switch (errno(system.access(path, mode))) {4933 switch (errno(system.access(path, mode))) {
4925 .SUCCESS => return,4934 .SUCCESS => return,
4926 .ACCES => return error.PermissionDenied,4935 .ACCES => return error.AccessDenied,
4927 .PERM => return error.PermissionDenied,4936 .PERM => return error.PermissionDenied,
4928 .ROFS => return error.ReadOnlyFileSystem,4937 .ROFS => return error.ReadOnlyFileSystem,
4929 .LOOP => return error.SymLinkLoop,4938 .LOOP => return error.SymLinkLoop,
...@@ -4958,19 +4967,14 @@ pub fn faccessat(dirfd: fd_t, path: []const u8, mode: u32, flags: u32) AccessErr...@@ -4958,19 +4967,14 @@ pub fn faccessat(dirfd: fd_t, path: []const u8, mode: u32, flags: u32) AccessErr
4958 } else if (native_os == .wasi and !builtin.link_libc) {4967 } else if (native_os == .wasi and !builtin.link_libc) {
4959 const resolved: RelativePathWasi = .{ .dir_fd = dirfd, .relative_path = path };4968 const resolved: RelativePathWasi = .{ .dir_fd = dirfd, .relative_path = path };
49604969
4961 const st = blk: {4970 const st = try std.os.fstatat_wasi(dirfd, path, .{
4962 break :blk std.os.fstatat_wasi(dirfd, path, .{4971 .SYMLINK_FOLLOW = (flags & AT.SYMLINK_NOFOLLOW) == 0,
4963 .SYMLINK_FOLLOW = (flags & AT.SYMLINK_NOFOLLOW) == 0,4972 });
4964 });
4965 } catch |err| switch (err) {
4966 error.AccessDenied => return error.PermissionDenied,
4967 else => |e| return e,
4968 };
49694973
4970 if (mode != F_OK) {4974 if (mode != F_OK) {
4971 var directory: wasi.fdstat_t = undefined;4975 var directory: wasi.fdstat_t = undefined;
4972 if (wasi.fd_fdstat_get(resolved.dir_fd, &directory) != .SUCCESS) {4976 if (wasi.fd_fdstat_get(resolved.dir_fd, &directory) != .SUCCESS) {
4973 return error.PermissionDenied;4977 return error.AccessDenied;
4974 }4978 }
49754979
4976 var rights: wasi.rights_t = .{};4980 var rights: wasi.rights_t = .{};
...@@ -4990,7 +4994,7 @@ pub fn faccessat(dirfd: fd_t, path: []const u8, mode: u32, flags: u32) AccessErr...@@ -4990,7 +4994,7 @@ pub fn faccessat(dirfd: fd_t, path: []const u8, mode: u32, flags: u32) AccessErr
4990 const rights_int: u64 = @bitCast(rights);4994 const rights_int: u64 = @bitCast(rights);
4991 const inheriting_int: u64 = @bitCast(directory.fs_rights_inheriting);4995 const inheriting_int: u64 = @bitCast(directory.fs_rights_inheriting);
4992 if ((rights_int & inheriting_int) != rights_int) {4996 if ((rights_int & inheriting_int) != rights_int) {
4993 return error.PermissionDenied;4997 return error.AccessDenied;
4994 }4998 }
4995 }4999 }
4996 return;5000 return;
...@@ -5009,7 +5013,7 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces...@@ -5009,7 +5013,7 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces
5009 }5013 }
5010 switch (errno(system.faccessat(dirfd, path, mode, flags))) {5014 switch (errno(system.faccessat(dirfd, path, mode, flags))) {
5011 .SUCCESS => return,5015 .SUCCESS => return,
5012 .ACCES => return error.PermissionDenied,5016 .ACCES => return error.AccessDenied,
5013 .PERM => return error.PermissionDenied,5017 .PERM => return error.PermissionDenied,
5014 .ROFS => return error.ReadOnlyFileSystem,5018 .ROFS => return error.ReadOnlyFileSystem,
5015 .LOOP => return error.SymLinkLoop,5019 .LOOP => return error.SymLinkLoop,
...@@ -5060,7 +5064,7 @@ pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16) AccessError!void {...@@ -5060,7 +5064,7 @@ pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16) AccessError!void {
5060 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,5064 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
5061 .OBJECT_NAME_INVALID => unreachable,5065 .OBJECT_NAME_INVALID => unreachable,
5062 .INVALID_PARAMETER => unreachable,5066 .INVALID_PARAMETER => unreachable,
5063 .ACCESS_DENIED => return error.PermissionDenied,5067 .ACCESS_DENIED => return error.AccessDenied,
5064 .OBJECT_PATH_SYNTAX_BAD => unreachable,5068 .OBJECT_PATH_SYNTAX_BAD => unreachable,
5065 else => |rc| return windows.unexpectedStatus(rc),5069 else => |rc| return windows.unexpectedStatus(rc),
5066 }5070 }
...@@ -5442,6 +5446,7 @@ pub fn flock(fd: fd_t, operation: i32) FlockError!void {...@@ -5442,6 +5446,7 @@ pub fn flock(fd: fd_t, operation: i32) FlockError!void {
5442pub const RealPathError = error{5446pub const RealPathError = error{
5443 FileNotFound,5447 FileNotFound,
5444 AccessDenied,5448 AccessDenied,
5449 PermissionDenied,
5445 NameTooLong,5450 NameTooLong,
5446 NotSupported,5451 NotSupported,
5447 NotDir,5452 NotDir,
...@@ -6823,7 +6828,7 @@ pub const SetSockOptError = error{...@@ -6823,7 +6828,7 @@ pub const SetSockOptError = error{
6823 /// Insufficient resources are available in the system to complete the call.6828 /// Insufficient resources are available in the system to complete the call.
6824 SystemResources,6829 SystemResources,
68256830
6826 // Setting the socket option requires more elevated permissions.6831 /// Setting the socket option requires more elevated permissions.
6827 PermissionDenied,6832 PermissionDenied,
68286833
6829 OperationNotSupported,6834 OperationNotSupported,
...@@ -7318,7 +7323,7 @@ pub fn perf_event_open(...@@ -7318,7 +7323,7 @@ pub fn perf_event_open(
7318}7323}
73197324
7320pub const TimerFdCreateError = error{7325pub const TimerFdCreateError = error{
7321 AccessDenied,7326 PermissionDenied,
7322 ProcessFdQuotaExceeded,7327 ProcessFdQuotaExceeded,
7323 SystemFdQuotaExceeded,7328 SystemFdQuotaExceeded,
7324 NoDevice,7329 NoDevice,
...@@ -7337,7 +7342,7 @@ pub fn timerfd_create(clock_id: system.timerfd_clockid_t, flags: system.TFD) Tim...@@ -7337,7 +7342,7 @@ pub fn timerfd_create(clock_id: system.timerfd_clockid_t, flags: system.TFD) Tim
7337 .NFILE => return error.SystemFdQuotaExceeded,7342 .NFILE => return error.SystemFdQuotaExceeded,
7338 .NODEV => return error.NoDevice,7343 .NODEV => return error.NoDevice,
7339 .NOMEM => return error.SystemResources,7344 .NOMEM => return error.SystemResources,
7340 .PERM => return error.AccessDenied,7345 .PERM => return error.PermissionDenied,
7341 else => |err| return unexpectedErrno(err),7346 else => |err| return unexpectedErrno(err),
7342 };7347 };
7343}7348}
lib/std/process/Child.zig+1-1
...@@ -269,7 +269,7 @@ pub fn killWindows(self: *ChildProcess, exit_code: windows.UINT) !Term {...@@ -269,7 +269,7 @@ pub fn killWindows(self: *ChildProcess, exit_code: windows.UINT) !Term {
269 }269 }
270270
271 windows.TerminateProcess(self.id, exit_code) catch |err| switch (err) {271 windows.TerminateProcess(self.id, exit_code) catch |err| switch (err) {
272 error.PermissionDenied => {272 error.AccessDenied => {
273 // Usually when TerminateProcess triggers a ACCESS_DENIED error, it273 // Usually when TerminateProcess triggers a ACCESS_DENIED error, it
274 // indicates that the process has already exited, but there may be274 // indicates that the process has already exited, but there may be
275 // some rare edge cases where our process handle no longer has the275 // some rare edge cases where our process handle no longer has the
lib/std/zig/system.zig+4
...@@ -731,6 +731,7 @@ pub fn abiAndDynamicLinkerFromFile(...@@ -731,6 +731,7 @@ pub fn abiAndDynamicLinkerFromFile(
731 error.NetworkNotFound => unreachable, // Windows only731 error.NetworkNotFound => unreachable, // Windows only
732732
733 error.AccessDenied,733 error.AccessDenied,
734 error.PermissionDenied,
734 error.FileNotFound,735 error.FileNotFound,
735 error.NotLink,736 error.NotLink,
736 error.NotDir,737 error.NotDir,
...@@ -825,6 +826,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {...@@ -825,6 +826,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
825 error.FileNotFound,826 error.FileNotFound,
826 error.NotDir,827 error.NotDir,
827 error.AccessDenied,828 error.AccessDenied,
829 error.PermissionDenied,
828 error.NoDevice,830 error.NoDevice,
829 => return error.GLibCNotFound,831 => return error.GLibCNotFound,
830832
...@@ -863,6 +865,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {...@@ -863,6 +865,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
863 error.NoDevice => unreachable, // not asking for a special device865 error.NoDevice => unreachable, // not asking for a special device
864866
865 error.AccessDenied,867 error.AccessDenied,
868 error.PermissionDenied,
866 error.FileNotFound,869 error.FileNotFound,
867 error.NotDir,870 error.NotDir,
868 error.IsDir,871 error.IsDir,
...@@ -1122,6 +1125,7 @@ fn detectAbiAndDynamicLinker(...@@ -1122,6 +1125,7 @@ fn detectAbiAndDynamicLinker(
1122 error.IsDir,1125 error.IsDir,
1123 error.NotDir,1126 error.NotDir,
1124 error.AccessDenied,1127 error.AccessDenied,
1128 error.PermissionDenied,
1125 error.NoDevice,1129 error.NoDevice,
1126 error.FileNotFound,1130 error.FileNotFound,
1127 error.NetworkNotFound,1131 error.NetworkNotFound,
src/DarwinPosixSpawn.zig+2-1
...@@ -6,6 +6,7 @@ pub const Error = error{...@@ -6,6 +6,7 @@ pub const Error = error{
6 InvalidFileDescriptor,6 InvalidFileDescriptor,
7 NameTooLong,7 NameTooLong,
8 TooBig,8 TooBig,
9 AccessDenied,
9 PermissionDenied,10 PermissionDenied,
10 InputOutput,11 InputOutput,
11 FileSystem,12 FileSystem,
...@@ -188,7 +189,7 @@ pub fn spawnZ(...@@ -188,7 +189,7 @@ pub fn spawnZ(
188 .@"2BIG" => return error.TooBig,189 .@"2BIG" => return error.TooBig,
189 .NOMEM => return error.SystemResources,190 .NOMEM => return error.SystemResources,
190 .BADF => return error.InvalidFileDescriptor,191 .BADF => return error.InvalidFileDescriptor,
191 .ACCES => return error.PermissionDenied,192 .ACCES => return error.AccessDenied,
192 .IO => return error.InputOutput,193 .IO => return error.InputOutput,
193 .LOOP => return error.FileSystem,194 .LOOP => return error.FileSystem,
194 .NAMETOOLONG => return error.NameTooLong,195 .NAMETOOLONG => return error.NameTooLong,