• Joe Tsai's avatar
    archive/tar: add raw support for global PAX records · 19a99594
    Joe Tsai authored
    The PAX specification says the following:
    <<<
    'g' represents global extended header records for the following files in the archive.
    The format of these extended header records shall be as described in pax Extended Header.
    Each value shall affect all subsequent files that do not override that value
    in their own extended header record and until another global extended header record
    is reached that provides another value for the same field.
    >>>
    
    This CL adds support for parsing and composing global PAX records,
    but intentionally does not provide support for automatically
    persisting the global state across files.
    
    Changes made:
    * When Reader encounters a TypeXGlobalRecord header, it parses the
    PAX records and returns them to the user ad-verbatim. Reader does not
    store them in its state, ensuring it has no effect on future Next calls.
    * When Writer receives a TypeXGlobalRecord header, it writes the
    PAX records to the archive ad-verbatim. It does not store them in
    its state, ensuring it has no effect on future WriteHeader calls.
    * The restriction regarding empty record values is lifted since this
    value is used to represent deletion in global headers.
    
    Why provide raw support only:
    * Some archives in the wild have a global header section (often empty)
    and it is the user's responsibility to manually read and discard it's body.
    The logic added here allows users to more easily skip over these sections.
    * For users that do care about global headers, having access to the raw
    records allows them to implement the functionality of global headers themselves
    and manually persist the global state across files.
    * We can still upgrade to a full implementation in the future.
    
    Why we don't provide full support:
    * Even though the PAX specification describes their operation in detail,
    both the GNU and BSD tar tools (which are the most common implementations)
    do not have a consistent interpretation of many details.
    * Global headers were a controversial feature in PAX, by admission of the
    specification itself:
      <<<
      The concept of a global extended header (typeflag g) was controversial.
    
      The typeflag g global headers should not be used with interchange media that
      could suffer partial data loss in transporting the archive.
      >>>
    * Having state persist from entry-to-entry complicates the implementation
    for a feature that is not widely used and not well supported.
    
    Change-Id: I1d904cacc2623ddcaa91525a5470b7dbe226c7e8
    Reviewed-on: https://go-review.googlesource.com/59190Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    19a99594
Name
Last commit
Last update
..
gnu-incremental.tar Loading commit data...
gnu-long-nul.tar Loading commit data...
gnu-multi-hdrs.tar Loading commit data...
gnu-nil-sparse-data.tar Loading commit data...
gnu-nil-sparse-hole.tar Loading commit data...
gnu-not-utf8.tar Loading commit data...
gnu-sparse-big.tar Loading commit data...
gnu-utf8.tar Loading commit data...
gnu.tar Loading commit data...
hardlink.tar Loading commit data...
hdr-only.tar Loading commit data...
invalid-go17.tar Loading commit data...
issue10968.tar Loading commit data...
issue11169.tar Loading commit data...
issue12435.tar Loading commit data...
neg-size.tar Loading commit data...
nil-uid.tar Loading commit data...
pax-bad-hdr-file.tar Loading commit data...
pax-bad-mtime-file.tar Loading commit data...
pax-global-records.tar Loading commit data...
pax-multi-hdrs.tar Loading commit data...
pax-nil-sparse-data.tar Loading commit data...
pax-nil-sparse-hole.tar Loading commit data...
pax-nul-path.tar Loading commit data...
pax-nul-xattrs.tar Loading commit data...
pax-path-hdr.tar Loading commit data...
pax-pos-size-file.tar Loading commit data...
pax-records.tar Loading commit data...
pax-sparse-big.tar Loading commit data...
pax.tar Loading commit data...
small.txt Loading commit data...
small2.txt Loading commit data...
sparse-formats.tar Loading commit data...
star.tar Loading commit data...
ustar-file-devs.tar Loading commit data...
ustar-file-reg.tar Loading commit data...
ustar.tar Loading commit data...
v7.tar Loading commit data...
writer-big-long.tar Loading commit data...
writer-big.tar Loading commit data...
writer.tar Loading commit data...
xattrs.tar Loading commit data...