diff --git a/lib/std/posix.zig b/lib/std/posix.zig index d6a5c27c7c0f..f78d2e8f8057 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -834,6 +834,9 @@ pub const ReadError = error{ /// Unable to read file due to lock. LockViolation, + + /// The device is not available or the address is not found. + DeviceOrAddressNotFound, } || UnexpectedError; /// Returns the number of bytes that were read, which can be less than @@ -901,6 +904,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { .NOTCONN => return error.SocketNotConnected, .CONNRESET => return error.ConnectionResetByPeer, .TIMEDOUT => return error.ConnectionTimedOut, + .NXIO => return error.DeviceOrAddressNotFound, else => |err| return unexpectedErrno(err), } } @@ -964,6 +968,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { .NOTCONN => return error.SocketNotConnected, .CONNRESET => return error.ConnectionResetByPeer, .TIMEDOUT => return error.ConnectionTimedOut, + .NXIO => return error.DeviceOrAddressNotFound, else => |err| return unexpectedErrno(err), } } @@ -1011,7 +1016,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { .NOTCONN => return error.SocketNotConnected, .CONNRESET => return error.ConnectionResetByPeer, .TIMEDOUT => return error.ConnectionTimedOut, - .NXIO => return error.Unseekable, + .NXIO => return error.DeviceOrAddressNotFound, .SPIPE => return error.Unseekable, .OVERFLOW => return error.Unseekable, .NOTCAPABLE => return error.AccessDenied, @@ -1044,7 +1049,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { .NOTCONN => return error.SocketNotConnected, .CONNRESET => return error.ConnectionResetByPeer, .TIMEDOUT => return error.ConnectionTimedOut, - .NXIO => return error.Unseekable, + .NXIO => return error.DeviceOrAddressNotFound, .SPIPE => return error.Unseekable, .OVERFLOW => return error.Unseekable, else => |err| return unexpectedErrno(err), @@ -1188,9 +1193,9 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { .NOTCONN => return error.SocketNotConnected, .CONNRESET => return error.ConnectionResetByPeer, .TIMEDOUT => return error.ConnectionTimedOut, - .NXIO => return error.Unseekable, .SPIPE => return error.Unseekable, .OVERFLOW => return error.Unseekable, + .NXIO => return error.DeviceOrAddressNotFound, else => |err| return unexpectedErrno(err), } } @@ -6231,6 +6236,9 @@ pub const SendError = error{ /// The destination address is not listening. ConnectionRefused, + + /// The device is not available or the address is not found. + DeviceOrAddressNotFound, } || UnexpectedError; pub const SendMsgError = SendError || error{ @@ -6422,6 +6430,7 @@ pub fn sendto( .NETUNREACH => return error.NetworkUnreachable, .NOTCONN => return error.SocketNotConnected, .NETDOWN => return error.NetworkSubsystemFailed, + .NXIO => return error.DeviceOrAddressNotFound, else => |err| return unexpectedErrno(err), } } diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index e237cecd5904..bc0a7b4e96ae 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -517,6 +517,7 @@ pub const AbiAndDynamicLinkerFromFileError = error{ NameTooLong, ProcessNotFound, StaticElfFile, + DeviceOrAddressNotFound, }; pub fn abiAndDynamicLinkerFromFile( @@ -925,6 +926,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion { error.Unexpected, error.FileSystem, error.ProcessNotFound, + error.DeviceOrAddressNotFound, => |e| return e, }; } @@ -1181,6 +1183,7 @@ fn detectAbiAndDynamicLinker( error.UnexpectedEndOfFile, error.UnableToReadElfFile, error.ProcessNotFound, + error.DeviceOrAddressNotFound, => return defaultAbiAndDynamicLinker(cpu, os, query), else => |e| return e, @@ -1237,6 +1240,7 @@ fn detectAbiAndDynamicLinker( error.UnexpectedEndOfFile, error.NameTooLong, error.StaticElfFile, + error.DeviceOrAddressNotFound, // Finally, we fall back on the standard path. => |e| { std.log.warn("Encountered error: {s}, falling back to default ABI and dynamic linker.", .{@errorName(e)}); @@ -1284,6 +1288,7 @@ fn preadAtLeast(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usi error.AccessDenied => return error.Unexpected, error.ProcessNotFound => return error.ProcessNotFound, error.LockViolation => return error.UnableToReadElfFile, + error.DeviceOrAddressNotFound => return error.DeviceOrAddressNotFound, }; if (len == 0) return error.UnexpectedEndOfFile; i += len;