authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:33-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:33-05:00
loge7526064641c41187ea4e8f6acfb461ac038ea73
treedb38433bb413499810a4b83dd65630b869e85f5c
parent1a403383c9d8c6d3aacae16162f72d911350fd17
signaturelock-open Commit is signed but in an unrecognized format.

netbsd: getFdPath: F_GETPATH implementation


2 files changed, 23 insertions(+), 2 deletions(-)

lib/std/c/netbsd.zig+6-2
...@@ -690,13 +690,17 @@ pub const F = struct {...@@ -690,13 +690,17 @@ pub const F = struct {
690 pub const SETFD = 2;690 pub const SETFD = 2;
691 pub const GETFL = 3;691 pub const GETFL = 3;
692 pub const SETFL = 4;692 pub const SETFL = 4;
693
694 pub const GETOWN = 5;693 pub const GETOWN = 5;
695 pub const SETOWN = 6;694 pub const SETOWN = 6;
696
697 pub const GETLK = 7;695 pub const GETLK = 7;
698 pub const SETLK = 8;696 pub const SETLK = 8;
699 pub const SETLKW = 9;697 pub const SETLKW = 9;
698 pub const CLOSEM = 10;
699 pub const MAXFD = 11;
700 pub const DUPFD_CLOEXEC = 12;
701 pub const GETNOSIGPIPE = 13;
702 pub const SETNOSIGPIPE = 14;
703 pub const GETPATH = 15;
700704
701 pub const RDLCK = 1;705 pub const RDLCK = 1;
702 pub const WRLCK = 3;706 pub const WRLCK = 3;
lib/std/os.zig+17
...@@ -5195,6 +5195,23 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -5195,6 +5195,23 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
5195 const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;5195 const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
5196 return out_buffer[0..len];5196 return out_buffer[0..len];
5197 },5197 },
5198 .netbsd => {
5199 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 10, .minor = 0 }) == .lt) {
5200 @compileError("querying for canonical path of a handle is unsupported on this host");
5201 }
5202 @memset(out_buffer, 0, MAX_PATH_BYTES);
5203 switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
5204 .SUCCESS => {},
5205 .ACCES => return error.AccessDenied,
5206 .BADF => return error.FileNotFound,
5207 .NOENT => return error.FileNotFound,
5208 .NOMEM => return error.SystemResources,
5209 .RANGE => return error.NameTooLong,
5210 else => |err| return unexpectedErrno(err),
5211 }
5212 const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
5213 return out_buffer[0..len];
5214 },
5198 else => @compileError("querying for canonical path of a handle is unsupported on this host"),5215 else => @compileError("querying for canonical path of a handle is unsupported on this host"),
5199 }5216 }
5200}5217}