-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Questions about tpxz / file index format #96
Comments
Wow, so many questions! I'll try to answer them all: 0
1
2
3
4
5
6
|
Thank you so much for your detailed reply, you're awesome! 😍 So the only thing unclear is the offset in the file index footer, i.e. the very last 8 bytes. Could I rely on it to find the beginning of the file index? Doing so would avoid readers to know about the xz format at all, which could make the implementation easier. I understand that when creating a tpxz file, the file index must be alone in the last xz block, but my point is about reading a tpxz file. |
What kinda fits to this: It would be nice if pixz manpage could clarify, whether or not it's created files (i.e. also those with indexing) are expected to be compatible with the "standard" xz-utils or not. |
@calestyo: yes, they are compatible with "standard" xz-utils:
|
Yes, and note that even in tar mode, the files are still 100% compatible with xz/liblzma.
Hm, how will you seek to the last 8 bytes of the file-index without understanding the xz file format? You'll need liblzma (or equivalent) to do that, and once you have liblzma it's not really any harder to ask "please go to the last block in the file". Plus there are other downsides:
|
Well, for example, the native lzma module in Python allows to decompress xz files into streams without having information about xz block boundaries. I will not be able to use that anyways because seeking to xz block 2 would mean decompressing block 1 for nothing with that implementation, but it's was an example.
Very good point! For some reason I completely miss that, my bad. So I'm convinced! I will definitively rely on pixz file index to start with the last xz block instead of using the offset in the file footer. |
Hello,
I am really interested in the “tpxz” format, i.e. indexed tar.xz format used by pixz.
I am planning on implementing a Python library that would support that format, and I have written below a few questions, I hope that you will have some time to answer them @vasi!
0. Popularity of tpxz
Is the format really named “tpxz”? What does that stand for?
Do you have any insights of how much tpxz format is used?
Do you know if reader or writers of that format have been written in other languages?
I think it is the main selling point of pixz (out of the one listed in the readme anyways), now that xz supports multi-threading itself. Do you know if people still use pixz just for the tpxz feature?
1. Structure of pixz's tar file index
Here is my understanding of the file index, did I get it right?
Where:
index magic (8 bytes): the constant
\xa6L2.\xd6\x14\xae\xdb
index record is defined as follows:
index footer is defined as follows:
2. Position of file index
The file index is appended just after the tar data. No padding is added, right?
Also, when reading the file index, do you just do the following?
An alternative would be to go to the start of the last XZ block, but it may be less reliable (see question 6b).
3. File index alone in one XZ block?
I noticed that the whole file index is alone inside the last xz block. It could have been appended to the tar data in the previous block. Is there any reason for that? Is it mandatory?
I first thought that maybe this would allow you to drop it easily to write more data to the tar archive, but it seems not to be the case as you would need to read the last block of tar data anyways.
4. Null byte at the start of the index footer
I noticed that the null byte at the end of the index footer is used in the code as a marker to stop the list of index records.
However, I feel like it would not be really needed, as you know that you reached the end of the index record when you are at the end of the stream minus 9 bytes.
It's not really a question, but just to make sure that I did not miss anything.
5. Filenames occurring several times in archive
Nothing special happens here, each occurrence is stored in the index file;
pixz -l
will list them all, in the same order as they appear in the tar:It's not really a question, but just to make sure that I did not miss anything.
6a. Xz block size
It seems that pixz creates an xz block every 0x1000000 bytes of input. It that always the case? How would pixz behave reading xz blocks of various sizes?
6b. Xz file index block size
Also, if there are many files in the tar, is the pixz file index could be greater than 0x1000000 bytes: would it be stored in more than one block?
6c. Synchronizing xz block size with tar files
When adding a tar file (including tar header, etc.), if there is not enough space left in the current xz block, we could move to a new xz block before adding that tar file.
If we want to extract only that file later, this would allow us to read only one block instead of two (or to be precise one less block in total).
What are your thoughts on that optimization? Would such an tpxz archive be fully compatible with pixz (i.e. would pixz read that kind of archive happily)?
The text was updated successfully, but these errors were encountered: