summaryrefslogtreecommitdiff
path: root/lib/sqfs/write_inode.c
AgeCommit message (Collapse)Author
2019-06-28Add support for packing sparse filesDavid Oberhollenzer
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 <david.oberhollenzer@sigma-star.at>
2019-06-28Fix inode fragment & sparse counter initializationDavid Oberhollenzer
The sparse attribute should be initialized with 0. It is subtracted from the file size in the kernel to determine the file size on disk to report to stat(2). So it actually didn't matter anyway (just for correctness sake). Second, the fragment index and offset should be set to 0xFFFFFFFF in the rare case that no fragments exist. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-19Cleanup fstree codeDavid Oberhollenzer
Replace default_$FIELD with a struct stat. Merge the rest of add_node/add_file into mknode and add by path+stat. Expose the mknode function and replace all the duplicated node pointer arithmetic magic with a call to mknode. Plus a generic cleanup by utlizing new util functions. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-10cleanup: move entire fstree serialization to libsqfs.aDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>