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{...@@ -2674,6 +2674,7 @@ pub const ReadLinkError = error{
2674 NameTooLong,2674 NameTooLong,
2675 FileNotFound,2675 FileNotFound,
2676 SystemResources,2676 SystemResources,
2677 NotLink,
2677 NotDir,2678 NotDir,
2678 InvalidUtf8,2679 InvalidUtf8,
2679 BadPathName,2680 BadPathName,
...@@ -2715,7 +2716,7 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8...@@ -2715,7 +2716,7 @@ pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8
2715 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],2716 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],
2716 .ACCES => return error.AccessDenied,2717 .ACCES => return error.AccessDenied,
2717 .FAULT => unreachable,2718 .FAULT => unreachable,
2718 .INVAL => unreachable,2719 .INVAL => return error.NotLink,
2719 .IO => return error.FileSystem,2720 .IO => return error.FileSystem,
2720 .LOOP => return error.SymLinkLoop,2721 .LOOP => return error.SymLinkLoop,
2721 .NAMETOOLONG => return error.NameTooLong,2722 .NAMETOOLONG => return error.NameTooLong,
...@@ -2751,7 +2752,7 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read...@@ -2751,7 +2752,7 @@ pub fn readlinkatWasi(dirfd: fd_t, file_path: []const u8, out_buffer: []u8) Read
2751 .SUCCESS => return out_buffer[0..bufused],2752 .SUCCESS => return out_buffer[0..bufused],
2752 .ACCES => return error.AccessDenied,2753 .ACCES => return error.AccessDenied,
2753 .FAULT => unreachable,2754 .FAULT => unreachable,
2754 .INVAL => unreachable,2755 .INVAL => return error.NotLink,
2755 .IO => return error.FileSystem,2756 .IO => return error.FileSystem,
2756 .LOOP => return error.SymLinkLoop,2757 .LOOP => return error.SymLinkLoop,
2757 .NAMETOOLONG => return error.NameTooLong,2758 .NAMETOOLONG => return error.NameTooLong,
...@@ -2781,7 +2782,7 @@ pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) Read...@@ -2781,7 +2782,7 @@ pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) Read
2781 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],2782 .SUCCESS => return out_buffer[0..@bitCast(usize, rc)],
2782 .ACCES => return error.AccessDenied,2783 .ACCES => return error.AccessDenied,
2783 .FAULT => unreachable,2784 .FAULT => unreachable,
2784 .INVAL => unreachable,2785 .INVAL => return error.NotLink,
2785 .IO => return error.FileSystem,2786 .IO => return error.FileSystem,
2786 .LOOP => return error.SymLinkLoop,2787 .LOOP => return error.SymLinkLoop,
2787 .NAMETOOLONG => return error.NameTooLong,2788 .NAMETOOLONG => return error.NameTooLong,
...@@ -4758,6 +4759,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -4758,6 +4759,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
4758 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {4759 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {
4759 switch (err) {4760 switch (err) {
4760 error.UnsupportedReparsePointType => unreachable, // Windows only,4761 error.UnsupportedReparsePointType => unreachable, // Windows only,
4762 error.NotLink => unreachable,
4761 else => |e| return e,4763 else => |e| return e,
4762 }4764 }
4763 };4765 };
...@@ -4769,6 +4771,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -4769,6 +4771,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
47694771
4770 const target = readlinkZ(proc_path, out_buffer) catch |err| switch (err) {4772 const target = readlinkZ(proc_path, out_buffer) catch |err| switch (err) {
4771 error.UnsupportedReparsePointType => unreachable,4773 error.UnsupportedReparsePointType => unreachable,
4774 error.NotLink => unreachable,
4772 else => |e| return e,4775 else => |e| return e,
4773 };4776 };
4774 return target;4777 return target;
lib/std/zig/system.zig+2
...@@ -614,6 +614,7 @@ pub const NativeTargetInfo = struct {...@@ -614,6 +614,7 @@ pub const NativeTargetInfo = struct {
614 error.FileSystem => return error.FileSystem,614 error.FileSystem => return error.FileSystem,
615 error.SymLinkLoop => return error.SymLinkLoop,615 error.SymLinkLoop => return error.SymLinkLoop,
616 error.NameTooLong => unreachable,616 error.NameTooLong => unreachable,
617 error.NotLink => return error.GnuLibCVersionUnavailable,
617 error.FileNotFound => return error.GnuLibCVersionUnavailable,618 error.FileNotFound => return error.GnuLibCVersionUnavailable,
618 error.SystemResources => return error.SystemResources,619 error.SystemResources => return error.SystemResources,
619 error.NotDir => return error.GnuLibCVersionUnavailable,620 error.NotDir => return error.GnuLibCVersionUnavailable,
...@@ -892,6 +893,7 @@ pub const NativeTargetInfo = struct {...@@ -892,6 +893,7 @@ pub const NativeTargetInfo = struct {
892893
893 error.AccessDenied,894 error.AccessDenied,
894 error.FileNotFound,895 error.FileNotFound,
896 error.NotLink,
895 error.NotDir,897 error.NotDir,
896 => continue,898 => continue,
897899