diff --git a/lib/std/os.zig b/lib/std/os.zig index cfb0ccd6c70c..a7ddf33b5c27 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -2674,6 +2674,7 @@ pub const ReadLinkError = error{ NameTooLong, FileNotFound, SystemResources, + NotLink, NotDir, InvalidUtf8, BadPathName, @@ -2715,7 +2716,7 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)], .ACCES => return error.AccessDenied, .FAULT => unreachable, - .INVAL => unreachable, + .INVAL => return error.NotLink, .IO => return error.FileSystem, .LOOP => return error.SymLinkLoop, .NAMETOOLONG => return error.NameTooLong, @@ -2751,7 +2752,7 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read .SUCCESS => return out_buffer[0..bufused], .ACCES => return error.AccessDenied, .FAULT => unreachable, - .INVAL => unreachable, + .INVAL => return error.NotLink, .IO => return error.FileSystem, .LOOP => return error.SymLinkLoop, .NAMETOOLONG => return error.NameTooLong, @@ -2781,7 +2782,7 @@ pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) Read .SUCCESS => return out_buffer[0..@bitCast(usize, rc)], .ACCES => return error.AccessDenied, .FAULT => unreachable, - .INVAL => unreachable, + .INVAL => return error.NotLink, .IO => return error.FileSystem, .LOOP => return error.SymLinkLoop, .NAMETOOLONG => return error.NameTooLong, @@ -4758,6 +4759,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| { switch (err) { error.UnsupportedReparsePointType => unreachable, // Windows only, + error.NotLink => unreachable, else => |e| return e, } }; @@ -4769,6 +4771,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { const target = readlinkZ(proc_path, out_buffer) catch |err| switch (err) { error.UnsupportedReparsePointType => unreachable, + error.NotLink => unreachable, else => |e| return e, }; return target; diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 316a2d14513a..3e2518cb5281 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -614,6 +614,7 @@ pub const NativeTargetInfo = struct { error.FileSystem => return error.FileSystem, error.SymLinkLoop => return error.SymLinkLoop, error.NameTooLong => unreachable, + error.NotLink => return error.GnuLibCVersionUnavailable, error.FileNotFound => return error.GnuLibCVersionUnavailable, error.SystemResources => return error.SystemResources, error.NotDir => return error.GnuLibCVersionUnavailable, @@ -892,6 +893,7 @@ pub const NativeTargetInfo = struct { error.AccessDenied, error.FileNotFound, + error.NotLink, error.NotDir, => continue,