From 710632b45cd7a7081af82af418eb3e405f7aa35e Mon Sep 17 00:00:00 2001 From: Pat Tullmann Date: Sun, 22 Jun 2025 20:48:35 -0700 Subject: [PATCH] lib/std/fs/test.zig: Some filesystems support 8 EiB files Btrfs at least supports 16 EiB files (limited in practice to 8EiB by the Linux VFS code which uses signed 64-bit offsets). So fix the fs.zig test case to expect either a FileTooBig or success from truncating a file to 8EiB. And test that beyond that size the offset is interpreted as a negative number. Fixes #24242 --- lib/std/fs/test.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 6593e7024d..99b6dd3920 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1435,14 +1435,17 @@ test "setEndPos" { try testing.expectEqual(0, try f.preadAll(&buffer, 0)); // Invalid file length should error gracefully. Actual limit is host - // and file-system dependent, but 1PB should fail most everywhere. - // Except MacOS APFS limit is 8 exabytes. + // and file-system dependent, but 1PB should fail on filesystems like + // EXT4 and NTFS. But XFS or Btrfs support up to 8EiB files. f.setEndPos(0x4_0000_0000_0000) catch |err| if (err != error.FileTooBig) { return err; }; - try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63))); // Maximum signed value + f.setEndPos(std.math.maxInt(u63)) catch |err| if (err != error.FileTooBig) { + return err; + }; + try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63) + 1)); try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u64))); }