aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAli Chraghi <63465728+AliChraghi@users.noreply.github.com>2021-11-21 00:19:22 +0330
committerGitHub <noreply@github.com>2021-11-20 15:49:22 -0500
commita699d678b2c81dcf333a4f4bb84676836849a618 (patch)
treee7194fe8f4796b6b6aca92e7dcd807cf4605fb2a /lib/std
parent3fefdc1a0b3177519aea8e8309983a41957555ab (diff)
downloadzig-a699d678b2c81dcf333a4f4bb84676836849a618.tar.gz
zig-a699d678b2c81dcf333a4f4bb84676836849a618.zip
add `NotLink` error (#9877)
Closes #9872 Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/os.zig9
-rw-r--r--lib/std/zig/system.zig2
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig
index cfb0ccd6c7..a7ddf33b5c 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 316a2d1451..3e2518cb52 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,