authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-18 07:34:32+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-18 07:34:32+02:00
log9636d76b6d26d142f7d23e6d25eec1c28cf571b4
tree8b9fd1906c87592d136075d390a37f9228043e33
parent21914c7c01d8d1071034153451414719906167b8

std.os.linux: getdents accepts a c_uint length (#31825)

https://github.com/torvalds/linux/blob/e774d5f1bc27a85f858bce7688509e866f8e8a4e/include/linux/syscalls.h#L1100-L1102 https://github.com/torvalds/linux/blob/e774d5f1bc27a85f858bce7688509e866f8e8a4e/include/linux/syscalls.h#L477-L479 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31825 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Co-authored-by: Meghan Denny <hello@nektro.net> Co-committed-by: Meghan Denny <hello@nektro.net>

3 files changed, 6 insertions(+), 6 deletions(-)

lib/std/Io/Threaded.zig+1-1
......@@ -5484,7 +5484,7 @@ fn dirReadLinux(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir
54845484 }
54855485 const syscall: Syscall = try .start();
54865486 const n = while (true) {
5487 const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
5487 const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
54885488 switch (linux.errno(rc)) {
54895489 .SUCCESS => {
54905490 syscall.finish();
lib/std/Io/Uring.zig+1-1
......@@ -3070,7 +3070,7 @@ fn dirRead(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Read
30703070 }
30713071 const n = while (true) {
30723072 try sync.cancel_region.await(.nothing);
3073 const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
3073 const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
30743074 switch (linux.errno(rc)) {
30753075 .SUCCESS => break rc,
30763076 .INTR => {},
lib/std/os/linux.zig+4-4
......@@ -887,21 +887,21 @@ pub fn getcwd(buf: [*]u8, size: usize) usize {
887887 return syscall2(.getcwd, @intFromPtr(buf), size);
888888}
889889
890pub fn getdents(fd: fd_t, dirp: [*]u8, len: usize) usize {
890pub fn getdents(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
891891 return syscall3(
892892 .getdents,
893893 @as(u32, @bitCast(fd)),
894894 @intFromPtr(dirp),
895 @min(len, maxInt(c_int)),
895 len,
896896 );
897897}
898898
899pub fn getdents64(fd: fd_t, dirp: [*]u8, len: usize) usize {
899pub fn getdents64(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
900900 return syscall3(
901901 .getdents64,
902902 @as(u32, @bitCast(fd)),
903903 @intFromPtr(dirp),
904 @min(len, maxInt(c_int)),
904 len,
905905 );
906906}
907907