Skip to content
15 changes: 12 additions & 3 deletions lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
NoSuchDeviceOrAddress,
} || UnexpectedError;

/// Returns the number of bytes that were read, which can be less than
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress,
else => |err| return unexpectedErrno(err),
}
}
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress,
else => |err| return unexpectedErrno(err),
}
}
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress,
.SPIPE => return error.Unseekable,
.OVERFLOW => return error.Unseekable,
.NOTCAPABLE => return error.AccessDenied,
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress,
.SPIPE => return error.Unseekable,
.OVERFLOW => return error.Unseekable,
else => |err| return unexpectedErrno(err),
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress,
else => |err| return unexpectedErrno(err),
}
}
Expand Down Expand Up @@ -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.
NoSuchDeviceOrAddress,
} || UnexpectedError;

pub const SendMsgError = SendError || error{
Expand Down Expand Up @@ -6422,6 +6430,7 @@ pub fn sendto(
.NETUNREACH => return error.NetworkUnreachable,
.NOTCONN => return error.SocketNotConnected,
.NETDOWN => return error.NetworkSubsystemFailed,
.NXIO => return error.NoSuchDeviceOrAddress,
else => |err| return unexpectedErrno(err),
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/std/zig/system.zig
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ pub const AbiAndDynamicLinkerFromFileError = error{
NameTooLong,
ProcessNotFound,
StaticElfFile,
NoSuchDeviceOrAddress,
};

pub fn abiAndDynamicLinkerFromFile(
Expand Down Expand Up @@ -925,6 +926,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
error.Unexpected,
error.FileSystem,
error.ProcessNotFound,
error.NoSuchDeviceOrAddress,
=> |e| return e,
};
}
Expand Down Expand Up @@ -1181,6 +1183,7 @@ fn detectAbiAndDynamicLinker(
error.UnexpectedEndOfFile,
error.UnableToReadElfFile,
error.ProcessNotFound,
error.NoSuchDeviceOrAddress,
=> return defaultAbiAndDynamicLinker(cpu, os, query),

else => |e| return e,
Expand Down Expand Up @@ -1237,6 +1240,7 @@ fn detectAbiAndDynamicLinker(
error.UnexpectedEndOfFile,
error.NameTooLong,
error.StaticElfFile,
error.NoSuchDeviceOrAddress,
// 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)});
Expand Down Expand Up @@ -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.NoSuchDeviceOrAddress => return error.NoSuchDeviceOrAddress,
};
if (len == 0) return error.UnexpectedEndOfFile;
i += len;
Expand Down
Loading