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