Summary
blocks() returns ceil(size / blksize) — the number of filesystem blocks — but POSIX stat(2) defines st_blocks as the count of 512-byte units, regardless of st_blksize.
Reproduction
use Test::MockFile qw< nostrict >;
my $mock = Test::MockFile->file('/tmp/test', 'hello');
my @stat = stat('/tmp/test');
print "mock blocks: $stat[12]\n"; # prints 1
# Real Perl:
use File::Temp qw(tempfile);
my ($fh, $name) = tempfile();
print $fh "hello"; close $fh;
my @real = stat($name);
print "real blocks: $real[12]\n"; # prints 8
Expected
stat[12] should be 8 (one 4096-byte filesystem block = 8 × 512-byte units).
Actual
stat[12] is 1.
Impact
Any code under test that relies on $stat[12] for disk space calculations (e.g., du-like logic, quota checks) will get incorrect results from mocked files.
Fix
PR #348
🤖 Created by Kōan from audit session