> SEEK_HOLE could provide a very simple heuristic to detect preallocated > files (unfortunately ext4 does not implement SEEK_HOLE yet). SEEK_HOLE is a weird (confusing and no intuitive) API (IMO). There is FIEMAP or whatever it's called which seems somewhat saner. XFS specific there is also GETBMAP[X]. Simplest still compare the blocks allocated by the file to it's length (ie. stat.st_blocks != stat.st_size>>9).