add NotLink error (#9877)

Closes #9872

Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
This commit is contained in:
Ali Chraghi 2021-11-21 00:19:22 +03:30 committed by GitHub
parent 3fefdc1a0b
commit a699d678b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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;

View File

@ -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,