| ... | @@ -296,6 +296,7 @@ pub const ReadError = error{ | ... | @@ -296,6 +296,7 @@ pub const ReadError = error{ |
| 296 | BrokenPipe, | 296 | BrokenPipe, |
| 297 | ConnectionResetByPeer, | 297 | ConnectionResetByPeer, |
| 298 | ConnectionTimedOut, | 298 | ConnectionTimedOut, |
| | 299 | NotOpenForReading, |
| 299 | | 300 | |
| 300 | /// This error occurs when no global event loop is configured, | 301 | /// This error occurs when no global event loop is configured, |
| 301 | /// and reading from the file descriptor would block. | 302 | /// and reading from the file descriptor would block. |
| ... | @@ -359,7 +360,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { | ... | @@ -359,7 +360,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 359 | } else { | 360 | } else { |
| 360 | return error.WouldBlock; | 361 | return error.WouldBlock; |
| 361 | }, | 362 | }, |
| 362 | EBADF => unreachable, // Always a race condition. | 363 | EBADF => return error.NotOpenForReading, // Can be a race condition. |
| 363 | EIO => return error.InputOutput, | 364 | EIO => return error.InputOutput, |
| 364 | EISDIR => return error.IsDir, | 365 | EISDIR => return error.IsDir, |
| 365 | ENOBUFS => return error.SystemResources, | 366 | ENOBUFS => return error.SystemResources, |
| ... | @@ -420,7 +421,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { | ... | @@ -420,7 +421,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 420 | } else { | 421 | } else { |
| 421 | return error.WouldBlock; | 422 | return error.WouldBlock; |
| 422 | }, | 423 | }, |
| 423 | EBADF => unreachable, // always a race condition | 424 | EBADF => return error.NotOpenForReading, // can be a race condition |
| 424 | EIO => return error.InputOutput, | 425 | EIO => return error.InputOutput, |
| 425 | EISDIR => return error.IsDir, | 426 | EISDIR => return error.IsDir, |
| 426 | ENOBUFS => return error.SystemResources, | 427 | ENOBUFS => return error.SystemResources, |
| ... | @@ -483,7 +484,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { | ... | @@ -483,7 +484,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 483 | } else { | 484 | } else { |
| 484 | return error.WouldBlock; | 485 | return error.WouldBlock; |
| 485 | }, | 486 | }, |
| 486 | EBADF => unreachable, // Always a race condition. | 487 | EBADF => return error.NotOpenForReading, // Can be a race condition. |
| 487 | EIO => return error.InputOutput, | 488 | EIO => return error.InputOutput, |
| 488 | EISDIR => return error.IsDir, | 489 | EISDIR => return error.IsDir, |
| 489 | ENOBUFS => return error.SystemResources, | 490 | ENOBUFS => return error.SystemResources, |
| ... | @@ -623,7 +624,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { | ... | @@ -623,7 +624,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 623 | } else { | 624 | } else { |
| 624 | return error.WouldBlock; | 625 | return error.WouldBlock; |
| 625 | }, | 626 | }, |
| 626 | EBADF => unreachable, // always a race condition | 627 | EBADF => return error.NotOpenForReading, // can be a race condition |
| 627 | EIO => return error.InputOutput, | 628 | EIO => return error.InputOutput, |
| 628 | EISDIR => return error.IsDir, | 629 | EISDIR => return error.IsDir, |
| 629 | ENOBUFS => return error.SystemResources, | 630 | ENOBUFS => return error.SystemResources, |
| ... | @@ -645,6 +646,7 @@ pub const WriteError = error{ | ... | @@ -645,6 +646,7 @@ pub const WriteError = error{ |
| 645 | BrokenPipe, | 646 | BrokenPipe, |
| 646 | SystemResources, | 647 | SystemResources, |
| 647 | OperationAborted, | 648 | OperationAborted, |
| | 649 | NotOpenForWriting, |
| 648 | | 650 | |
| 649 | /// This error occurs when no global event loop is configured, | 651 | /// This error occurs when no global event loop is configured, |
| 650 | /// and reading from the file descriptor would block. | 652 | /// and reading from the file descriptor would block. |
| ... | @@ -720,7 +722,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { | ... | @@ -720,7 +722,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 720 | } else { | 722 | } else { |
| 721 | return error.WouldBlock; | 723 | return error.WouldBlock; |
| 722 | }, | 724 | }, |
| 723 | EBADF => unreachable, // Always a race condition. | 725 | EBADF => return error.NotOpenForWriting, // can be a race condition. |
| 724 | EDESTADDRREQ => unreachable, // `connect` was never called. | 726 | EDESTADDRREQ => unreachable, // `connect` was never called. |
| 725 | EDQUOT => return error.DiskQuota, | 727 | EDQUOT => return error.DiskQuota, |
| 726 | EFBIG => return error.FileTooBig, | 728 | EFBIG => return error.FileTooBig, |
| ... | @@ -792,7 +794,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { | ... | @@ -792,7 +794,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { |
| 792 | } else { | 794 | } else { |
| 793 | return error.WouldBlock; | 795 | return error.WouldBlock; |
| 794 | }, | 796 | }, |
| 795 | EBADF => unreachable, // Always a race condition. | 797 | EBADF => return error.NotOpenForWriting, // Can be a race condition. |
| 796 | EDESTADDRREQ => unreachable, // `connect` was never called. | 798 | EDESTADDRREQ => unreachable, // `connect` was never called. |
| 797 | EDQUOT => return error.DiskQuota, | 799 | EDQUOT => return error.DiskQuota, |
| 798 | EFBIG => return error.FileTooBig, | 800 | EFBIG => return error.FileTooBig, |
| ... | @@ -880,7 +882,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { | ... | @@ -880,7 +882,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 880 | } else { | 882 | } else { |
| 881 | return error.WouldBlock; | 883 | return error.WouldBlock; |
| 882 | }, | 884 | }, |
| 883 | EBADF => unreachable, // Always a race condition. | 885 | EBADF => return error.NotOpenForWriting, // Can be a race condition. |
| 884 | EDESTADDRREQ => unreachable, // `connect` was never called. | 886 | EDESTADDRREQ => unreachable, // `connect` was never called. |
| 885 | EDQUOT => return error.DiskQuota, | 887 | EDQUOT => return error.DiskQuota, |
| 886 | EFBIG => return error.FileTooBig, | 888 | EFBIG => return error.FileTooBig, |
| ... | @@ -967,7 +969,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz | ... | @@ -967,7 +969,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 967 | } else { | 969 | } else { |
| 968 | return error.WouldBlock; | 970 | return error.WouldBlock; |
| 969 | }, | 971 | }, |
| 970 | EBADF => unreachable, // Always a race condition. | 972 | EBADF => return error.NotOpenForWriting, // Can be a race condition. |
| 971 | EDESTADDRREQ => unreachable, // `connect` was never called. | 973 | EDESTADDRREQ => unreachable, // `connect` was never called. |
| 972 | EDQUOT => return error.DiskQuota, | 974 | EDQUOT => return error.DiskQuota, |
| 973 | EFBIG => return error.FileTooBig, | 975 | EFBIG => return error.FileTooBig, |
| ... | @@ -1162,7 +1164,7 @@ pub fn dup2(old_fd: fd_t, new_fd: fd_t) !void { | ... | @@ -1162,7 +1164,7 @@ pub fn dup2(old_fd: fd_t, new_fd: fd_t) !void { |
| 1162 | EBUSY, EINTR => continue, | 1164 | EBUSY, EINTR => continue, |
| 1163 | EMFILE => return error.ProcessFdQuotaExceeded, | 1165 | EMFILE => return error.ProcessFdQuotaExceeded, |
| 1164 | EINVAL => unreachable, // invalid parameters passed to dup2 | 1166 | EINVAL => unreachable, // invalid parameters passed to dup2 |
| 1165 | EBADF => unreachable, // always a race condition | 1167 | EBADF => unreachable, // invalid file descriptor |
| 1166 | else => |err| return unexpectedErrno(err), | 1168 | else => |err| return unexpectedErrno(err), |
| 1167 | } | 1169 | } |
| 1168 | } | 1170 | } |