How to get sparse block size and check if data is present at the given offset in sparse file in reiserfs/ext3 in Linux?
I want to use it to implement simple copy-on-write block device using FUSE.
Or I should better keep a bitmap in a separate file?
How to get sparse block size and check if data is present at the given offset in sparse file in reiserfs/ext3 in Linux?
I want to use it to implement simple copy-on-write block device using FUSE.
Or I should better keep a bitmap in a separate file?
/usr/src/linux/Documentation/filesystems/fiemap.txt
There's a quick example of usage in git://kernel.ubuntu.com/cking/debug-code/fiemap/. A sparse file will lack extents for the "missing" portions.
Since Linux 3.1,
lseek
provides flagsSEEK_HOLE
andSEEK_DATA
to navigate to the beginning or end of a hole, so this might be an alternative to theioctl
based solution. Haven't tried either in practice, so I don't have any real experience to compare the two.Well, http://lxr.linux.no/#linux+v2.6.33/arch/um/drivers/cow_user.c indicates that User Mode Linux uses an explicit bitmap for this, FWIW.