What are functions to manupulate sparse files under Linux? (let's say in C, notes about other systems highly welcome) e.g.:
- make hole inside of file by removing part of its inside
- investigate structure , e.g. generate sequence of pairs denoting beginnings and ends of separated continuous blocks of data
- split file into two at some point, by reassigning range of blocks (i.e. without moving actual data)
- investigate inodes, and other relevant aspects? (maybe possible to assign some blocks to multiple files in copy-on-write manner?)
Original question that come to my mind and I arrived from was after
man rsync of
--sparse option conflicts with
Is it limitation of filesystem calls api?
From data structure point of view, if source sparse file is seen as sequence of non-continuous blocks of data, than I would expect from "r"syncing to deallocate on destination those ranges that does not exist at source, allocate missing ones, rest update accordingly (even with standard rsync rolling hash algorithm, treating all remaining sequences as one, or running separately on each).
-S, --sparse Try to handle sparse files efficiently so they take up less space on the destination. Conflicts with --inplace because it's
not possible to over- write data in a sparse fashion.