mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 18:51:44 +03:00
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>
This commit is contained in:
committed by
Andrew Kelley
parent
21914c7c01
commit
9636d76b6d
@@ -5484,7 +5484,7 @@ fn dirReadLinux(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir
|
||||
}
|
||||
const syscall: Syscall = try .start();
|
||||
const n = while (true) {
|
||||
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
|
||||
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
|
||||
switch (linux.errno(rc)) {
|
||||
.SUCCESS => {
|
||||
syscall.finish();
|
||||
|
||||
@@ -3070,7 +3070,7 @@ fn dirRead(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Read
|
||||
}
|
||||
const n = while (true) {
|
||||
try sync.cancel_region.await(.nothing);
|
||||
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
|
||||
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
|
||||
switch (linux.errno(rc)) {
|
||||
.SUCCESS => break rc,
|
||||
.INTR => {},
|
||||
|
||||
@@ -887,21 +887,21 @@ pub fn getcwd(buf: [*]u8, size: usize) usize {
|
||||
return syscall2(.getcwd, @intFromPtr(buf), size);
|
||||
}
|
||||
|
||||
pub fn getdents(fd: fd_t, dirp: [*]u8, len: usize) usize {
|
||||
pub fn getdents(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
|
||||
return syscall3(
|
||||
.getdents,
|
||||
@as(u32, @bitCast(fd)),
|
||||
@intFromPtr(dirp),
|
||||
@min(len, maxInt(c_int)),
|
||||
len,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn getdents64(fd: fd_t, dirp: [*]u8, len: usize) usize {
|
||||
pub fn getdents64(fd: fd_t, dirp: [*]u8, len: c_uint) usize {
|
||||
return syscall3(
|
||||
.getdents64,
|
||||
@as(u32, @bitCast(fd)),
|
||||
@intFromPtr(dirp),
|
||||
@min(len, maxInt(c_int)),
|
||||
len,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user