From 4e017928c7b5b590d2c7e04e42cb497eb3a4f8cf Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 28 Jun 2019 12:41:26 +0200 Subject: Add support for packing sparse files This commit adds support for packing sparse files into squashfs images as follows: - In the data writer: simply detect zero blocks and write a zero to the block size field and don't emit any data. Record the number of bytes saved this way. For fragments, set the fragment offset to invalid. - In the inode writer: write out the number of bytes saved for sparse files. If there should be a fragment but there is none, append a block count of 0. - In the data reader: if the block size is 0, read nothing from disk and emit an empty block. Do the same if the fragment is missing. - In the inode reader: restore the number of bytes saved for sparse files. The sparse files can be packed and unpacked, but the unpacking will not create sparse files for now. Signed-off-by: David Oberhollenzer --- include/fstree.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/fstree.h b/include/fstree.h index 040136e..6c2ec0b 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -58,6 +58,9 @@ struct file_info_t { uint64_t size; + /* Number of bytes not written to disk because they are 0 */ + uint64_t sparse; + /* Absolute position of the first data block. */ uint64_t startblock; -- cgit v1.2.3