mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
dragonfly: getFdPath: F_GETPATH implementation
This commit is contained in:
parent
7f012eef0b
commit
7da9348637
2 changed files with 15 additions and 0 deletions
|
|
@ -419,6 +419,7 @@ pub const F = struct {
|
||||||
pub const DUP2FD = 10;
|
pub const DUP2FD = 10;
|
||||||
pub const DUPFD_CLOEXEC = 17;
|
pub const DUPFD_CLOEXEC = 17;
|
||||||
pub const DUP2FD_CLOEXEC = 18;
|
pub const DUP2FD_CLOEXEC = 18;
|
||||||
|
pub const GETPATH = 19;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FD_CLOEXEC = 1;
|
pub const FD_CLOEXEC = 1;
|
||||||
|
|
|
||||||
|
|
@ -5181,6 +5181,20 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
|
||||||
return error.InvalidHandle;
|
return error.InvalidHandle;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
.dragonfly => {
|
||||||
|
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 6, .minor = 0 }) == .lt) {
|
||||||
|
@compileError("querying for canonical path of a handle is unsupported on this host");
|
||||||
|
}
|
||||||
|
@memset(out_buffer, 0, MAX_PATH_BYTES);
|
||||||
|
switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
|
||||||
|
.SUCCESS => {},
|
||||||
|
.BADF => return error.FileNotFound,
|
||||||
|
.RANGE => return error.NameTooLong,
|
||||||
|
else => |err| return unexpectedErrno(err),
|
||||||
|
}
|
||||||
|
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
|
||||||
|
return out_buffer[0..len];
|
||||||
|
},
|
||||||
else => @compileError("querying for canonical path of a handle is unsupported on this host"),
|
else => @compileError("querying for canonical path of a handle is unsupported on this host"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue