authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-12-28 22:20:26 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-12-28 22:20:26 -08:00
log1801d0cdde61ac06001a9722cb61e0214d937305
tree7d211b55ef4b40eb2e4dcf7e12beb930caadce0c
parent93300601f41052dad125f28ed83052f647f22203

add fstatat


1 files changed, 12 insertions(+), 0 deletions(-)

mod.zig+12
...@@ -1334,6 +1334,10 @@ pub const libc = struct {...@@ -1334,6 +1334,10 @@ pub const libc = struct {
1334 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fstat.html1334 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fstat.html
1335 pub extern fn fstat(fd: c_int, buf: *struct_stat) c_int;1335 pub extern fn fstat(fd: c_int, buf: *struct_stat) c_int;
13361336
1337 /// int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag);
1338 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fstatat.html
1339 pub extern fn fstatat(fd: c_int, noalias path: [*:0]const u8, noalias buf: *struct_stat, flag: c_int) c_int;
1340
1337 /// int getchar(void);1341 /// int getchar(void);
1338 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar.html1342 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar.html
1339 pub extern fn getchar() c_int;1343 pub extern fn getchar() c_int;
...@@ -1643,3 +1647,11 @@ pub fn pthread_self() pthread_t {...@@ -1643,3 +1647,11 @@ pub fn pthread_self() pthread_t {
1643pub fn gettid() pid_t {1647pub fn gettid() pid_t {
1644 return libc.gettid();1648 return libc.gettid();
1645}1649}
1650
1651pub fn fstatat(fd: c_int, path: [*:0]const u8, flag: c_int) errno.Error!struct_stat {
1652 var buf: struct_stat = undefined;
1653 const rc = libc.fstatat(fd, path, &buf, flag);
1654 if (rc == -1) return errno.fromInt(errno.fromLibC());
1655 std.debug.assert(rc == 0);
1656 return buf;
1657}