]> Cypherpunks repositories - gostls13.git/commit
archive/tar: support arbitrary PAX records
authorJoe Tsai <joetsai@digital-static.net>
Thu, 24 Aug 2017 06:44:33 +0000 (23:44 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Fri, 25 Aug 2017 21:57:32 +0000 (21:57 +0000)
commita795ca51db39f057fb1f772425d86cd93ccf261b
treee21acedf33339d90473816c978c7313fc7b3744c
parent4d6da864696fd302aa62666eeed8b01918577f14
archive/tar: support arbitrary PAX records

This CL adds the following new publicly visible API:
type Header struct { ...; PAXRecords map[string]string }

The new Header.PAXRecords field is a map of all PAX extended header records.

We suggest (but do not enforce) that users use VENDOR-prefixed keys
according to the following in the PAX specification:
<<<
The standard developers have reserved keyword name space for vendor extensions.
It is suggested that the format to be used is:
VENDOR.keyword
where VENDOR is the name of the vendor or organization in all uppercase letters.
>>>

When reading, the Header.PAXRecords is populated with all PAX records
encountered so far, including basic ones (e.g., "path", "mtime", etc).
When writing, the fields of Header will be merged into PAXRecords,
overwriting any records that may conflict.

Since PAXRecords is a more expressive feature than Xattrs and
is entirely a superset of Xattrs, we mark Xattrs as deprecated,
and steer users towards the new PAXRecords API.

The issue has a discussion about adding a Header.SetPAXRecord method
to help validate records and keep the Header fields in sync.
However, we do not include that in this CL since that helper
method can always be added in the future.

There is no support for global records.

Fixes #14472

Change-Id: If285a52749acc733476cf75a2c7ad15bc1542071
Reviewed-on: https://go-review.googlesource.com/58390
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/archive/tar/common.go
src/archive/tar/reader.go
src/archive/tar/reader_test.go
src/archive/tar/strconv_test.go
src/archive/tar/tar_test.go
src/archive/tar/testdata/pax-records.tar [new file with mode: 0644]
src/archive/tar/writer_test.go