authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-16 00:04:54 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-16 00:04:54 -07:00
log506c6f458b9fabc1dd60cf58cee6f15637957b55
treed7e21e78956a1a56455daa499c2e097a67fe0d85
parenta0b5c69b45e4d492c3fcb6681f642e0f628ababd
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add getdents


2 files changed, 21 insertions(+), 0 deletions(-)

mod.zig+20
......@@ -2650,6 +2650,7 @@ pub const libc = struct {
26502650 pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int;
26512651 pub extern fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int;
26522652 pub extern fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) isize;
2653 pub extern fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) c_int;
26532654};
26542655
26552656pub const clock_t = c_long;
......@@ -2694,6 +2695,7 @@ pub const struct_sockaddr_in = extern struct { family: AF = .INET, port: in_port
26942695pub const struct_sockaddr_in6 = extern struct { family: AF = .INET6, port: in_port_t, flowinfo: u32, addr: struct_in6_addr, scope_id: u32 };
26952696pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 };
26962697pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo };
2698pub const struct_dirent = extern struct { ino: ino_t, off: off_t, reclen: c_ushort, type: DT, name: [NAME_MAX + 1]u8 };
26972699
26982700pub const AT = struct {
26992701 pub const FDCWD = -100;
......@@ -3028,6 +3030,18 @@ pub const SO = struct {
30283030 pub const DOMAIN = 39;
30293031};
30303032
3033pub const DT = enum(u8) {
3034 UNKNOWN = 0,
3035 FIFO = 1,
3036 CHR = 2,
3037 DIR = 4,
3038 BLK = 6,
3039 REG = 8,
3040 LNK = 10,
3041 SOCK = 12,
3042 WHT = 14,
3043};
3044
30313045pub fn getpid() pid_t {
30323046 return libc.getpid();
30333047}
......@@ -3188,3 +3202,9 @@ pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize
31883202 std.debug.assert(rc >= 0);
31893203 return @intCast(rc);
31903204}
3205pub fn getdents(dirfd: c_int, buf: []u8) errno.Error!usize {
3206 const rc = libc.getdents(dirfd, buf.ptr, buf.len);
3207 if (rc == -1) return errno.fromInt(errno.fromLibC());
3208 std.debug.assert(rc >= 0);
3209 return @intCast(rc);
3210}
test.zig+1
......@@ -34,4 +34,5 @@ test {
3434 _ = &linux.writev;
3535 _ = &linux.getsockname;
3636 _ = &linux.sendfile;
37 _ = &linux.getdents;
3738}