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?
In computer science, a sparse file is a type of computer file that attempts to use file system space more efficiently when the file itself is partially empty.
Sparse Files are a type of computer file that allows for efficient storage allocation for large data. A file is considered to be sparse when much of its data is zero (empty data). Support for the creation of such files is generally provided by the File system.
Sparse file is a type of computer file, which generally has file size (logical) higher than allocated size (clusters allocated to data of the file). Most File systems support this type of file, but Operating system suppresses them underneath command interpreters' command or API calls.
/usr/src/linux/Documentation/filesystems/fiemap.txt
The fiemap ioctl is an efficient method for userspace to get file extent mappings. Instead of block-by-block mapping (such as bmap), fiemap returns a list of extents.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With