| ... | @@ -301,9 +301,9 @@ pub const ReadError = error{ | ... | @@ -301,9 +301,9 @@ pub const ReadError = error{ |
| 301 | /// and reading from the file descriptor would block. | 301 | /// and reading from the file descriptor would block. |
| 302 | WouldBlock, | 302 | WouldBlock, |
| 303 | | 303 | |
| 304 | /// WASI-only. This error occurs when the file descriptor does | 304 | /// In WASI, this error occurs when the file descriptor does |
| 305 | /// not hold the required rights to read from it. | 305 | /// not hold the required rights to read from it. |
| 306 | NotCapable, | 306 | AccessDenied, |
| 307 | } || UnexpectedError; | 307 | } || UnexpectedError; |
| 308 | | 308 | |
| 309 | /// Returns the number of bytes that were read, which can be less than | 309 | /// Returns the number of bytes that were read, which can be less than |
| ... | @@ -339,7 +339,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { | ... | @@ -339,7 +339,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 339 | wasi.ENOMEM => return error.SystemResources, | 339 | wasi.ENOMEM => return error.SystemResources, |
| 340 | wasi.ECONNRESET => return error.ConnectionResetByPeer, | 340 | wasi.ECONNRESET => return error.ConnectionResetByPeer, |
| 341 | wasi.ETIMEDOUT => return error.ConnectionTimedOut, | 341 | wasi.ETIMEDOUT => return error.ConnectionTimedOut, |
| 342 | wasi.ENOTCAPABLE => return error.NotCapable, | 342 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 343 | else => |err| return unexpectedErrno(err), | 343 | else => |err| return unexpectedErrno(err), |
| 344 | } | 344 | } |
| 345 | } | 345 | } |
| ... | @@ -407,7 +407,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { | ... | @@ -407,7 +407,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 407 | wasi.EISDIR => return error.IsDir, | 407 | wasi.EISDIR => return error.IsDir, |
| 408 | wasi.ENOBUFS => return error.SystemResources, | 408 | wasi.ENOBUFS => return error.SystemResources, |
| 409 | wasi.ENOMEM => return error.SystemResources, | 409 | wasi.ENOMEM => return error.SystemResources, |
| 410 | wasi.ENOTCAPABLE => return error.NotCapable, | 410 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 411 | else => |err| return unexpectedErrno(err), | 411 | else => |err| return unexpectedErrno(err), |
| 412 | } | 412 | } |
| 413 | } | 413 | } |
| ... | @@ -472,7 +472,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { | ... | @@ -472,7 +472,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 472 | wasi.ENXIO => return error.Unseekable, | 472 | wasi.ENXIO => return error.Unseekable, |
| 473 | wasi.ESPIPE => return error.Unseekable, | 473 | wasi.ESPIPE => return error.Unseekable, |
| 474 | wasi.EOVERFLOW => return error.Unseekable, | 474 | wasi.EOVERFLOW => return error.Unseekable, |
| 475 | wasi.ENOTCAPABLE => return error.NotCapable, | 475 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 476 | else => |err| return unexpectedErrno(err), | 476 | else => |err| return unexpectedErrno(err), |
| 477 | } | 477 | } |
| 478 | } | 478 | } |
| ... | @@ -507,12 +507,11 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { | ... | @@ -507,12 +507,11 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 507 | pub const TruncateError = error{ | 507 | pub const TruncateError = error{ |
| 508 | FileTooBig, | 508 | FileTooBig, |
| 509 | InputOutput, | 509 | InputOutput, |
| 510 | CannotTruncate, | | |
| 511 | FileBusy, | 510 | FileBusy, |
| 512 | | 511 | |
| 513 | /// WASI-only. This error occurs when the file descriptor does | 512 | /// In WASI, this error occurs when the file descriptor does |
| 514 | /// not hold the required rights to call `ftruncate` on it. | 513 | /// not hold the required rights to call `ftruncate` on it. |
| 515 | NotCapable, | 514 | AccessDenied, |
| 516 | } || UnexpectedError; | 515 | } || UnexpectedError; |
| 517 | | 516 | |
| 518 | pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { | 517 | pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| ... | @@ -533,7 +532,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { | ... | @@ -533,7 +532,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 533 | switch (rc) { | 532 | switch (rc) { |
| 534 | .SUCCESS => return, | 533 | .SUCCESS => return, |
| 535 | .INVALID_HANDLE => unreachable, // Handle not open for writing | 534 | .INVALID_HANDLE => unreachable, // Handle not open for writing |
| 536 | .ACCESS_DENIED => return error.CannotTruncate, | 535 | .ACCESS_DENIED => return error.AccessDenied, |
| 537 | else => return windows.unexpectedStatus(rc), | 536 | else => return windows.unexpectedStatus(rc), |
| 538 | } | 537 | } |
| 539 | } | 538 | } |
| ... | @@ -543,11 +542,11 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { | ... | @@ -543,11 +542,11 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 543 | wasi.EINTR => unreachable, | 542 | wasi.EINTR => unreachable, |
| 544 | wasi.EFBIG => return error.FileTooBig, | 543 | wasi.EFBIG => return error.FileTooBig, |
| 545 | wasi.EIO => return error.InputOutput, | 544 | wasi.EIO => return error.InputOutput, |
| 546 | wasi.EPERM => return error.CannotTruncate, | 545 | wasi.EPERM => return error.AccessDenied, |
| 547 | wasi.ETXTBSY => return error.FileBusy, | 546 | wasi.ETXTBSY => return error.FileBusy, |
| 548 | wasi.EBADF => unreachable, // Handle not open for writing | 547 | wasi.EBADF => unreachable, // Handle not open for writing |
| 549 | wasi.EINVAL => unreachable, // Handle not open for writing | 548 | wasi.EINVAL => unreachable, // Handle not open for writing |
| 550 | wasi.ENOTCAPABLE => return error.NotCapable, | 549 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 551 | else => |err| return unexpectedErrno(err), | 550 | else => |err| return unexpectedErrno(err), |
| 552 | } | 551 | } |
| 553 | } | 552 | } |
| ... | @@ -566,7 +565,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { | ... | @@ -566,7 +565,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 566 | EINTR => continue, | 565 | EINTR => continue, |
| 567 | EFBIG => return error.FileTooBig, | 566 | EFBIG => return error.FileTooBig, |
| 568 | EIO => return error.InputOutput, | 567 | EIO => return error.InputOutput, |
| 569 | EPERM => return error.CannotTruncate, | 568 | EPERM => return error.AccessDenied, |
| 570 | ETXTBSY => return error.FileBusy, | 569 | ETXTBSY => return error.FileBusy, |
| 571 | EBADF => unreachable, // Handle not open for writing | 570 | EBADF => unreachable, // Handle not open for writing |
| 572 | EINVAL => unreachable, // Handle not open for writing | 571 | EINVAL => unreachable, // Handle not open for writing |
| ... | @@ -616,7 +615,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { | ... | @@ -616,7 +615,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 616 | wasi.ENXIO => return error.Unseekable, | 615 | wasi.ENXIO => return error.Unseekable, |
| 617 | wasi.ESPIPE => return error.Unseekable, | 616 | wasi.ESPIPE => return error.Unseekable, |
| 618 | wasi.EOVERFLOW => return error.Unseekable, | 617 | wasi.EOVERFLOW => return error.Unseekable, |
| 619 | wasi.ENOTCAPABLE => return error.NotCapable, | 618 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 620 | else => |err| return unexpectedErrno(err), | 619 | else => |err| return unexpectedErrno(err), |
| 621 | } | 620 | } |
| 622 | } | 621 | } |
| ... | @@ -654,6 +653,9 @@ pub const WriteError = error{ | ... | @@ -654,6 +653,9 @@ pub const WriteError = error{ |
| 654 | FileTooBig, | 653 | FileTooBig, |
| 655 | InputOutput, | 654 | InputOutput, |
| 656 | NoSpaceLeft, | 655 | NoSpaceLeft, |
| | 656 | |
| | 657 | /// In WASI, this error may occur when the file descriptor does |
| | 658 | /// not hold the required rights to write to it. |
| 657 | AccessDenied, | 659 | AccessDenied, |
| 658 | BrokenPipe, | 660 | BrokenPipe, |
| 659 | SystemResources, | 661 | SystemResources, |
| ... | @@ -662,10 +664,6 @@ pub const WriteError = error{ | ... | @@ -662,10 +664,6 @@ pub const WriteError = error{ |
| 662 | /// This error occurs when no global event loop is configured, | 664 | /// This error occurs when no global event loop is configured, |
| 663 | /// and reading from the file descriptor would block. | 665 | /// and reading from the file descriptor would block. |
| 664 | WouldBlock, | 666 | WouldBlock, |
| 665 | | | |
| 666 | /// WASI-only. This error occurs when the file descriptor does | | |
| 667 | /// not hold the required rights to write to it. | | |
| 668 | NotCapable, | | |
| 669 | } || UnexpectedError; | 667 | } || UnexpectedError; |
| 670 | | 668 | |
| 671 | /// Write to a file descriptor. | 669 | /// Write to a file descriptor. |
| ... | @@ -714,7 +712,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { | ... | @@ -714,7 +712,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 714 | wasi.ENOSPC => return error.NoSpaceLeft, | 712 | wasi.ENOSPC => return error.NoSpaceLeft, |
| 715 | wasi.EPERM => return error.AccessDenied, | 713 | wasi.EPERM => return error.AccessDenied, |
| 716 | wasi.EPIPE => return error.BrokenPipe, | 714 | wasi.EPIPE => return error.BrokenPipe, |
| 717 | wasi.ENOTCAPABLE => return error.NotCapable, | 715 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 718 | else => |err| return unexpectedErrno(err), | 716 | else => |err| return unexpectedErrno(err), |
| 719 | } | 717 | } |
| 720 | } | 718 | } |
| ... | @@ -792,7 +790,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { | ... | @@ -792,7 +790,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { |
| 792 | wasi.ENOSPC => return error.NoSpaceLeft, | 790 | wasi.ENOSPC => return error.NoSpaceLeft, |
| 793 | wasi.EPERM => return error.AccessDenied, | 791 | wasi.EPERM => return error.AccessDenied, |
| 794 | wasi.EPIPE => return error.BrokenPipe, | 792 | wasi.EPIPE => return error.BrokenPipe, |
| 795 | wasi.ENOTCAPABLE => return error.NotCapable, | 793 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 796 | else => |err| return unexpectedErrno(err), | 794 | else => |err| return unexpectedErrno(err), |
| 797 | } | 795 | } |
| 798 | } | 796 | } |
| ... | @@ -875,7 +873,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { | ... | @@ -875,7 +873,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 875 | wasi.ENXIO => return error.Unseekable, | 873 | wasi.ENXIO => return error.Unseekable, |
| 876 | wasi.ESPIPE => return error.Unseekable, | 874 | wasi.ESPIPE => return error.Unseekable, |
| 877 | wasi.EOVERFLOW => return error.Unseekable, | 875 | wasi.EOVERFLOW => return error.Unseekable, |
| 878 | wasi.ENOTCAPABLE => return error.NotCapable, | 876 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 879 | else => |err| return unexpectedErrno(err), | 877 | else => |err| return unexpectedErrno(err), |
| 880 | } | 878 | } |
| 881 | } | 879 | } |
| ... | @@ -969,7 +967,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz | ... | @@ -969,7 +967,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 969 | wasi.ENXIO => return error.Unseekable, | 967 | wasi.ENXIO => return error.Unseekable, |
| 970 | wasi.ESPIPE => return error.Unseekable, | 968 | wasi.ESPIPE => return error.Unseekable, |
| 971 | wasi.EOVERFLOW => return error.Unseekable, | 969 | wasi.EOVERFLOW => return error.Unseekable, |
| 972 | wasi.ENOTCAPABLE => return error.NotCapable, | 970 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 973 | else => |err| return unexpectedErrno(err), | 971 | else => |err| return unexpectedErrno(err), |
| 974 | } | 972 | } |
| 975 | } | 973 | } |
| ... | @@ -1005,6 +1003,8 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz | ... | @@ -1005,6 +1003,8 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 1005 | } | 1003 | } |
| 1006 | | 1004 | |
| 1007 | pub const OpenError = error{ | 1005 | pub const OpenError = error{ |
| | 1006 | /// In WASI, this error may occur when the file descriptor does |
| | 1007 | /// not hold the required rights to open a new resource relative to it. |
| 1008 | AccessDenied, | 1008 | AccessDenied, |
| 1009 | SymLinkLoop, | 1009 | SymLinkLoop, |
| 1010 | ProcessFdQuotaExceeded, | 1010 | ProcessFdQuotaExceeded, |
| ... | @@ -1041,10 +1041,6 @@ pub const OpenError = error{ | ... | @@ -1041,10 +1041,6 @@ pub const OpenError = error{ |
| 1041 | | 1041 | |
| 1042 | /// The underlying filesystem does not support file locks | 1042 | /// The underlying filesystem does not support file locks |
| 1043 | FileLocksNotSupported, | 1043 | FileLocksNotSupported, |
| 1044 | | | |
| 1045 | /// WASI-only. This error occurs when the file descriptor does | | |
| 1046 | /// not hold the required rights to open a new resource relative to it. | | |
| 1047 | NotCapable, | | |
| 1048 | } || UnexpectedError; | 1044 | } || UnexpectedError; |
| 1049 | | 1045 | |
| 1050 | /// Open and possibly create a file. Keeps trying if it gets interrupted. | 1046 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| ... | @@ -1138,7 +1134,7 @@ pub fn openatWasi(dir_fd: fd_t, file_path: []const u8, oflags: oflags_t, fdflags | ... | @@ -1138,7 +1134,7 @@ pub fn openatWasi(dir_fd: fd_t, file_path: []const u8, oflags: oflags_t, fdflags |
| 1138 | wasi.EPERM => return error.AccessDenied, | 1134 | wasi.EPERM => return error.AccessDenied, |
| 1139 | wasi.EEXIST => return error.PathAlreadyExists, | 1135 | wasi.EEXIST => return error.PathAlreadyExists, |
| 1140 | wasi.EBUSY => return error.DeviceBusy, | 1136 | wasi.EBUSY => return error.DeviceBusy, |
| 1141 | wasi.ENOTCAPABLE => return error.NotCapable, | 1137 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 1142 | else => |err| return unexpectedErrno(err), | 1138 | else => |err| return unexpectedErrno(err), |
| 1143 | } | 1139 | } |
| 1144 | } | 1140 | } |
| ... | @@ -1525,6 +1521,8 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { | ... | @@ -1525,6 +1521,8 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { |
| 1525 | } | 1521 | } |
| 1526 | | 1522 | |
| 1527 | pub const SymLinkError = error{ | 1523 | pub const SymLinkError = error{ |
| | 1524 | /// In WASI, this error may occur when the file descriptor does |
| | 1525 | /// not hold the required rights to create a new symbolic link relative to it. |
| 1528 | AccessDenied, | 1526 | AccessDenied, |
| 1529 | DiskQuota, | 1527 | DiskQuota, |
| 1530 | PathAlreadyExists, | 1528 | PathAlreadyExists, |
| ... | @@ -1589,19 +1587,13 @@ pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin | ... | @@ -1589,19 +1587,13 @@ pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin |
| 1589 | } | 1587 | } |
| 1590 | } | 1588 | } |
| 1591 | | 1589 | |
| 1592 | pub const SymLinkAtError = error{ | | |
| 1593 | /// WASI-only. This error occurs when the file descriptor does | | |
| 1594 | /// not hold the required rights to create a new symbolic link relative to it. | | |
| 1595 | NotCapable, | | |
| 1596 | } || SymLinkError; | | |
| 1597 | | | |
| 1598 | /// Similar to `symlink`, however, creates a symbolic link named `sym_link_path` which contains the string | 1590 | /// Similar to `symlink`, however, creates a symbolic link named `sym_link_path` which contains the string |
| 1599 | /// `target_path` **relative** to `newdirfd` directory handle. | 1591 | /// `target_path` **relative** to `newdirfd` directory handle. |
| 1600 | /// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent | 1592 | /// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent |
| 1601 | /// one; the latter case is known as a dangling link. | 1593 | /// one; the latter case is known as a dangling link. |
| 1602 | /// If `sym_link_path` exists, it will not be overwritten. | 1594 | /// If `sym_link_path` exists, it will not be overwritten. |
| 1603 | /// See also `symlinkatWasi`, `symlinkatZ` and `symlinkatW`. | 1595 | /// See also `symlinkatWasi`, `symlinkatZ` and `symlinkatW`. |
| 1604 | pub fn symlinkat(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkAtError!void { | 1596 | pub fn symlinkat(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkError!void { |
| 1605 | if (builtin.os.tag == .wasi) { | 1597 | if (builtin.os.tag == .wasi) { |
| 1606 | return symlinkatWasi(target_path, newdirfd, sym_link_path); | 1598 | return symlinkatWasi(target_path, newdirfd, sym_link_path); |
| 1607 | } | 1599 | } |
| ... | @@ -1619,7 +1611,7 @@ pub const symlinkatC = @compileError("deprecated: renamed to symlinkatZ"); | ... | @@ -1619,7 +1611,7 @@ pub const symlinkatC = @compileError("deprecated: renamed to symlinkatZ"); |
| 1619 | | 1611 | |
| 1620 | /// WASI-only. The same as `symlinkat` but targeting WASI. | 1612 | /// WASI-only. The same as `symlinkat` but targeting WASI. |
| 1621 | /// See also `symlinkat`. | 1613 | /// See also `symlinkat`. |
| 1622 | pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkAtError!void { | 1614 | pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkError!void { |
| 1623 | switch (wasi.path_symlink(target_path.ptr, target_path.len, newdirfd, sym_link_path.ptr, sym_link_path.len)) { | 1615 | switch (wasi.path_symlink(target_path.ptr, target_path.len, newdirfd, sym_link_path.ptr, sym_link_path.len)) { |
| 1624 | wasi.ESUCCESS => {}, | 1616 | wasi.ESUCCESS => {}, |
| 1625 | wasi.EFAULT => unreachable, | 1617 | wasi.EFAULT => unreachable, |
| ... | @@ -1636,20 +1628,20 @@ pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []c | ... | @@ -1636,20 +1628,20 @@ pub fn symlinkatWasi(target_path: []const u8, newdirfd: fd_t, sym_link_path: []c |
| 1636 | wasi.ENOMEM => return error.SystemResources, | 1628 | wasi.ENOMEM => return error.SystemResources, |
| 1637 | wasi.ENOSPC => return error.NoSpaceLeft, | 1629 | wasi.ENOSPC => return error.NoSpaceLeft, |
| 1638 | wasi.EROFS => return error.ReadOnlyFileSystem, | 1630 | wasi.EROFS => return error.ReadOnlyFileSystem, |
| 1639 | wasi.ENOTCAPABLE => return error.NotCapable, | 1631 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 1640 | else => |err| return unexpectedErrno(err), | 1632 | else => |err| return unexpectedErrno(err), |
| 1641 | } | 1633 | } |
| 1642 | } | 1634 | } |
| 1643 | | 1635 | |
| 1644 | /// Windows-only. The same as `symlinkat` except the paths are null-terminated, WTF-16 encoded. | 1636 | /// Windows-only. The same as `symlinkat` except the paths are null-terminated, WTF-16 encoded. |
| 1645 | /// See also `symlinkat`. | 1637 | /// See also `symlinkat`. |
| 1646 | pub fn symlinkatW(target_path: [*:0]const u16, newdirfd: fd_t, sym_link_path: [*:0]const u16) SymLinkAtError!void { | 1638 | pub fn symlinkatW(target_path: [*:0]const u16, newdirfd: fd_t, sym_link_path: [*:0]const u16) SymLinkError!void { |
| 1647 | @compileError("TODO implement on Windows"); | 1639 | @compileError("TODO implement on Windows"); |
| 1648 | } | 1640 | } |
| 1649 | | 1641 | |
| 1650 | /// The same as `symlinkat` except the parameters are null-terminated pointers. | 1642 | /// The same as `symlinkat` except the parameters are null-terminated pointers. |
| 1651 | /// See also `symlinkat`. | 1643 | /// See also `symlinkat`. |
| 1652 | pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:0]const u8) SymLinkAtError!void { | 1644 | pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:0]const u8) SymLinkError!void { |
| 1653 | if (builtin.os.tag == .windows) { | 1645 | if (builtin.os.tag == .windows) { |
| 1654 | const target_path_w = try windows.cStrToPrefixedFileW(target_path); | 1646 | const target_path_w = try windows.cStrToPrefixedFileW(target_path); |
| 1655 | const sym_link_path_w = try windows.cStrToPrefixedFileW(sym_link_path); | 1647 | const sym_link_path_w = try windows.cStrToPrefixedFileW(sym_link_path); |
| ... | @@ -1677,6 +1669,9 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*: | ... | @@ -1677,6 +1669,9 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*: |
| 1677 | | 1669 | |
| 1678 | pub const UnlinkError = error{ | 1670 | pub const UnlinkError = error{ |
| 1679 | FileNotFound, | 1671 | FileNotFound, |
| | 1672 | |
| | 1673 | /// In WASI, this error may occur when the file descriptor does |
| | 1674 | /// not hold the required rights to unlink a resource by path relative to it. |
| 1680 | AccessDenied, | 1675 | AccessDenied, |
| 1681 | FileBusy, | 1676 | FileBusy, |
| 1682 | FileSystem, | 1677 | FileSystem, |
| ... | @@ -1739,10 +1734,6 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void { | ... | @@ -1739,10 +1734,6 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void { |
| 1739 | pub const UnlinkatError = UnlinkError || error{ | 1734 | pub const UnlinkatError = UnlinkError || error{ |
| 1740 | /// When passing `AT_REMOVEDIR`, this error occurs when the named directory is not empty. | 1735 | /// When passing `AT_REMOVEDIR`, this error occurs when the named directory is not empty. |
| 1741 | DirNotEmpty, | 1736 | DirNotEmpty, |
| 1742 | | | |
| 1743 | /// WASI-only. This error occurs when the file descriptor does | | |
| 1744 | /// not hold the required rights to unlink a resource by path relative to it. | | |
| 1745 | NotCapable, | | |
| 1746 | }; | 1737 | }; |
| 1747 | | 1738 | |
| 1748 | /// Delete a file name and possibly the file it refers to, based on an open directory handle. | 1739 | /// Delete a file name and possibly the file it refers to, based on an open directory handle. |
| ... | @@ -1784,7 +1775,7 @@ pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatErro | ... | @@ -1784,7 +1775,7 @@ pub fn unlinkatWasi(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatErro |
| 1784 | wasi.ENOMEM => return error.SystemResources, | 1775 | wasi.ENOMEM => return error.SystemResources, |
| 1785 | wasi.EROFS => return error.ReadOnlyFileSystem, | 1776 | wasi.EROFS => return error.ReadOnlyFileSystem, |
| 1786 | wasi.ENOTEMPTY => return error.DirNotEmpty, | 1777 | wasi.ENOTEMPTY => return error.DirNotEmpty, |
| 1787 | wasi.ENOTCAPABLE => return error.NotCapable, | 1778 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 1788 | | 1779 | |
| 1789 | wasi.EINVAL => unreachable, // invalid flags, or pathname has . as last component | 1780 | wasi.EINVAL => unreachable, // invalid flags, or pathname has . as last component |
| 1790 | wasi.EBADF => unreachable, // always a race condition | 1781 | wasi.EBADF => unreachable, // always a race condition |
| ... | @@ -1887,6 +1878,8 @@ pub fn unlinkatW(dirfd: fd_t, sub_path_w: [*:0]const u16, flags: u32) UnlinkatEr | ... | @@ -1887,6 +1878,8 @@ pub fn unlinkatW(dirfd: fd_t, sub_path_w: [*:0]const u16, flags: u32) UnlinkatEr |
| 1887 | } | 1878 | } |
| 1888 | | 1879 | |
| 1889 | const RenameError = error{ | 1880 | const RenameError = error{ |
| | 1881 | /// In WASI, this error may occur when the file descriptor does |
| | 1882 | /// not hold the required rights to rename a resource by path relative to it. |
| 1890 | AccessDenied, | 1883 | AccessDenied, |
| 1891 | FileBusy, | 1884 | FileBusy, |
| 1892 | DiskQuota, | 1885 | DiskQuota, |
| ... | @@ -1963,19 +1956,13 @@ pub fn renameW(old_path: [*:0]const u16, new_path: [*:0]const u16) RenameError!v | ... | @@ -1963,19 +1956,13 @@ pub fn renameW(old_path: [*:0]const u16, new_path: [*:0]const u16) RenameError!v |
| 1963 | return windows.MoveFileExW(old_path, new_path, flags); | 1956 | return windows.MoveFileExW(old_path, new_path, flags); |
| 1964 | } | 1957 | } |
| 1965 | | 1958 | |
| 1966 | pub const RenameatError = error{ | | |
| 1967 | /// WASI-only. This error occurs when the file descriptor does | | |
| 1968 | /// not hold the required rights to rename a resource by path relative to it. | | |
| 1969 | NotCapable, | | |
| 1970 | } || RenameError; | | |
| 1971 | | | |
| 1972 | /// Change the name or location of a file based on an open directory handle. | 1959 | /// Change the name or location of a file based on an open directory handle. |
| 1973 | pub fn renameat( | 1960 | pub fn renameat( |
| 1974 | old_dir_fd: fd_t, | 1961 | old_dir_fd: fd_t, |
| 1975 | old_path: []const u8, | 1962 | old_path: []const u8, |
| 1976 | new_dir_fd: fd_t, | 1963 | new_dir_fd: fd_t, |
| 1977 | new_path: []const u8, | 1964 | new_path: []const u8, |
| 1978 | ) RenameatError!void { | 1965 | ) RenameError!void { |
| 1979 | if (builtin.os.tag == .windows) { | 1966 | if (builtin.os.tag == .windows) { |
| 1980 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); | 1967 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); |
| 1981 | const new_path_w = try windows.sliceToPrefixedFileW(new_path); | 1968 | const new_path_w = try windows.sliceToPrefixedFileW(new_path); |
| ... | @@ -1991,7 +1978,7 @@ pub fn renameat( | ... | @@ -1991,7 +1978,7 @@ pub fn renameat( |
| 1991 | | 1978 | |
| 1992 | /// WASI-only. Same as `renameat` expect targeting WASI. | 1979 | /// WASI-only. Same as `renameat` expect targeting WASI. |
| 1993 | /// See also `renameat`. | 1980 | /// See also `renameat`. |
| 1994 | pub fn renameatWasi(old_dir_fd: fd_t, old_path: []const u8, new_dir_fd: fd_t, new_path: []const u8) RenameatError!void { | 1981 | pub fn renameatWasi(old_dir_fd: fd_t, old_path: []const u8, new_dir_fd: fd_t, new_path: []const u8) RenameError!void { |
| 1995 | switch (wasi.path_rename(old_dir_fd, old_path.ptr, old_path.len, new_dir_fd, new_path.ptr, new_path.len)) { | 1982 | switch (wasi.path_rename(old_dir_fd, old_path.ptr, old_path.len, new_dir_fd, new_path.ptr, new_path.len)) { |
| 1996 | wasi.ESUCCESS => return, | 1983 | wasi.ESUCCESS => return, |
| 1997 | wasi.EACCES => return error.AccessDenied, | 1984 | wasi.EACCES => return error.AccessDenied, |
| ... | @@ -2012,7 +1999,7 @@ pub fn renameatWasi(old_dir_fd: fd_t, old_path: []const u8, new_dir_fd: fd_t, ne | ... | @@ -2012,7 +1999,7 @@ pub fn renameatWasi(old_dir_fd: fd_t, old_path: []const u8, new_dir_fd: fd_t, ne |
| 2012 | wasi.ENOTEMPTY => return error.PathAlreadyExists, | 1999 | wasi.ENOTEMPTY => return error.PathAlreadyExists, |
| 2013 | wasi.EROFS => return error.ReadOnlyFileSystem, | 2000 | wasi.EROFS => return error.ReadOnlyFileSystem, |
| 2014 | wasi.EXDEV => return error.RenameAcrossMountPoints, | 2001 | wasi.EXDEV => return error.RenameAcrossMountPoints, |
| 2015 | wasi.ENOTCAPABLE => return error.NotCapable, | 2002 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 2016 | else => |err| return unexpectedErrno(err), | 2003 | else => |err| return unexpectedErrno(err), |
| 2017 | } | 2004 | } |
| 2018 | } | 2005 | } |
| ... | @@ -2023,7 +2010,7 @@ pub fn renameatZ( | ... | @@ -2023,7 +2010,7 @@ pub fn renameatZ( |
| 2023 | old_path: [*:0]const u8, | 2010 | old_path: [*:0]const u8, |
| 2024 | new_dir_fd: fd_t, | 2011 | new_dir_fd: fd_t, |
| 2025 | new_path: [*:0]const u8, | 2012 | new_path: [*:0]const u8, |
| 2026 | ) RenameatError!void { | 2013 | ) RenameError!void { |
| 2027 | if (builtin.os.tag == .windows) { | 2014 | if (builtin.os.tag == .windows) { |
| 2028 | const old_path_w = try windows.cStrToPrefixedFileW(old_path); | 2015 | const old_path_w = try windows.cStrToPrefixedFileW(old_path); |
| 2029 | const new_path_w = try windows.cStrToPrefixedFileW(new_path); | 2016 | const new_path_w = try windows.cStrToPrefixedFileW(new_path); |
| ... | @@ -2062,7 +2049,7 @@ pub fn renameatW( | ... | @@ -2062,7 +2049,7 @@ pub fn renameatW( |
| 2062 | new_dir_fd: fd_t, | 2049 | new_dir_fd: fd_t, |
| 2063 | new_path_w: []const u16, | 2050 | new_path_w: []const u16, |
| 2064 | ReplaceIfExists: windows.BOOLEAN, | 2051 | ReplaceIfExists: windows.BOOLEAN, |
| 2065 | ) RenameatError!void { | 2052 | ) RenameError!void { |
| 2066 | const src_fd = windows.OpenFile(old_path_w, .{ | 2053 | const src_fd = windows.OpenFile(old_path_w, .{ |
| 2067 | .dir = old_dir_fd, | 2054 | .dir = old_dir_fd, |
| 2068 | .access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE | windows.DELETE, | 2055 | .access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE | windows.DELETE, |
| ... | @@ -2111,13 +2098,7 @@ pub fn renameatW( | ... | @@ -2111,13 +2098,7 @@ pub fn renameatW( |
| 2111 | } | 2098 | } |
| 2112 | } | 2099 | } |
| 2113 | | 2100 | |
| 2114 | pub const MakeDirAtError = error{ | 2101 | pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2115 | /// WASI-only. This error occurs when the file descriptor does | | |
| 2116 | /// not hold the required rights to create a new directory relative to it. | | |
| 2117 | NotCapable, | | |
| 2118 | } || MakeDirError; | | |
| 2119 | | | |
| 2120 | pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtError!void { | | |
| 2121 | if (builtin.os.tag == .windows) { | 2102 | if (builtin.os.tag == .windows) { |
| 2122 | const sub_dir_path_w = try windows.sliceToPrefixedFileW(sub_dir_path); | 2103 | const sub_dir_path_w = try windows.sliceToPrefixedFileW(sub_dir_path); |
| 2123 | return mkdiratW(dir_fd, sub_dir_path_w.span().ptr, mode); | 2104 | return mkdiratW(dir_fd, sub_dir_path_w.span().ptr, mode); |
| ... | @@ -2131,7 +2112,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtError | ... | @@ -2131,7 +2112,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtError |
| 2131 | | 2112 | |
| 2132 | pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); | 2113 | pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); |
| 2133 | | 2114 | |
| 2134 | pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtError!void { | 2115 | pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2135 | switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { | 2116 | switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { |
| 2136 | wasi.ESUCCESS => return, | 2117 | wasi.ESUCCESS => return, |
| 2137 | wasi.EACCES => return error.AccessDenied, | 2118 | wasi.EACCES => return error.AccessDenied, |
| ... | @@ -2148,12 +2129,12 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtE | ... | @@ -2148,12 +2129,12 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirAtE |
| 2148 | wasi.ENOSPC => return error.NoSpaceLeft, | 2129 | wasi.ENOSPC => return error.NoSpaceLeft, |
| 2149 | wasi.ENOTDIR => return error.NotDir, | 2130 | wasi.ENOTDIR => return error.NotDir, |
| 2150 | wasi.EROFS => return error.ReadOnlyFileSystem, | 2131 | wasi.EROFS => return error.ReadOnlyFileSystem, |
| 2151 | wasi.ENOTCAPABLE => return error.NotCapable, | 2132 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 2152 | else => |err| return unexpectedErrno(err), | 2133 | else => |err| return unexpectedErrno(err), |
| 2153 | } | 2134 | } |
| 2154 | } | 2135 | } |
| 2155 | | 2136 | |
| 2156 | pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirAtError!void { | 2137 | pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirError!void { |
| 2157 | if (builtin.os.tag == .windows) { | 2138 | if (builtin.os.tag == .windows) { |
| 2158 | const sub_dir_path_w = try windows.cStrToPrefixedFileW(sub_dir_path); | 2139 | const sub_dir_path_w = try windows.cStrToPrefixedFileW(sub_dir_path); |
| 2159 | return mkdiratW(dir_fd, sub_dir_path_w.span().ptr, mode); | 2140 | return mkdiratW(dir_fd, sub_dir_path_w.span().ptr, mode); |
| ... | @@ -2178,12 +2159,14 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirAtE | ... | @@ -2178,12 +2159,14 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirAtE |
| 2178 | } | 2159 | } |
| 2179 | } | 2160 | } |
| 2180 | | 2161 | |
| 2181 | pub fn mkdiratW(dir_fd: fd_t, sub_path_w: [*:0]const u16, mode: u32) MakeDirAtError!void { | 2162 | pub fn mkdiratW(dir_fd: fd_t, sub_path_w: [*:0]const u16, mode: u32) MakeDirError!void { |
| 2182 | const sub_dir_handle = try windows.CreateDirectoryW(dir_fd, sub_path_w, null); | 2163 | const sub_dir_handle = try windows.CreateDirectoryW(dir_fd, sub_path_w, null); |
| 2183 | windows.CloseHandle(sub_dir_handle); | 2164 | windows.CloseHandle(sub_dir_handle); |
| 2184 | } | 2165 | } |
| 2185 | | 2166 | |
| 2186 | pub const MakeDirError = error{ | 2167 | pub const MakeDirError = error{ |
| | 2168 | /// In WASI, this error may occur when the file descriptor does |
| | 2169 | /// not hold the required rights to create a new directory relative to it. |
| 2187 | AccessDenied, | 2170 | AccessDenied, |
| 2188 | DiskQuota, | 2171 | DiskQuota, |
| 2189 | PathAlreadyExists, | 2172 | PathAlreadyExists, |
| ... | @@ -2363,6 +2346,8 @@ pub fn fchdir(dirfd: fd_t) FchdirError!void { | ... | @@ -2363,6 +2346,8 @@ pub fn fchdir(dirfd: fd_t) FchdirError!void { |
| 2363 | } | 2346 | } |
| 2364 | | 2347 | |
| 2365 | pub const ReadLinkError = error{ | 2348 | pub const ReadLinkError = error{ |
| | 2349 | /// In WASI, this error may occur when the file descriptor does |
| | 2350 | /// not hold the required rights to read value of a symbolic link relative to it. |
| 2366 | AccessDenied, | 2351 | AccessDenied, |
| 2367 | FileSystem, | 2352 | FileSystem, |
| 2368 | SymLinkLoop, | 2353 | SymLinkLoop, |
| ... | @@ -2416,16 +2401,10 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 | ... | @@ -2416,16 +2401,10 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 |
| 2416 | } | 2401 | } |
| 2417 | } | 2402 | } |
| 2418 | | 2403 | |
| 2419 | pub const ReadLinkAtError = error{ | | |
| 2420 | /// WASI-only. This error occurs when the file descriptor does | | |
| 2421 | /// not hold the required rights to read value of a symbolic link relative to it. | | |
| 2422 | NotCapable, | | |
| 2423 | } || ReadLinkError; | | |
| 2424 | | | |
| 2425 | /// Similar to `readlink` except reads value of a symbolink link **relative** to `dirfd` directory handle. | 2404 | /// Similar to `readlink` except reads value of a symbolink link **relative** to `dirfd` directory handle. |
| 2426 | /// The return value is a slice of `out_buffer` from index 0. | 2405 | /// The return value is a slice of `out_buffer` from index 0. |
| 2427 | /// See also `readlinkatWasi`, `realinkatZ` and `realinkatW`. | 2406 | /// See also `readlinkatWasi`, `realinkatZ` and `realinkatW`. |
| 2428 | pub fn readlinkat(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) ReadLinkAtError![]u8 { | 2407 | pub fn readlinkat(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2429 | if (builtin.os.tag == .wasi) { | 2408 | if (builtin.os.tag == .wasi) { |
| 2430 | return readlinkatWasi(dirfd, file_path, out_buffer); | 2409 | return readlinkatWasi(dirfd, file_path, out_buffer); |
| 2431 | } | 2410 | } |
| ... | @@ -2441,7 +2420,7 @@ pub const readlinkatC = @compileError("deprecated: renamed to readlinkatZ"); | ... | @@ -2441,7 +2420,7 @@ pub const readlinkatC = @compileError("deprecated: renamed to readlinkatZ"); |
| 2441 | | 2420 | |
| 2442 | /// WASI-only. Same as `readlinkat` but targets WASI. | 2421 | /// WASI-only. Same as `readlinkat` but targets WASI. |
| 2443 | /// See also `readlinkat`. | 2422 | /// See also `readlinkat`. |
| 2444 | pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) ReadLinkAtError![]u8 { | 2423 | pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2445 | var bufused: usize = undefined; | 2424 | var bufused: usize = undefined; |
| 2446 | switch (wasi.path_readlink(dirfd, file_path.ptr, file_path.len, out_buffer.ptr, out_buffer.len, &bufused)) { | 2425 | switch (wasi.path_readlink(dirfd, file_path.ptr, file_path.len, out_buffer.ptr, out_buffer.len, &bufused)) { |
| 2447 | wasi.ESUCCESS => return out_buffer[0..bufused], | 2426 | wasi.ESUCCESS => return out_buffer[0..bufused], |
| ... | @@ -2454,20 +2433,20 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read | ... | @@ -2454,20 +2433,20 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read |
| 2454 | wasi.ENOENT => return error.FileNotFound, | 2433 | wasi.ENOENT => return error.FileNotFound, |
| 2455 | wasi.ENOMEM => return error.SystemResources, | 2434 | wasi.ENOMEM => return error.SystemResources, |
| 2456 | wasi.ENOTDIR => return error.NotDir, | 2435 | wasi.ENOTDIR => return error.NotDir, |
| 2457 | wasi.ENOTCAPABLE => return error.NotCapable, | 2436 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 2458 | else => |err| return unexpectedErrno(err), | 2437 | else => |err| return unexpectedErrno(err), |
| 2459 | } | 2438 | } |
| 2460 | } | 2439 | } |
| 2461 | | 2440 | |
| 2462 | /// Windows-only. Same as `readlinkat` except `file_path` is null-terminated, WTF16 encoded. | 2441 | /// Windows-only. Same as `readlinkat` except `file_path` is null-terminated, WTF16 encoded. |
| 2463 | /// See also `readlinkat`. | 2442 | /// See also `readlinkat`. |
| 2464 | pub fn readlinkatW(dirfd: fd_t, file_path: [*:0]const u16, out_buffer: []u8) ReadLinkAtError![]u8 { | 2443 | pub fn readlinkatW(dirfd: fd_t, file_path: [*:0]const u16, out_buffer: []u8) ReadLinkError![]u8 { |
| 2465 | @compileError("TODO implement on Windows"); | 2444 | @compileError("TODO implement on Windows"); |
| 2466 | } | 2445 | } |
| 2467 | | 2446 | |
| 2468 | /// Same as `readlinkat` except `file_path` is null-terminated. | 2447 | /// Same as `readlinkat` except `file_path` is null-terminated. |
| 2469 | /// See also `readlinkat`. | 2448 | /// See also `readlinkat`. |
| 2470 | pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) ReadLinkAtError![]u8 { | 2449 | pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2471 | if (builtin.os.tag == .windows) { | 2450 | if (builtin.os.tag == .windows) { |
| 2472 | const file_path_w = try windows.cStrToPrefixedFileW(file_path); | 2451 | const file_path_w = try windows.cStrToPrefixedFileW(file_path); |
| 2473 | return readlinkatW(dirfd, file_path_w.span().ptr, out_buffer); | 2452 | return readlinkatW(dirfd, file_path_w.span().ptr, out_buffer); |
| ... | @@ -3132,11 +3111,10 @@ pub fn waitpid(pid: i32, flags: u32) u32 { | ... | @@ -3132,11 +3111,10 @@ pub fn waitpid(pid: i32, flags: u32) u32 { |
| 3132 | | 3111 | |
| 3133 | pub const FStatError = error{ | 3112 | pub const FStatError = error{ |
| 3134 | SystemResources, | 3113 | SystemResources, |
| 3135 | AccessDenied, | | |
| 3136 | | 3114 | |
| 3137 | /// WASI-only. This error occurs when the file descriptor does | 3115 | /// In WASI, this error may occur when the file descriptor does |
| 3138 | /// not hold the required rights to get its filestat information. | 3116 | /// not hold the required rights to get its filestat information. |
| 3139 | NotCapable, | 3117 | AccessDenied, |
| 3140 | } || UnexpectedError; | 3118 | } || UnexpectedError; |
| 3141 | | 3119 | |
| 3142 | /// Return information about a file descriptor. | 3120 | /// Return information about a file descriptor. |
| ... | @@ -3149,7 +3127,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { | ... | @@ -3149,7 +3127,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 3149 | wasi.EBADF => unreachable, // Always a race condition. | 3127 | wasi.EBADF => unreachable, // Always a race condition. |
| 3150 | wasi.ENOMEM => return error.SystemResources, | 3128 | wasi.ENOMEM => return error.SystemResources, |
| 3151 | wasi.EACCES => return error.AccessDenied, | 3129 | wasi.EACCES => return error.AccessDenied, |
| 3152 | wasi.ENOTCAPABLE => return error.NotCapable, | 3130 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3153 | else => |err| return unexpectedErrno(err), | 3131 | else => |err| return unexpectedErrno(err), |
| 3154 | } | 3132 | } |
| 3155 | } | 3133 | } |
| ... | @@ -3200,7 +3178,7 @@ pub fn fstatatWasi(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!S | ... | @@ -3200,7 +3178,7 @@ pub fn fstatatWasi(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!S |
| 3200 | wasi.ENAMETOOLONG => return error.NameTooLong, | 3178 | wasi.ENAMETOOLONG => return error.NameTooLong, |
| 3201 | wasi.ENOENT => return error.FileNotFound, | 3179 | wasi.ENOENT => return error.FileNotFound, |
| 3202 | wasi.ENOTDIR => return error.FileNotFound, | 3180 | wasi.ENOTDIR => return error.FileNotFound, |
| 3203 | wasi.ENOTCAPABLE => return error.NotCapable, | 3181 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3204 | else => |err| return unexpectedErrno(err), | 3182 | else => |err| return unexpectedErrno(err), |
| 3205 | } | 3183 | } |
| 3206 | } | 3184 | } |
| ... | @@ -3709,9 +3687,9 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void { | ... | @@ -3709,9 +3687,9 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void { |
| 3709 | pub const SeekError = error{ | 3687 | pub const SeekError = error{ |
| 3710 | Unseekable, | 3688 | Unseekable, |
| 3711 | | 3689 | |
| 3712 | /// WASI-only. This error occurs when the file descriptor does | 3690 | /// In WASI, this error may occur when the file descriptor does |
| 3713 | /// not hold the required rights to seek on it. | 3691 | /// not hold the required rights to seek on it. |
| 3714 | NotCapable, | 3692 | AccessDenied, |
| 3715 | } || UnexpectedError; | 3693 | } || UnexpectedError; |
| 3716 | | 3694 | |
| 3717 | /// Repositions read/write file offset relative to the beginning. | 3695 | /// Repositions read/write file offset relative to the beginning. |
| ... | @@ -3740,7 +3718,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { | ... | @@ -3740,7 +3718,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 3740 | wasi.EOVERFLOW => return error.Unseekable, | 3718 | wasi.EOVERFLOW => return error.Unseekable, |
| 3741 | wasi.ESPIPE => return error.Unseekable, | 3719 | wasi.ESPIPE => return error.Unseekable, |
| 3742 | wasi.ENXIO => return error.Unseekable, | 3720 | wasi.ENXIO => return error.Unseekable, |
| 3743 | wasi.ENOTCAPABLE => return error.NotCapable, | 3721 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3744 | else => |err| return unexpectedErrno(err), | 3722 | else => |err| return unexpectedErrno(err), |
| 3745 | } | 3723 | } |
| 3746 | } | 3724 | } |
| ... | @@ -3782,7 +3760,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { | ... | @@ -3782,7 +3760,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 3782 | wasi.EOVERFLOW => return error.Unseekable, | 3760 | wasi.EOVERFLOW => return error.Unseekable, |
| 3783 | wasi.ESPIPE => return error.Unseekable, | 3761 | wasi.ESPIPE => return error.Unseekable, |
| 3784 | wasi.ENXIO => return error.Unseekable, | 3762 | wasi.ENXIO => return error.Unseekable, |
| 3785 | wasi.ENOTCAPABLE => return error.NotCapable, | 3763 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3786 | else => |err| return unexpectedErrno(err), | 3764 | else => |err| return unexpectedErrno(err), |
| 3787 | } | 3765 | } |
| 3788 | } | 3766 | } |
| ... | @@ -3823,7 +3801,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { | ... | @@ -3823,7 +3801,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 3823 | wasi.EOVERFLOW => return error.Unseekable, | 3801 | wasi.EOVERFLOW => return error.Unseekable, |
| 3824 | wasi.ESPIPE => return error.Unseekable, | 3802 | wasi.ESPIPE => return error.Unseekable, |
| 3825 | wasi.ENXIO => return error.Unseekable, | 3803 | wasi.ENXIO => return error.Unseekable, |
| 3826 | wasi.ENOTCAPABLE => return error.NotCapable, | 3804 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3827 | else => |err| return unexpectedErrno(err), | 3805 | else => |err| return unexpectedErrno(err), |
| 3828 | } | 3806 | } |
| 3829 | } | 3807 | } |
| ... | @@ -3864,7 +3842,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { | ... | @@ -3864,7 +3842,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 3864 | wasi.EOVERFLOW => return error.Unseekable, | 3842 | wasi.EOVERFLOW => return error.Unseekable, |
| 3865 | wasi.ESPIPE => return error.Unseekable, | 3843 | wasi.ESPIPE => return error.Unseekable, |
| 3866 | wasi.ENXIO => return error.Unseekable, | 3844 | wasi.ENXIO => return error.Unseekable, |
| 3867 | wasi.ENOTCAPABLE => return error.NotCapable, | 3845 | wasi.ENOTCAPABLE => return error.AccessDenied, |
| 3868 | else => |err| return unexpectedErrno(err), | 3846 | else => |err| return unexpectedErrno(err), |
| 3869 | } | 3847 | } |
| 3870 | } | 3848 | } |
| ... | @@ -4012,7 +3990,6 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP | ... | @@ -4012,7 +3990,6 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP |
| 4012 | if (builtin.os.tag == .linux and !builtin.link_libc) { | 3990 | if (builtin.os.tag == .linux and !builtin.link_libc) { |
| 4013 | const fd = openZ(pathname, linux.O_PATH | linux.O_NONBLOCK | linux.O_CLOEXEC, 0) catch |err| switch (err) { | 3991 | const fd = openZ(pathname, linux.O_PATH | linux.O_NONBLOCK | linux.O_CLOEXEC, 0) catch |err| switch (err) { |
| 4014 | error.FileLocksNotSupported => unreachable, | 3992 | error.FileLocksNotSupported => unreachable, |
| 4015 | error.NotCapable => unreachable, // WASI only | | |
| 4016 | else => |e| return e, | 3993 | else => |e| return e, |
| 4017 | }; | 3994 | }; |
| 4018 | defer close(fd); | 3995 | defer close(fd); |