Skip to content

Commit

Permalink
add NotLink error (ziglang#9877)
Browse files Browse the repository at this point in the history
Closes ziglang#9872

Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
  • Loading branch information
alichraghi and squeek502 committed Nov 20, 2021
1 parent 3fefdc1 commit a699d67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/std/os.zig
Expand Up @@ -2674,6 +2674,7 @@ pub const ReadLinkError = error{
NameTooLong,
FileNotFound,
SystemResources,
NotLink,
NotDir,
InvalidUtf8,
BadPathName,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}
};
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/std/zig/system.zig
Expand Up @@ -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,
Expand Down Expand Up @@ -892,6 +893,7 @@ pub const NativeTargetInfo = struct {

error.AccessDenied,
error.FileNotFound,
error.NotLink,
error.NotDir,
=> continue,

Expand Down

0 comments on commit a699d67

Please sign in to comment.