authorgravatar for 63465728+AliChraghi@users.noreply.github.comAli Chraghi <63465728+AliChraghi@users.noreply.github.com> 2021-11-21 00:19:22+03:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-11-20 15:49:22-05:00
loga699d678b2c81dcf333a4f4bb84676836849a618
treee7194fe8f4796b6b6aca92e7dcd807cf4605fb2a
parent3fefdc1a0b3177519aea8e8309983a41957555ab
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

add `NotLink` error (#9877)

Closes #9872 Co-authored-by: Ryan Liptak <squeek502@hotmail.com>

2 files changed, 8 insertions(+), 3 deletions(-)

lib/std/os.zig+6-3
......@@ -2674,6 +2674,7 @@ pub const ReadLinkError = error{
26742674 NameTooLong,
26752675 FileNotFound,
26762676 SystemResources,
2677 NotLink,
26772678 NotDir,
26782679 InvalidUtf8,
26792680 BadPathName,
......@@ -2715,7 +2716,7 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8
27152716 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],
27162717 .ACCES => return error.AccessDenied,
27172718 .FAULT => unreachable,
2718 .INVAL => unreachable,
2719 .INVAL => return error.NotLink,
27192720 .IO => return error.FileSystem,
27202721 .LOOP => return error.SymLinkLoop,
27212722 .NAMETOOLONG => return error.NameTooLong,
......@@ -2751,7 +2752,7 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read
27512752 .SUCCESS => return out_buffer[0..bufused],
27522753 .ACCES => return error.AccessDenied,
27532754 .FAULT => unreachable,
2754 .INVAL => unreachable,
2755 .INVAL => return error.NotLink,
27552756 .IO => return error.FileSystem,
27562757 .LOOP => return error.SymLinkLoop,
27572758 .NAMETOOLONG => return error.NameTooLong,
......@@ -2781,7 +2782,7 @@ pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) Read
27812782 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],
27822783 .ACCES => return error.AccessDenied,
27832784 .FAULT => unreachable,
2784 .INVAL => unreachable,
2785 .INVAL => return error.NotLink,
27852786 .IO => return error.FileSystem,
27862787 .LOOP => return error.SymLinkLoop,
27872788 .NAMETOOLONG => return error.NameTooLong,
......@@ -4758,6 +4759,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
47584759 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {
47594760 switch (err) {
47604761 error.UnsupportedReparsePointType => unreachable, // Windows only,
4762 error.NotLink => unreachable,
47614763 else => |e| return e,
47624764 }
47634765 };
......@@ -4769,6 +4771,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
47694771
47704772 const target = readlinkZ(proc_path, out_buffer) catch |err| switch (err) {
47714773 error.UnsupportedReparsePointType => unreachable,
4774 error.NotLink => unreachable,
47724775 else => |e| return e,
47734776 };
47744777 return target;
lib/std/zig/system.zig+2
......@@ -614,6 +614,7 @@ pub const NativeTargetInfo = struct {
614614 error.FileSystem => return error.FileSystem,
615615 error.SymLinkLoop => return error.SymLinkLoop,
616616 error.NameTooLong => unreachable,
617 error.NotLink => return error.GnuLibCVersionUnavailable,
617618 error.FileNotFound => return error.GnuLibCVersionUnavailable,
618619 error.SystemResources => return error.SystemResources,
619620 error.NotDir => return error.GnuLibCVersionUnavailable,
......@@ -892,6 +893,7 @@ pub const NativeTargetInfo = struct {
892893
893894 error.AccessDenied,
894895 error.FileNotFound,
896 error.NotLink,
895897 error.NotDir,
896898 => continue,
897899