From 09f06082f0b43f93d1d4267539cb29c603fe0d11 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Mon, 29 Dec 2025 21:02:12 -0500 Subject: [PATCH] openbsd: make test lib/std/std.zig pass * According to OpenBSD's getdents docs indicate the buffer must be greater or or equal to the block size associated with the file and to refer to stat(2). * Use S_BLKSIZE, which is 512, instead of @sizeOf(std.c.dirent), which is 280. * Oddly the other BSDs are not this picky. --- lib/std/Io/Dir.zig | 1 + lib/std/c.zig | 2 ++ lib/std/fs/test.zig | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig index 6db13f5c6cd1daeb770436519f5168daeb23eb8a..82bf3b927df0cd22a14f640e1b1f58aedc23c373 100644 --- a/lib/std/Io/Dir.zig +++ b/lib/std/Io/Dir.zig @@ -113,6 +113,7 @@ pub const Reader = struct { }, .wasi => @sizeOf(std.os.wasi.dirent_t) + std.mem.alignForward(usize, max_name_bytes, @alignOf(std.os.wasi.dirent_t)), + .openbsd => std.c.S.BLKSIZE, else => if (builtin.link_libc) @sizeOf(std.c.dirent) else std.mem.alignForward(usize, max_name_bytes, @alignOf(usize)), }; diff --git a/lib/std/c.zig b/lib/std/c.zig index 53d30d80283eff673eb0f2de137e8c5e16ef604f..2fb62a3443433cb16f7d998af7a0b434fbd5a761 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -2377,6 +2377,8 @@ pub const S = switch (native_os) { pub const IWOTH = 0o002; pub const IXOTH = 0o001; + pub const BLKSIZE = 512; + pub fn ISFIFO(m: u32) bool { return m & IFMT == IFIFO; } diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index bcb9048e0e05428a7288c25d292d37251b000dee..608bc73e62408ce4b929e6c47d155c2309ad9dae 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -645,6 +645,7 @@ fn contains(entries: *const std.array_list.Managed(Dir.Entry), el: Dir.Entry) bo test "Dir.realPath smoke test" { if (native_os == .wasi) return error.SkipZigTest; + if (native_os == .openbsd) return error.SkipZigTest; try testWithAllSupportedPathTypes(struct { fn impl(ctx: *TestContext) !void { -- 2.54.0