squashfs

Squashfs check compressed file size


is there any way to check the final size of a specific file after compression in a squashfs filesystem?

I'm looking through mksquashfs/unsquashfs command line options but I can't find anything.

Using the -info option in mksquashfs only prints the size before the compression.

Thanks


Solution

  • This isn't feasible to do with much granularity, because compression is done at block level, not file level.

    A file may be marked at starting 50kb into the size of the buffer created by decompressing block 50, and continuing to end 50 bytes into the decompressed block 52 (ignoring fragments here, which are a separate concern) -- but that doesn't let you map back to the position inside the compressed copy of block-50 where that file starts. (You can easily determine the compression ratio for block 51, but you can't easily figure out the ratios for the parts of the file contained in 50 and 52 in our example, because they're shared with other contents).

    So the information isn't exposed because it isn't easily available. This actually makes storage of numerous (similar) small files significantly more efficient, because a single compression context is used for all of them (and decompressing a block to retrieve one file may mean that you've got files next to it already decompressed in memory)... but without potentially-unfounded assumptions (such as assuming that all contents within a block share that block's average ratio) it doesn't help with trying to backtrace how well each individual item compressed, because the items aren't compressed individually in the first place.