I have a sparse file, in which only some blocks are allocated:
~% du -h --apparent-size example 100K example ~% du -h example 52K example
I would like to know which blocks of the file are actually allocated. Is there a system call or kernel interface that could be used to get a list of either the allocations, or the holes of file?
Simply checking for a long enough string of zeros (the approach used by GNU cp, rsync, etc) does not work correctly:
~% cp example example1 ~% du -h example1 32K example1
It detected other sequences of zeros that were actually allocated.