[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Finding the holes in sparse files.

Sean McCauliff wrote:
> Is there a way to find the holes in sparse files, other than assuming
> contiguous blocks of zeroes are holes?

yes, programatically you can use a couple ioctls:
fibmap (block-at-a-time) or fiemap in newer kernels.

If you want a commandline, try filefrag -v.

For ioctl usage examples, take a look at how filefrag is implemented.

# dd if=/dev/zero of=testfile bs=4k count=1; dd if=/dev/zero of=testfile conv=notrunc bs=4k seek=4 count=1
# sync
# filefrag -v testfile
Filesystem type is: ef53
File size of testfile is 20480 (5 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  1829913               1 
   1       4  1802777  1829913      1 eof
testfile: 2 extents found

the logical+length gap shows you that there was a hole in there

Andreas has patches to make it still clearer in the table output.


> Thanks,
> Sean
> _______________________________________________
> Ext3-users mailing list
> Ext3-users redhat com
> https://www.redhat.com/mailman/listinfo/ext3-users

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]