Tar: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Added filename compatibility note
Empty headers + tidy-up
Line 4: Line 4:


Tar works by concatenating all files together in one big file where each file gets a header that is padded up to 512 bytes. The headers are each aligned on a 512 byte boundry and the content follows directly afterwards. This is what a tar header in it's simplest form could look like.
Tar works by concatenating all files together in one big file where each file gets a header that is padded up to 512 bytes. The headers are each aligned on a 512 byte boundry and the content follows directly afterwards. This is what a tar header in it's simplest form could look like.



<source lang="c">
<source lang="c">
Line 20: Line 19:
</source>
</source>


As you can see the header is not 512 bytes big so the rest of the header is padded up with zeros. At the end of the tar file there is a header of 512 bytes filled with only zeros to indicate the end. A header contains a lot of information but for this tutorial we'll only be interested in two of them.
As you can see the header is not 512 bytes big so the rest of the header is padded up with zeros. At the end of the tar file there is a header of 512 bytes filled with only zeros to indicate the end. (There may be more empty headers to pad to the tape block size; ustar format specifies 10KiB blocks.) A header contains a lot of information but for this tutorial we'll only be interested in two of them.


Filename: This actually contains the whole path, not only the file. It ends with the '\0' character. 100 bytes is sufficient for all tar formats provided the tar file is created with paths no longer than 99 bytes. The newer ustar format supports longer names by a more complicated mechanism not covered here. Caution: paths of 100 bytes or longer may not be terminated with '\0'.
Filename: This actually contains the whole path, not only the file. It ends with the '\0' character. 100 bytes is sufficient for all tar formats provided the tar file is created with paths no longer than 99 bytes. The newer ustar format supports longer names by a more complicated mechanism not covered here. Caution: paths of 100 bytes or longer may not be terminated with '\0'.