go/src
Joe Tsai 3bece2fa0e archive/tar: refactor Reader support for sparse files
This CL is the first step (of two) for adding sparse file support
to the Writer. This CL only refactors the logic of sparse-file handling
in the Reader so that common logic can be easily shared by the Writer.

As a result of this CL, there are some new publicly visible API changes:
	type SparseEntry struct { Offset, Length int64 }
	type Header struct { ...; SparseHoles []SparseEntry }

A new type is defined to represent a sparse fragment and a new field
Header.SparseHoles is added to represent the sparse holes in a file.
The API intentionally represent sparse files using hole fragments,
rather than data fragments so that the zero value of SparseHoles
naturally represents a normal file (i.e., a file without any holes).
The Reader now populates SparseHoles for sparse files.

It is necessary to export the sparse hole information, otherwise it would
be impossible for the Writer to specify that it is trying to encode
a sparse file, and what it looks like.

Some unexported helper functions were added to common.go:
	func validateSparseEntries(sp []SparseEntry, size int64) bool
	func alignSparseEntries(src []SparseEntry, size int64) []SparseEntry
	func invertSparseEntries(src []SparseEntry, size int64) []SparseEntry

The validation logic that used to be in newSparseFileReader is now moved
to validateSparseEntries so that the Writer can use it in the future.
alignSparseEntries is currently unused by the Reader, but will be used
by the Writer in the future. Since TAR represents sparse files by
only recording the data fragments, we add the invertSparseEntries
function to convert a list of data fragments to a normalized list
of hole fragments (and vice-versa).

Some other high-level changes:
* skipUnread is deleted, where most of it's logic is moved to the
Discard methods on regFileReader and sparseFileReader.
* readGNUSparsePAXHeaders was rewritten to be simpler.
* regFileReader and sparseFileReader were completely rewritten
in simpler and easier to understand logic.
* A bug was fixed in sparseFileReader.Read where it failed to
report an error if the logical size of the file ends before
consuming all of the underlying data.
* The tests for sparse-file support was completely rewritten.

Updates #13548

Change-Id: Ic1233ae5daf3b3f4278fe1115d34a90c4aeaf0c2
Reviewed-on: https://go-review.googlesource.com/56771
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-19 00:57:31 +00:00
..
archive archive/tar: refactor Reader support for sparse files 2017-08-19 00:57:31 +00:00
bufio
builtin
bytes bytes: clean-up of buffer.go 2017-08-18 17:41:11 +00:00
cmd cmd/compile/internal/amd64: add ADD[Q|L]constmem 2017-08-18 18:55:44 +00:00
compress
container
context
crypto crypto/aes: make the GHASH part of AES-GCM faster 2017-08-18 21:40:57 +00:00
database/sql database/sql: fail on unsupported options when context is un-cancellable 2017-08-09 20:06:20 +00:00
debug all: unindent some big chunks of code 2017-08-18 06:59:48 +00:00
encoding encoding/asn1: handle application tag in Marshal 2017-08-15 18:45:39 +00:00
errors
expvar
flag
fmt fmt: add Stringer example 2017-08-16 18:02:42 +00:00
go all: unindent some big chunks of code 2017-08-18 06:59:48 +00:00
hash
html
image
index/suffixarray
internal runtime, internal/cpu: CPU capabilities detection for ppc64x 2017-08-14 12:16:42 +00:00
io
log
math math: implement the erfinv function 2017-08-18 13:30:46 +00:00
mime
net {net,os/user,plugin}: eliminate unnecessary C round-trips 2017-08-17 18:14:16 +00:00
os {net,os/user,plugin}: eliminate unnecessary C round-trips 2017-08-17 18:14:16 +00:00
path
plugin {net,os/user,plugin}: eliminate unnecessary C round-trips 2017-08-17 18:14:16 +00:00
reflect reflect: remove useless parameter from newName 2017-08-16 15:11:03 +00:00
regexp
runtime runtime: fix false positive race in profile label reading 2017-08-18 21:40:37 +00:00
sort
strconv strconv: cleanup variable declarations in ParseUint 2017-08-15 04:24:52 +00:00
strings strings: use slice instead of list and array in Fields comment 2017-08-14 21:25:53 +00:00
sync
syscall syscall: really use utimensat for UtimesNano on Solaris 2017-08-15 16:56:03 +00:00
testing testing: don't fail all tests after racy test failure 2017-08-15 22:59:26 +00:00
text all: unindent some big chunks of code 2017-08-18 06:59:48 +00:00
time time: add leap year test for Date 2017-08-18 16:55:11 +00:00
unicode
unsafe
vendor/golang_org/x
Make.dist
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash
make.bat
make.rc
naclmake.bash
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc