authorgravatar for pat.github@tullmann.orgPat Tullmann <pat.github@tullmann.org> 2025-06-22 20:48:35-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-23 15:20:24+02:00
log710632b45cd7a7081af82af418eb3e405f7aa35e
tree00eb10fdf4662357e7ee57773932e36cb74d68d3
parent640a130651ee39f8d8f5afc9498574c10af18ba9

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

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

lib/std/fs/test.zig+6-3
...@@ -1435,14 +1435,17 @@ test "setEndPos" {...@@ -1435,14 +1435,17 @@ test "setEndPos" {
1435 try testing.expectEqual(0, try f.preadAll(&buffer, 0));1435 try testing.expectEqual(0, try f.preadAll(&buffer, 0));
14361436
1437 // Invalid file length should error gracefully. Actual limit is host1437 // Invalid file length should error gracefully. Actual limit is host
1438 // and file-system dependent, but 1PB should fail most everywhere.1438 // and file-system dependent, but 1PB should fail on filesystems like
1439 // Except MacOS APFS limit is 8 exabytes.1439 // EXT4 and NTFS. But XFS or Btrfs support up to 8EiB files.
1440 f.setEndPos(0x4_0000_0000_0000) catch |err| if (err != error.FileTooBig) {1440 f.setEndPos(0x4_0000_0000_0000) catch |err| if (err != error.FileTooBig) {
1441 return err;1441 return err;
1442 };1442 };
14431443
1444 try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63))); // Maximum signed value1444 f.setEndPos(std.math.maxInt(u63)) catch |err| if (err != error.FileTooBig) {
1445 return err;
1446 };
14451447
1448 try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63) + 1));
1446 try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u64)));1449 try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u64)));
1447}1450}
14481451