Dear lazyweb,
Is there a syscall to ask the system whether a file is sparse in a particular region? I.e., if I say dd if=/dev/zero of=./foo seek=10 count=10, then I should get a "yes" for the first half of the file, but a "no" for the second half.
Case in point: I need to write a test for the newly-implemented NBD_CMD_TRIM which uses fallocate with the FALLOC_FL_PUNCH_HOLE option to sparsify a file.
kthxbye,
As far as I know (and as far as the authors of core unix tools like cp know) there is no way to find out specific regions of files that are sparse.
But maybe in this specific test, you could * make sure that the region you're about to hole must have been non-sparse * look at the st_blocks before the hole-making operation * do the hole-making operation * look at the st_blocks after the hole-making operation if st_blocks has decreased, and by the size of hole you expected to punch, then it worked.