I was debugging a fuse filesystem that was reporting wrong sizes for du. It turned out that it was putting st_size / st_blksize [*] into st_blocks of the stat structure. The Linux manual page for stat(2) says:
struct stat {
…
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
…
};
What is st_blksize for if st_blocks is in 512B blocks anyway?
[*] which looks wrong anyway, as integer division doesn't account for the fractional part…