Understanding reported block count for sparse files

From: Roman Bogorodskiy <novel_at_freebsd.org>
Date: Wed, 23 Jul 2025 18:30:48 UTC
Hi,

I'm porting a test from Linux, and this test checks the allocated block
count for the sparse file. Its expectation is that the block count
should be close to zero.

To isolate things, it roughly does the following:

Linux:

$ truncate -s +52428800 test.raw
$ stat test.raw
  File: test.raw
  Size: 52428800        Blocks: 0          IO Block: 4096   regular file
Device: 252,0   Inode: 25218599    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   novel)   Gid: ( 1000/   novel)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2025-07-23 14:20:31.640547511 -0400
Modify: 2025-07-23 14:20:31.642105574 -0400
Change: 2025-07-23 14:20:31.642105574 -0400
 Birth: 2025-07-23 14:20:31.640547511 -0400

It reports 0 blocks.
Filesystem here is xfs.

FreeBSD:

$ truncate -s +52428800 test.raw
$ stat -f "%z %k %b" test.raw   
52428800 32768 128

This reports 128 blocks. Filesystem here is UFS.

What's reason behind this difference? 

Thanks,
Roman