[LTP] [PATCH v2] fstat_02: Increase test coverage by creating hard link to file and validate using fstat
Cyril Hrubis
chrubis@suse.cz
Wed Feb 23 13:43:19 CET 2022
Hi!
> Apology for the late reply.
>
> I am not sure about the st_blocks size. If you can guide me how to check
> that I might work on that?
Just read the man 2 stat:
...
blkcnt_t st_blocks; /* Number of 512B blocks allocated */
...
For large enough files the size/512 rounded up should be close to the
number of blocks (there would be usually a few more blocks preallocated
for the file than the actuall size is). Filesystems tend to allocate
more than one block when file needs to be extended, it looks like common
value is PAGE_SIZE/512. So I guess that a reasonable test would create a
few files somewhere between half a megabyte and a few megabytes in size
and then check that the size/blocks ratio is somewhere between 512 and
512-epsilon. As long as the file size is order of magnitude larger than
PAGE_SIZE it should be safe to set the epsion to 10% of the blocksize
i.e. 51.
> Are you planning to merge this patch with the st_blocks check or the
> current version is ready to be merged?
The patch has been already merged, I was just pointing out other fields
that are not validated in the test.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list