AgentD / squashfs-tools-ng

A new set of tools and libraries for working with SquashFS images
Other
194 stars 30 forks source link

sqfs2tar: increase compatibility with gnu tar entries #37

Closed josch closed 4 years ago

josch commented 4 years ago

Hi,

would you consider making the output of sqfs2tar a bit more similar to the default behaviour of GNU tar? Specifically, when using tar2sqfs to create a squashfs image containing a full system root, then the input tarball was most likely created by running tar like this: tar -C rootfs -cf rootfs.tar .

The resulting tarball will then have entries like:

./
./bin/
./bin/bash
./bin/cat

When I turn this into a squashfs image with tar2sqfs and then back to a tarball with sqfs2tar, then the tar entries will look like this:

bin
bin/bash
bin/cat

Would it break anything if the following changes were made to the output of sqfs2tar:

I can emulate the first two by calling sqfs2tar with --root-becomes ./ but the third is tricky and I wrote a small filter to be able to compare the original input tar with the output tar after a roundtrip through tar2sqfs and sqfs2tar.

josch commented 4 years ago

Also an inconsistency. There is no difference between calling sqfs2tar with --root-becomes ./ or with --root-becomes .. In both cases, the first member will be ./ and thus the only directory entry that ends with a slash. So right now there is no way to consistently have directories end either all with a slash or all with no slash.

AgentD commented 4 years ago

According to tar(5), the reason for the / at the end of directory names is actually compatibility with older tar versions (older than GNU tar, so really old). The very first versions of tar did not have a field to indicate the file type and simply appended / to directory names to distinguish them from regular files. I didn't consider this to be necessary any more nowadays, since POSIX tar has a type field.

With commit c835ac7dc3286ee77547e385a3420c42e8f535b9, sqfs2tar should now unconditionally append / to names of directories.

josch commented 4 years ago

I did not know that! Thanks, I learned something new! :)

Thank you for that commit. It is now much easier for me to compare the output of sqfs2tar with the original that I put into tar2sqfs. :)

Since the other two points are solved by using --root-becomes ./ you might as well close this issue. Thank you!