Browse Source

Merge pull request #1195 from benmoss/fix-glide

Fix glide
Rajat Chopra 5 years ago
parent
commit
fe96aa0160
100 changed files with 15 additions and 14383 deletions
  1. 7 0
      .travis.yml
  2. 6 1
      Makefile
  3. 2 2
      glide.lock
  4. 0 22
      vendor/github.com/Microsoft/go-winio/README.md
  5. 0 27
      vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE
  6. 0 344
      vendor/github.com/Microsoft/go-winio/archive/tar/common.go
  7. 0 80
      vendor/github.com/Microsoft/go-winio/archive/tar/example_test.go
  8. 0 1002
      vendor/github.com/Microsoft/go-winio/archive/tar/reader.go
  9. 0 1125
      vendor/github.com/Microsoft/go-winio/archive/tar/reader_test.go
  10. 0 20
      vendor/github.com/Microsoft/go-winio/archive/tar/stat_atim.go
  11. 0 20
      vendor/github.com/Microsoft/go-winio/archive/tar/stat_atimespec.go
  12. 0 32
      vendor/github.com/Microsoft/go-winio/archive/tar/stat_unix.go
  13. 0 325
      vendor/github.com/Microsoft/go-winio/archive/tar/tar_test.go
  14. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/gnu-multi-hdrs.tar
  15. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/gnu.tar
  16. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/hardlink.tar
  17. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/hdr-only.tar
  18. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue10968.tar
  19. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue11169.tar
  20. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue12435.tar
  21. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/neg-size.tar
  22. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/nil-uid.tar
  23. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax-multi-hdrs.tar
  24. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax-path-hdr.tar
  25. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax.tar
  26. 0 1
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/small.txt
  27. 0 1
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/small2.txt
  28. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/sparse-formats.tar
  29. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/star.tar
  30. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/ustar-file-reg.tar
  31. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/ustar.tar
  32. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/v7.tar
  33. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer-big-long.tar
  34. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer-big.tar
  35. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer.tar
  36. BIN
      vendor/github.com/Microsoft/go-winio/archive/tar/testdata/xattrs.tar
  37. 0 444
      vendor/github.com/Microsoft/go-winio/archive/tar/writer.go
  38. 0 739
      vendor/github.com/Microsoft/go-winio/archive/tar/writer_test.go
  39. 0 255
      vendor/github.com/Microsoft/go-winio/backup_test.go
  40. 0 4
      vendor/github.com/Microsoft/go-winio/backuptar/noop.go
  41. 0 439
      vendor/github.com/Microsoft/go-winio/backuptar/tar.go
  42. 0 84
      vendor/github.com/Microsoft/go-winio/backuptar/tar_test.go
  43. 0 89
      vendor/github.com/Microsoft/go-winio/ea_test.go
  44. 0 516
      vendor/github.com/Microsoft/go-winio/pipe_test.go
  45. 0 17
      vendor/github.com/Microsoft/go-winio/privileges_test.go
  46. 0 26
      vendor/github.com/Microsoft/go-winio/sd_test.go
  47. 0 901
      vendor/github.com/Microsoft/go-winio/vhd/mksyscall_windows.go
  48. 0 108
      vendor/github.com/Microsoft/go-winio/vhd/vhd.go
  49. 0 99
      vendor/github.com/Microsoft/go-winio/vhd/zvhd.go
  50. 0 138
      vendor/github.com/Microsoft/go-winio/wim/decompress.go
  51. 0 606
      vendor/github.com/Microsoft/go-winio/wim/lzx/lzx.go
  52. 0 51
      vendor/github.com/Microsoft/go-winio/wim/validate/validate.go
  53. 0 866
      vendor/github.com/Microsoft/go-winio/wim/wim.go
  54. 0 1
      vendor/github.com/Microsoft/hcsshim/.gitignore
  55. 0 17
      vendor/github.com/Microsoft/hcsshim/.gometalinter.json
  56. 0 41
      vendor/github.com/Microsoft/hcsshim/README.md
  57. 0 29
      vendor/github.com/Microsoft/hcsshim/appveyor.yml
  58. 0 191
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/LICENSE
  59. 0 22
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/NOTICE
  60. 0 848
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/container.go
  61. 0 71
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create-scratch.go
  62. 0 100
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create.go
  63. 0 73
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/delete.go
  64. 0 160
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/exec.go
  65. 0 193
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill.go
  66. 0 111
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill_test.go
  67. 0 116
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/list.go
  68. 0 174
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/main.go
  69. 0 58
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/pause.go
  70. 0 51
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/ps.go
  71. BIN
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/resource_windows_386.syso
  72. BIN
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/resource_windows_amd64.syso
  73. 0 64
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/run.go
  74. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/runhcs.exe.manifest
  75. 0 323
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/shim.go
  76. 0 46
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/signalmap.go
  77. 0 42
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/spec.go
  78. 0 43
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/start.go
  79. 0 49
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/state.go
  80. 0 56
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/tty.go
  81. 0 52
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/utils.go
  82. 0 39
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/utils_test.go
  83. 0 43
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/versioninfo.json
  84. 0 209
      vendor/github.com/Microsoft/hcsshim/cmd/runhcs/vm.go
  85. 0 64
      vendor/github.com/Microsoft/hcsshim/cmd/tar2ext4/tar2ext4.go
  86. 0 36
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/create.go
  87. 0 66
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/export.go
  88. 0 74
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/import.go
  89. 0 88
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/mount.go
  90. 0 31
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/remove.go
  91. BIN
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/resource_windows_386.syso
  92. BIN
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/resource_windows_amd64.syso
  93. 0 43
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/versioninfo.json
  94. 0 10
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/wclayer.exe.manifest
  95. 0 60
      vendor/github.com/Microsoft/hcsshim/cmd/wclayer/wclayer.go
  96. 0 1263
      vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact.go
  97. 0 355
      vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact_test.go
  98. 0 248
      vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/verify_linux_test.go
  99. 0 18
      vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/verify_test.go
  100. 0 411
      vendor/github.com/Microsoft/hcsshim/ext4/internal/format/format.go

+ 7 - 0
.travis.yml

@@ -24,3 +24,10 @@ after_success:
 
 notifications:
   email: false
+
+addons:
+  apt:
+    sources:
+      - sourceline: 'ppa:masterminds/glide'
+    packages:
+      - glide

+ 6 - 1
Makefile

@@ -69,7 +69,7 @@ ifeq ($(ARCH),amd64)
 endif
 
 ### TESTING
-test: header-check gofmt
+test: header-check gofmt verify-glide
 	# Run the unit tests
 	# NET_ADMIN capacity is required to do some network operation
 	# SYS_ADMIN capacity is required to create network namespace
@@ -99,6 +99,11 @@ header-check:
 gofmt:
 	bash -c '! gofmt -d $(PACKAGES) 2>&1 | read'
 
+# Throw an error if `glide list` finds any errors.
+verify-glide:
+	$(if $(shell which glide),,$(error "glide not found in PATH"))
+	bash -c '! glide list 2>&1 | grep "ERROR"'
+
 gofmt-fix:
 	gofmt -w $(PACKAGES)
 

+ 2 - 2
glide.lock

@@ -1,4 +1,4 @@
-hash: 2f18ae318a81ddf8a97889dd05c1d2cae675586788b641c8b2b1fec819177d69
+hash: 4059cd0e42f61ec6a1d3e910a989dd22141611b5774464aac92ba256734d6f34
 updated: 2018-01-01T18:24:38.545866546-06:00
 imports:
 - name: cloud.google.com/go
@@ -157,7 +157,7 @@ imports:
 - name: github.com/PuerkitoBio/urlesc
   version: 5bd2802263f21d8788851d5305584c82a5c75d7e
 - name: github.com/rakelkar/gonetsh
-  version: 758b1f7c9d1ca5acaca0b909f06ff9ed9fe35de1
+  version: 501daadcadf88660f61cc3352bdcb26b5f8ba4ce
   subpackages:
   - netroute
   - netsh

+ 0 - 22
vendor/github.com/Microsoft/go-winio/README.md

@@ -1,22 +0,0 @@
-# go-winio
-
-This repository contains utilities for efficiently performing Win32 IO operations in
-Go. Currently, this is focused on accessing named pipes and other file handles, and
-for using named pipes as a net transport.
-
-This code relies on IO completion ports to avoid blocking IO on system threads, allowing Go
-to reuse the thread to schedule another goroutine. This limits support to Windows Vista and
-newer operating systems. This is similar to the implementation of network sockets in Go's net
-package.
-
-Please see the LICENSE file for licensing information.
-
-This project has adopted the [Microsoft Open Source Code of
-Conduct](https://opensource.microsoft.com/codeofconduct/). For more information
-see the [Code of Conduct
-FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
-[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
-questions or comments.
-
-Thanks to natefinch for the inspiration for this library. See https://github.com/natefinch/npipe
-for another named pipe implementation.

+ 0 - 27
vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE

@@ -1,27 +0,0 @@
-Copyright (c) 2012 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-   * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-   * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-   * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 344
vendor/github.com/Microsoft/go-winio/archive/tar/common.go

@@ -1,344 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package tar implements access to tar archives.
-// It aims to cover most of the variations, including those produced
-// by GNU and BSD tars.
-//
-// References:
-//   http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5
-//   http://www.gnu.org/software/tar/manual/html_node/Standard.html
-//   http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html
-package tar
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"os"
-	"path"
-	"time"
-)
-
-const (
-	blockSize = 512
-
-	// Types
-	TypeReg           = '0'    // regular file
-	TypeRegA          = '\x00' // regular file
-	TypeLink          = '1'    // hard link
-	TypeSymlink       = '2'    // symbolic link
-	TypeChar          = '3'    // character device node
-	TypeBlock         = '4'    // block device node
-	TypeDir           = '5'    // directory
-	TypeFifo          = '6'    // fifo node
-	TypeCont          = '7'    // reserved
-	TypeXHeader       = 'x'    // extended header
-	TypeXGlobalHeader = 'g'    // global extended header
-	TypeGNULongName   = 'L'    // Next file has a long name
-	TypeGNULongLink   = 'K'    // Next file symlinks to a file w/ a long name
-	TypeGNUSparse     = 'S'    // sparse file
-)
-
-// A Header represents a single header in a tar archive.
-// Some fields may not be populated.
-type Header struct {
-	Name         string    // name of header file entry
-	Mode         int64     // permission and mode bits
-	Uid          int       // user id of owner
-	Gid          int       // group id of owner
-	Size         int64     // length in bytes
-	ModTime      time.Time // modified time
-	Typeflag     byte      // type of header entry
-	Linkname     string    // target name of link
-	Uname        string    // user name of owner
-	Gname        string    // group name of owner
-	Devmajor     int64     // major number of character or block device
-	Devminor     int64     // minor number of character or block device
-	AccessTime   time.Time // access time
-	ChangeTime   time.Time // status change time
-	CreationTime time.Time // creation time
-	Xattrs       map[string]string
-	Winheaders   map[string]string
-}
-
-// File name constants from the tar spec.
-const (
-	fileNameSize       = 100 // Maximum number of bytes in a standard tar name.
-	fileNamePrefixSize = 155 // Maximum number of ustar extension bytes.
-)
-
-// FileInfo returns an os.FileInfo for the Header.
-func (h *Header) FileInfo() os.FileInfo {
-	return headerFileInfo{h}
-}
-
-// headerFileInfo implements os.FileInfo.
-type headerFileInfo struct {
-	h *Header
-}
-
-func (fi headerFileInfo) Size() int64        { return fi.h.Size }
-func (fi headerFileInfo) IsDir() bool        { return fi.Mode().IsDir() }
-func (fi headerFileInfo) ModTime() time.Time { return fi.h.ModTime }
-func (fi headerFileInfo) Sys() interface{}   { return fi.h }
-
-// Name returns the base name of the file.
-func (fi headerFileInfo) Name() string {
-	if fi.IsDir() {
-		return path.Base(path.Clean(fi.h.Name))
-	}
-	return path.Base(fi.h.Name)
-}
-
-// Mode returns the permission and mode bits for the headerFileInfo.
-func (fi headerFileInfo) Mode() (mode os.FileMode) {
-	// Set file permission bits.
-	mode = os.FileMode(fi.h.Mode).Perm()
-
-	// Set setuid, setgid and sticky bits.
-	if fi.h.Mode&c_ISUID != 0 {
-		// setuid
-		mode |= os.ModeSetuid
-	}
-	if fi.h.Mode&c_ISGID != 0 {
-		// setgid
-		mode |= os.ModeSetgid
-	}
-	if fi.h.Mode&c_ISVTX != 0 {
-		// sticky
-		mode |= os.ModeSticky
-	}
-
-	// Set file mode bits.
-	// clear perm, setuid, setgid and sticky bits.
-	m := os.FileMode(fi.h.Mode) &^ 07777
-	if m == c_ISDIR {
-		// directory
-		mode |= os.ModeDir
-	}
-	if m == c_ISFIFO {
-		// named pipe (FIFO)
-		mode |= os.ModeNamedPipe
-	}
-	if m == c_ISLNK {
-		// symbolic link
-		mode |= os.ModeSymlink
-	}
-	if m == c_ISBLK {
-		// device file
-		mode |= os.ModeDevice
-	}
-	if m == c_ISCHR {
-		// Unix character device
-		mode |= os.ModeDevice
-		mode |= os.ModeCharDevice
-	}
-	if m == c_ISSOCK {
-		// Unix domain socket
-		mode |= os.ModeSocket
-	}
-
-	switch fi.h.Typeflag {
-	case TypeSymlink:
-		// symbolic link
-		mode |= os.ModeSymlink
-	case TypeChar:
-		// character device node
-		mode |= os.ModeDevice
-		mode |= os.ModeCharDevice
-	case TypeBlock:
-		// block device node
-		mode |= os.ModeDevice
-	case TypeDir:
-		// directory
-		mode |= os.ModeDir
-	case TypeFifo:
-		// fifo node
-		mode |= os.ModeNamedPipe
-	}
-
-	return mode
-}
-
-// sysStat, if non-nil, populates h from system-dependent fields of fi.
-var sysStat func(fi os.FileInfo, h *Header) error
-
-// Mode constants from the tar spec.
-const (
-	c_ISUID  = 04000   // Set uid
-	c_ISGID  = 02000   // Set gid
-	c_ISVTX  = 01000   // Save text (sticky bit)
-	c_ISDIR  = 040000  // Directory
-	c_ISFIFO = 010000  // FIFO
-	c_ISREG  = 0100000 // Regular file
-	c_ISLNK  = 0120000 // Symbolic link
-	c_ISBLK  = 060000  // Block special file
-	c_ISCHR  = 020000  // Character special file
-	c_ISSOCK = 0140000 // Socket
-)
-
-// Keywords for the PAX Extended Header
-const (
-	paxAtime        = "atime"
-	paxCharset      = "charset"
-	paxComment      = "comment"
-	paxCtime        = "ctime" // please note that ctime is not a valid pax header.
-	paxCreationTime = "LIBARCHIVE.creationtime"
-	paxGid          = "gid"
-	paxGname        = "gname"
-	paxLinkpath     = "linkpath"
-	paxMtime        = "mtime"
-	paxPath         = "path"
-	paxSize         = "size"
-	paxUid          = "uid"
-	paxUname        = "uname"
-	paxXattr        = "SCHILY.xattr."
-	paxWindows      = "MSWINDOWS."
-	paxNone         = ""
-)
-
-// FileInfoHeader creates a partially-populated Header from fi.
-// If fi describes a symlink, FileInfoHeader records link as the link target.
-// If fi describes a directory, a slash is appended to the name.
-// Because os.FileInfo's Name method returns only the base name of
-// the file it describes, it may be necessary to modify the Name field
-// of the returned header to provide the full path name of the file.
-func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
-	if fi == nil {
-		return nil, errors.New("tar: FileInfo is nil")
-	}
-	fm := fi.Mode()
-	h := &Header{
-		Name:    fi.Name(),
-		ModTime: fi.ModTime(),
-		Mode:    int64(fm.Perm()), // or'd with c_IS* constants later
-	}
-	switch {
-	case fm.IsRegular():
-		h.Mode |= c_ISREG
-		h.Typeflag = TypeReg
-		h.Size = fi.Size()
-	case fi.IsDir():
-		h.Typeflag = TypeDir
-		h.Mode |= c_ISDIR
-		h.Name += "/"
-	case fm&os.ModeSymlink != 0:
-		h.Typeflag = TypeSymlink
-		h.Mode |= c_ISLNK
-		h.Linkname = link
-	case fm&os.ModeDevice != 0:
-		if fm&os.ModeCharDevice != 0 {
-			h.Mode |= c_ISCHR
-			h.Typeflag = TypeChar
-		} else {
-			h.Mode |= c_ISBLK
-			h.Typeflag = TypeBlock
-		}
-	case fm&os.ModeNamedPipe != 0:
-		h.Typeflag = TypeFifo
-		h.Mode |= c_ISFIFO
-	case fm&os.ModeSocket != 0:
-		h.Mode |= c_ISSOCK
-	default:
-		return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
-	}
-	if fm&os.ModeSetuid != 0 {
-		h.Mode |= c_ISUID
-	}
-	if fm&os.ModeSetgid != 0 {
-		h.Mode |= c_ISGID
-	}
-	if fm&os.ModeSticky != 0 {
-		h.Mode |= c_ISVTX
-	}
-	// If possible, populate additional fields from OS-specific
-	// FileInfo fields.
-	if sys, ok := fi.Sys().(*Header); ok {
-		// This FileInfo came from a Header (not the OS). Use the
-		// original Header to populate all remaining fields.
-		h.Uid = sys.Uid
-		h.Gid = sys.Gid
-		h.Uname = sys.Uname
-		h.Gname = sys.Gname
-		h.AccessTime = sys.AccessTime
-		h.ChangeTime = sys.ChangeTime
-		if sys.Xattrs != nil {
-			h.Xattrs = make(map[string]string)
-			for k, v := range sys.Xattrs {
-				h.Xattrs[k] = v
-			}
-		}
-		if sys.Typeflag == TypeLink {
-			// hard link
-			h.Typeflag = TypeLink
-			h.Size = 0
-			h.Linkname = sys.Linkname
-		}
-	}
-	if sysStat != nil {
-		return h, sysStat(fi, h)
-	}
-	return h, nil
-}
-
-var zeroBlock = make([]byte, blockSize)
-
-// POSIX specifies a sum of the unsigned byte values, but the Sun tar uses signed byte values.
-// We compute and return both.
-func checksum(header []byte) (unsigned int64, signed int64) {
-	for i := 0; i < len(header); i++ {
-		if i == 148 {
-			// The chksum field (header[148:156]) is special: it should be treated as space bytes.
-			unsigned += ' ' * 8
-			signed += ' ' * 8
-			i += 7
-			continue
-		}
-		unsigned += int64(header[i])
-		signed += int64(int8(header[i]))
-	}
-	return
-}
-
-type slicer []byte
-
-func (sp *slicer) next(n int) (b []byte) {
-	s := *sp
-	b, *sp = s[0:n], s[n:]
-	return
-}
-
-func isASCII(s string) bool {
-	for _, c := range s {
-		if c >= 0x80 {
-			return false
-		}
-	}
-	return true
-}
-
-func toASCII(s string) string {
-	if isASCII(s) {
-		return s
-	}
-	var buf bytes.Buffer
-	for _, c := range s {
-		if c < 0x80 {
-			buf.WriteByte(byte(c))
-		}
-	}
-	return buf.String()
-}
-
-// isHeaderOnlyType checks if the given type flag is of the type that has no
-// data section even if a size is specified.
-func isHeaderOnlyType(flag byte) bool {
-	switch flag {
-	case TypeLink, TypeSymlink, TypeChar, TypeBlock, TypeDir, TypeFifo:
-		return true
-	default:
-		return false
-	}
-}

+ 0 - 80
vendor/github.com/Microsoft/go-winio/archive/tar/example_test.go

@@ -1,80 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar_test
-
-import (
-	"archive/tar"
-	"bytes"
-	"fmt"
-	"io"
-	"log"
-	"os"
-)
-
-func Example() {
-	// Create a buffer to write our archive to.
-	buf := new(bytes.Buffer)
-
-	// Create a new tar archive.
-	tw := tar.NewWriter(buf)
-
-	// Add some files to the archive.
-	var files = []struct {
-		Name, Body string
-	}{
-		{"readme.txt", "This archive contains some text files."},
-		{"gopher.txt", "Gopher names:\nGeorge\nGeoffrey\nGonzo"},
-		{"todo.txt", "Get animal handling license."},
-	}
-	for _, file := range files {
-		hdr := &tar.Header{
-			Name: file.Name,
-			Mode: 0600,
-			Size: int64(len(file.Body)),
-		}
-		if err := tw.WriteHeader(hdr); err != nil {
-			log.Fatalln(err)
-		}
-		if _, err := tw.Write([]byte(file.Body)); err != nil {
-			log.Fatalln(err)
-		}
-	}
-	// Make sure to check the error on Close.
-	if err := tw.Close(); err != nil {
-		log.Fatalln(err)
-	}
-
-	// Open the tar archive for reading.
-	r := bytes.NewReader(buf.Bytes())
-	tr := tar.NewReader(r)
-
-	// Iterate through the files in the archive.
-	for {
-		hdr, err := tr.Next()
-		if err == io.EOF {
-			// end of tar archive
-			break
-		}
-		if err != nil {
-			log.Fatalln(err)
-		}
-		fmt.Printf("Contents of %s:\n", hdr.Name)
-		if _, err := io.Copy(os.Stdout, tr); err != nil {
-			log.Fatalln(err)
-		}
-		fmt.Println()
-	}
-
-	// Output:
-	// Contents of readme.txt:
-	// This archive contains some text files.
-	// Contents of gopher.txt:
-	// Gopher names:
-	// George
-	// Geoffrey
-	// Gonzo
-	// Contents of todo.txt:
-	// Get animal handling license.
-}

+ 0 - 1002
vendor/github.com/Microsoft/go-winio/archive/tar/reader.go

@@ -1,1002 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar
-
-// TODO(dsymonds):
-//   - pax extensions
-
-import (
-	"bytes"
-	"errors"
-	"io"
-	"io/ioutil"
-	"math"
-	"os"
-	"strconv"
-	"strings"
-	"time"
-)
-
-var (
-	ErrHeader = errors.New("archive/tar: invalid tar header")
-)
-
-const maxNanoSecondIntSize = 9
-
-// A Reader provides sequential access to the contents of a tar archive.
-// A tar archive consists of a sequence of files.
-// The Next method advances to the next file in the archive (including the first),
-// and then it can be treated as an io.Reader to access the file's data.
-type Reader struct {
-	r       io.Reader
-	err     error
-	pad     int64           // amount of padding (ignored) after current file entry
-	curr    numBytesReader  // reader for current file entry
-	hdrBuff [blockSize]byte // buffer to use in readHeader
-}
-
-type parser struct {
-	err error // Last error seen
-}
-
-// A numBytesReader is an io.Reader with a numBytes method, returning the number
-// of bytes remaining in the underlying encoded data.
-type numBytesReader interface {
-	io.Reader
-	numBytes() int64
-}
-
-// A regFileReader is a numBytesReader for reading file data from a tar archive.
-type regFileReader struct {
-	r  io.Reader // underlying reader
-	nb int64     // number of unread bytes for current file entry
-}
-
-// A sparseFileReader is a numBytesReader for reading sparse file data from a
-// tar archive.
-type sparseFileReader struct {
-	rfr   numBytesReader // Reads the sparse-encoded file data
-	sp    []sparseEntry  // The sparse map for the file
-	pos   int64          // Keeps track of file position
-	total int64          // Total size of the file
-}
-
-// A sparseEntry holds a single entry in a sparse file's sparse map.
-//
-// Sparse files are represented using a series of sparseEntrys.
-// Despite the name, a sparseEntry represents an actual data fragment that
-// references data found in the underlying archive stream. All regions not
-// covered by a sparseEntry are logically filled with zeros.
-//
-// For example, if the underlying raw file contains the 10-byte data:
-//	var compactData = "abcdefgh"
-//
-// And the sparse map has the following entries:
-//	var sp = []sparseEntry{
-//		{offset: 2,  numBytes: 5} // Data fragment for [2..7]
-//		{offset: 18, numBytes: 3} // Data fragment for [18..21]
-//	}
-//
-// Then the content of the resulting sparse file with a "real" size of 25 is:
-//	var sparseData = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4
-type sparseEntry struct {
-	offset   int64 // Starting position of the fragment
-	numBytes int64 // Length of the fragment
-}
-
-// Keywords for GNU sparse files in a PAX extended header
-const (
-	paxGNUSparseNumBlocks = "GNU.sparse.numblocks"
-	paxGNUSparseOffset    = "GNU.sparse.offset"
-	paxGNUSparseNumBytes  = "GNU.sparse.numbytes"
-	paxGNUSparseMap       = "GNU.sparse.map"
-	paxGNUSparseName      = "GNU.sparse.name"
-	paxGNUSparseMajor     = "GNU.sparse.major"
-	paxGNUSparseMinor     = "GNU.sparse.minor"
-	paxGNUSparseSize      = "GNU.sparse.size"
-	paxGNUSparseRealSize  = "GNU.sparse.realsize"
-)
-
-// Keywords for old GNU sparse headers
-const (
-	oldGNUSparseMainHeaderOffset               = 386
-	oldGNUSparseMainHeaderIsExtendedOffset     = 482
-	oldGNUSparseMainHeaderNumEntries           = 4
-	oldGNUSparseExtendedHeaderIsExtendedOffset = 504
-	oldGNUSparseExtendedHeaderNumEntries       = 21
-	oldGNUSparseOffsetSize                     = 12
-	oldGNUSparseNumBytesSize                   = 12
-)
-
-// NewReader creates a new Reader reading from r.
-func NewReader(r io.Reader) *Reader { return &Reader{r: r} }
-
-// Next advances to the next entry in the tar archive.
-//
-// io.EOF is returned at the end of the input.
-func (tr *Reader) Next() (*Header, error) {
-	if tr.err != nil {
-		return nil, tr.err
-	}
-
-	var hdr *Header
-	var extHdrs map[string]string
-
-	// Externally, Next iterates through the tar archive as if it is a series of
-	// files. Internally, the tar format often uses fake "files" to add meta
-	// data that describes the next file. These meta data "files" should not
-	// normally be visible to the outside. As such, this loop iterates through
-	// one or more "header files" until it finds a "normal file".
-loop:
-	for {
-		tr.err = tr.skipUnread()
-		if tr.err != nil {
-			return nil, tr.err
-		}
-
-		hdr = tr.readHeader()
-		if tr.err != nil {
-			return nil, tr.err
-		}
-
-		// Check for PAX/GNU special headers and files.
-		switch hdr.Typeflag {
-		case TypeXHeader:
-			extHdrs, tr.err = parsePAX(tr)
-			if tr.err != nil {
-				return nil, tr.err
-			}
-			continue loop // This is a meta header affecting the next header
-		case TypeGNULongName, TypeGNULongLink:
-			var realname []byte
-			realname, tr.err = ioutil.ReadAll(tr)
-			if tr.err != nil {
-				return nil, tr.err
-			}
-
-			// Convert GNU extensions to use PAX headers.
-			if extHdrs == nil {
-				extHdrs = make(map[string]string)
-			}
-			var p parser
-			switch hdr.Typeflag {
-			case TypeGNULongName:
-				extHdrs[paxPath] = p.parseString(realname)
-			case TypeGNULongLink:
-				extHdrs[paxLinkpath] = p.parseString(realname)
-			}
-			if p.err != nil {
-				tr.err = p.err
-				return nil, tr.err
-			}
-			continue loop // This is a meta header affecting the next header
-		default:
-			mergePAX(hdr, extHdrs)
-
-			// Check for a PAX format sparse file
-			sp, err := tr.checkForGNUSparsePAXHeaders(hdr, extHdrs)
-			if err != nil {
-				tr.err = err
-				return nil, err
-			}
-			if sp != nil {
-				// Current file is a PAX format GNU sparse file.
-				// Set the current file reader to a sparse file reader.
-				tr.curr, tr.err = newSparseFileReader(tr.curr, sp, hdr.Size)
-				if tr.err != nil {
-					return nil, tr.err
-				}
-			}
-			break loop // This is a file, so stop
-		}
-	}
-	return hdr, nil
-}
-
-// checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers. If they are found, then
-// this function reads the sparse map and returns it. Unknown sparse formats are ignored, causing the file to
-// be treated as a regular file.
-func (tr *Reader) checkForGNUSparsePAXHeaders(hdr *Header, headers map[string]string) ([]sparseEntry, error) {
-	var sparseFormat string
-
-	// Check for sparse format indicators
-	major, majorOk := headers[paxGNUSparseMajor]
-	minor, minorOk := headers[paxGNUSparseMinor]
-	sparseName, sparseNameOk := headers[paxGNUSparseName]
-	_, sparseMapOk := headers[paxGNUSparseMap]
-	sparseSize, sparseSizeOk := headers[paxGNUSparseSize]
-	sparseRealSize, sparseRealSizeOk := headers[paxGNUSparseRealSize]
-
-	// Identify which, if any, sparse format applies from which PAX headers are set
-	if majorOk && minorOk {
-		sparseFormat = major + "." + minor
-	} else if sparseNameOk && sparseMapOk {
-		sparseFormat = "0.1"
-	} else if sparseSizeOk {
-		sparseFormat = "0.0"
-	} else {
-		// Not a PAX format GNU sparse file.
-		return nil, nil
-	}
-
-	// Check for unknown sparse format
-	if sparseFormat != "0.0" && sparseFormat != "0.1" && sparseFormat != "1.0" {
-		return nil, nil
-	}
-
-	// Update hdr from GNU sparse PAX headers
-	if sparseNameOk {
-		hdr.Name = sparseName
-	}
-	if sparseSizeOk {
-		realSize, err := strconv.ParseInt(sparseSize, 10, 0)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		hdr.Size = realSize
-	} else if sparseRealSizeOk {
-		realSize, err := strconv.ParseInt(sparseRealSize, 10, 0)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		hdr.Size = realSize
-	}
-
-	// Set up the sparse map, according to the particular sparse format in use
-	var sp []sparseEntry
-	var err error
-	switch sparseFormat {
-	case "0.0", "0.1":
-		sp, err = readGNUSparseMap0x1(headers)
-	case "1.0":
-		sp, err = readGNUSparseMap1x0(tr.curr)
-	}
-	return sp, err
-}
-
-// mergePAX merges well known headers according to PAX standard.
-// In general headers with the same name as those found
-// in the header struct overwrite those found in the header
-// struct with higher precision or longer values. Esp. useful
-// for name and linkname fields.
-func mergePAX(hdr *Header, headers map[string]string) error {
-	for k, v := range headers {
-		switch k {
-		case paxPath:
-			hdr.Name = v
-		case paxLinkpath:
-			hdr.Linkname = v
-		case paxGname:
-			hdr.Gname = v
-		case paxUname:
-			hdr.Uname = v
-		case paxUid:
-			uid, err := strconv.ParseInt(v, 10, 0)
-			if err != nil {
-				return err
-			}
-			hdr.Uid = int(uid)
-		case paxGid:
-			gid, err := strconv.ParseInt(v, 10, 0)
-			if err != nil {
-				return err
-			}
-			hdr.Gid = int(gid)
-		case paxAtime:
-			t, err := parsePAXTime(v)
-			if err != nil {
-				return err
-			}
-			hdr.AccessTime = t
-		case paxMtime:
-			t, err := parsePAXTime(v)
-			if err != nil {
-				return err
-			}
-			hdr.ModTime = t
-		case paxCtime:
-			t, err := parsePAXTime(v)
-			if err != nil {
-				return err
-			}
-			hdr.ChangeTime = t
-		case paxCreationTime:
-			t, err := parsePAXTime(v)
-			if err != nil {
-				return err
-			}
-			hdr.CreationTime = t
-		case paxSize:
-			size, err := strconv.ParseInt(v, 10, 0)
-			if err != nil {
-				return err
-			}
-			hdr.Size = int64(size)
-		default:
-			if strings.HasPrefix(k, paxXattr) {
-				if hdr.Xattrs == nil {
-					hdr.Xattrs = make(map[string]string)
-				}
-				hdr.Xattrs[k[len(paxXattr):]] = v
-			} else if strings.HasPrefix(k, paxWindows) {
-				if hdr.Winheaders == nil {
-					hdr.Winheaders = make(map[string]string)
-				}
-				hdr.Winheaders[k[len(paxWindows):]] = v
-			}
-		}
-	}
-	return nil
-}
-
-// parsePAXTime takes a string of the form %d.%d as described in
-// the PAX specification.
-func parsePAXTime(t string) (time.Time, error) {
-	buf := []byte(t)
-	pos := bytes.IndexByte(buf, '.')
-	var seconds, nanoseconds int64
-	var err error
-	if pos == -1 {
-		seconds, err = strconv.ParseInt(t, 10, 0)
-		if err != nil {
-			return time.Time{}, err
-		}
-	} else {
-		seconds, err = strconv.ParseInt(string(buf[:pos]), 10, 0)
-		if err != nil {
-			return time.Time{}, err
-		}
-		nano_buf := string(buf[pos+1:])
-		// Pad as needed before converting to a decimal.
-		// For example .030 -> .030000000 -> 30000000 nanoseconds
-		if len(nano_buf) < maxNanoSecondIntSize {
-			// Right pad
-			nano_buf += strings.Repeat("0", maxNanoSecondIntSize-len(nano_buf))
-		} else if len(nano_buf) > maxNanoSecondIntSize {
-			// Right truncate
-			nano_buf = nano_buf[:maxNanoSecondIntSize]
-		}
-		nanoseconds, err = strconv.ParseInt(string(nano_buf), 10, 0)
-		if err != nil {
-			return time.Time{}, err
-		}
-	}
-	ts := time.Unix(seconds, nanoseconds)
-	return ts, nil
-}
-
-// parsePAX parses PAX headers.
-// If an extended header (type 'x') is invalid, ErrHeader is returned
-func parsePAX(r io.Reader) (map[string]string, error) {
-	buf, err := ioutil.ReadAll(r)
-	if err != nil {
-		return nil, err
-	}
-	sbuf := string(buf)
-
-	// For GNU PAX sparse format 0.0 support.
-	// This function transforms the sparse format 0.0 headers into sparse format 0.1 headers.
-	var sparseMap bytes.Buffer
-
-	headers := make(map[string]string)
-	// Each record is constructed as
-	//     "%d %s=%s\n", length, keyword, value
-	for len(sbuf) > 0 {
-		key, value, residual, err := parsePAXRecord(sbuf)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		sbuf = residual
-
-		keyStr := string(key)
-		if keyStr == paxGNUSparseOffset || keyStr == paxGNUSparseNumBytes {
-			// GNU sparse format 0.0 special key. Write to sparseMap instead of using the headers map.
-			sparseMap.WriteString(value)
-			sparseMap.Write([]byte{','})
-		} else {
-			// Normal key. Set the value in the headers map.
-			headers[keyStr] = string(value)
-		}
-	}
-	if sparseMap.Len() != 0 {
-		// Add sparse info to headers, chopping off the extra comma
-		sparseMap.Truncate(sparseMap.Len() - 1)
-		headers[paxGNUSparseMap] = sparseMap.String()
-	}
-	return headers, nil
-}
-
-// parsePAXRecord parses the input PAX record string into a key-value pair.
-// If parsing is successful, it will slice off the currently read record and
-// return the remainder as r.
-//
-// A PAX record is of the following form:
-//	"%d %s=%s\n" % (size, key, value)
-func parsePAXRecord(s string) (k, v, r string, err error) {
-	// The size field ends at the first space.
-	sp := strings.IndexByte(s, ' ')
-	if sp == -1 {
-		return "", "", s, ErrHeader
-	}
-
-	// Parse the first token as a decimal integer.
-	n, perr := strconv.ParseInt(s[:sp], 10, 0) // Intentionally parse as native int
-	if perr != nil || n < 5 || int64(len(s)) < n {
-		return "", "", s, ErrHeader
-	}
-
-	// Extract everything between the space and the final newline.
-	rec, nl, rem := s[sp+1:n-1], s[n-1:n], s[n:]
-	if nl != "\n" {
-		return "", "", s, ErrHeader
-	}
-
-	// The first equals separates the key from the value.
-	eq := strings.IndexByte(rec, '=')
-	if eq == -1 {
-		return "", "", s, ErrHeader
-	}
-	return rec[:eq], rec[eq+1:], rem, nil
-}
-
-// parseString parses bytes as a NUL-terminated C-style string.
-// If a NUL byte is not found then the whole slice is returned as a string.
-func (*parser) parseString(b []byte) string {
-	n := 0
-	for n < len(b) && b[n] != 0 {
-		n++
-	}
-	return string(b[0:n])
-}
-
-// parseNumeric parses the input as being encoded in either base-256 or octal.
-// This function may return negative numbers.
-// If parsing fails or an integer overflow occurs, err will be set.
-func (p *parser) parseNumeric(b []byte) int64 {
-	// Check for base-256 (binary) format first.
-	// If the first bit is set, then all following bits constitute a two's
-	// complement encoded number in big-endian byte order.
-	if len(b) > 0 && b[0]&0x80 != 0 {
-		// Handling negative numbers relies on the following identity:
-		//	-a-1 == ^a
-		//
-		// If the number is negative, we use an inversion mask to invert the
-		// data bytes and treat the value as an unsigned number.
-		var inv byte // 0x00 if positive or zero, 0xff if negative
-		if b[0]&0x40 != 0 {
-			inv = 0xff
-		}
-
-		var x uint64
-		for i, c := range b {
-			c ^= inv // Inverts c only if inv is 0xff, otherwise does nothing
-			if i == 0 {
-				c &= 0x7f // Ignore signal bit in first byte
-			}
-			if (x >> 56) > 0 {
-				p.err = ErrHeader // Integer overflow
-				return 0
-			}
-			x = x<<8 | uint64(c)
-		}
-		if (x >> 63) > 0 {
-			p.err = ErrHeader // Integer overflow
-			return 0
-		}
-		if inv == 0xff {
-			return ^int64(x)
-		}
-		return int64(x)
-	}
-
-	// Normal case is base-8 (octal) format.
-	return p.parseOctal(b)
-}
-
-func (p *parser) parseOctal(b []byte) int64 {
-	// Because unused fields are filled with NULs, we need
-	// to skip leading NULs. Fields may also be padded with
-	// spaces or NULs.
-	// So we remove leading and trailing NULs and spaces to
-	// be sure.
-	b = bytes.Trim(b, " \x00")
-
-	if len(b) == 0 {
-		return 0
-	}
-	x, perr := strconv.ParseUint(p.parseString(b), 8, 64)
-	if perr != nil {
-		p.err = ErrHeader
-	}
-	return int64(x)
-}
-
-// skipUnread skips any unread bytes in the existing file entry, as well as any
-// alignment padding. It returns io.ErrUnexpectedEOF if any io.EOF is
-// encountered in the data portion; it is okay to hit io.EOF in the padding.
-//
-// Note that this function still works properly even when sparse files are being
-// used since numBytes returns the bytes remaining in the underlying io.Reader.
-func (tr *Reader) skipUnread() error {
-	dataSkip := tr.numBytes()      // Number of data bytes to skip
-	totalSkip := dataSkip + tr.pad // Total number of bytes to skip
-	tr.curr, tr.pad = nil, 0
-
-	// If possible, Seek to the last byte before the end of the data section.
-	// Do this because Seek is often lazy about reporting errors; this will mask
-	// the fact that the tar stream may be truncated. We can rely on the
-	// io.CopyN done shortly afterwards to trigger any IO errors.
-	var seekSkipped int64 // Number of bytes skipped via Seek
-	if sr, ok := tr.r.(io.Seeker); ok && dataSkip > 1 {
-		// Not all io.Seeker can actually Seek. For example, os.Stdin implements
-		// io.Seeker, but calling Seek always returns an error and performs
-		// no action. Thus, we try an innocent seek to the current position
-		// to see if Seek is really supported.
-		pos1, err := sr.Seek(0, os.SEEK_CUR)
-		if err == nil {
-			// Seek seems supported, so perform the real Seek.
-			pos2, err := sr.Seek(dataSkip-1, os.SEEK_CUR)
-			if err != nil {
-				tr.err = err
-				return tr.err
-			}
-			seekSkipped = pos2 - pos1
-		}
-	}
-
-	var copySkipped int64 // Number of bytes skipped via CopyN
-	copySkipped, tr.err = io.CopyN(ioutil.Discard, tr.r, totalSkip-seekSkipped)
-	if tr.err == io.EOF && seekSkipped+copySkipped < dataSkip {
-		tr.err = io.ErrUnexpectedEOF
-	}
-	return tr.err
-}
-
-func (tr *Reader) verifyChecksum(header []byte) bool {
-	if tr.err != nil {
-		return false
-	}
-
-	var p parser
-	given := p.parseOctal(header[148:156])
-	unsigned, signed := checksum(header)
-	return p.err == nil && (given == unsigned || given == signed)
-}
-
-// readHeader reads the next block header and assumes that the underlying reader
-// is already aligned to a block boundary.
-//
-// The err will be set to io.EOF only when one of the following occurs:
-//	* Exactly 0 bytes are read and EOF is hit.
-//	* Exactly 1 block of zeros is read and EOF is hit.
-//	* At least 2 blocks of zeros are read.
-func (tr *Reader) readHeader() *Header {
-	header := tr.hdrBuff[:]
-	copy(header, zeroBlock)
-
-	if _, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
-		return nil // io.EOF is okay here
-	}
-
-	// Two blocks of zero bytes marks the end of the archive.
-	if bytes.Equal(header, zeroBlock[0:blockSize]) {
-		if _, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
-			return nil // io.EOF is okay here
-		}
-		if bytes.Equal(header, zeroBlock[0:blockSize]) {
-			tr.err = io.EOF
-		} else {
-			tr.err = ErrHeader // zero block and then non-zero block
-		}
-		return nil
-	}
-
-	if !tr.verifyChecksum(header) {
-		tr.err = ErrHeader
-		return nil
-	}
-
-	// Unpack
-	var p parser
-	hdr := new(Header)
-	s := slicer(header)
-
-	hdr.Name = p.parseString(s.next(100))
-	hdr.Mode = p.parseNumeric(s.next(8))
-	hdr.Uid = int(p.parseNumeric(s.next(8)))
-	hdr.Gid = int(p.parseNumeric(s.next(8)))
-	hdr.Size = p.parseNumeric(s.next(12))
-	hdr.ModTime = time.Unix(p.parseNumeric(s.next(12)), 0)
-	s.next(8) // chksum
-	hdr.Typeflag = s.next(1)[0]
-	hdr.Linkname = p.parseString(s.next(100))
-
-	// The remainder of the header depends on the value of magic.
-	// The original (v7) version of tar had no explicit magic field,
-	// so its magic bytes, like the rest of the block, are NULs.
-	magic := string(s.next(8)) // contains version field as well.
-	var format string
-	switch {
-	case magic[:6] == "ustar\x00": // POSIX tar (1003.1-1988)
-		if string(header[508:512]) == "tar\x00" {
-			format = "star"
-		} else {
-			format = "posix"
-		}
-	case magic == "ustar  \x00": // old GNU tar
-		format = "gnu"
-	}
-
-	switch format {
-	case "posix", "gnu", "star":
-		hdr.Uname = p.parseString(s.next(32))
-		hdr.Gname = p.parseString(s.next(32))
-		devmajor := s.next(8)
-		devminor := s.next(8)
-		if hdr.Typeflag == TypeChar || hdr.Typeflag == TypeBlock {
-			hdr.Devmajor = p.parseNumeric(devmajor)
-			hdr.Devminor = p.parseNumeric(devminor)
-		}
-		var prefix string
-		switch format {
-		case "posix", "gnu":
-			prefix = p.parseString(s.next(155))
-		case "star":
-			prefix = p.parseString(s.next(131))
-			hdr.AccessTime = time.Unix(p.parseNumeric(s.next(12)), 0)
-			hdr.ChangeTime = time.Unix(p.parseNumeric(s.next(12)), 0)
-		}
-		if len(prefix) > 0 {
-			hdr.Name = prefix + "/" + hdr.Name
-		}
-	}
-
-	if p.err != nil {
-		tr.err = p.err
-		return nil
-	}
-
-	nb := hdr.Size
-	if isHeaderOnlyType(hdr.Typeflag) {
-		nb = 0
-	}
-	if nb < 0 {
-		tr.err = ErrHeader
-		return nil
-	}
-
-	// Set the current file reader.
-	tr.pad = -nb & (blockSize - 1) // blockSize is a power of two
-	tr.curr = &regFileReader{r: tr.r, nb: nb}
-
-	// Check for old GNU sparse format entry.
-	if hdr.Typeflag == TypeGNUSparse {
-		// Get the real size of the file.
-		hdr.Size = p.parseNumeric(header[483:495])
-		if p.err != nil {
-			tr.err = p.err
-			return nil
-		}
-
-		// Read the sparse map.
-		sp := tr.readOldGNUSparseMap(header)
-		if tr.err != nil {
-			return nil
-		}
-
-		// Current file is a GNU sparse file. Update the current file reader.
-		tr.curr, tr.err = newSparseFileReader(tr.curr, sp, hdr.Size)
-		if tr.err != nil {
-			return nil
-		}
-	}
-
-	return hdr
-}
-
-// readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format.
-// The sparse map is stored in the tar header if it's small enough. If it's larger than four entries,
-// then one or more extension headers are used to store the rest of the sparse map.
-func (tr *Reader) readOldGNUSparseMap(header []byte) []sparseEntry {
-	var p parser
-	isExtended := header[oldGNUSparseMainHeaderIsExtendedOffset] != 0
-	spCap := oldGNUSparseMainHeaderNumEntries
-	if isExtended {
-		spCap += oldGNUSparseExtendedHeaderNumEntries
-	}
-	sp := make([]sparseEntry, 0, spCap)
-	s := slicer(header[oldGNUSparseMainHeaderOffset:])
-
-	// Read the four entries from the main tar header
-	for i := 0; i < oldGNUSparseMainHeaderNumEntries; i++ {
-		offset := p.parseNumeric(s.next(oldGNUSparseOffsetSize))
-		numBytes := p.parseNumeric(s.next(oldGNUSparseNumBytesSize))
-		if p.err != nil {
-			tr.err = p.err
-			return nil
-		}
-		if offset == 0 && numBytes == 0 {
-			break
-		}
-		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
-	}
-
-	for isExtended {
-		// There are more entries. Read an extension header and parse its entries.
-		sparseHeader := make([]byte, blockSize)
-		if _, tr.err = io.ReadFull(tr.r, sparseHeader); tr.err != nil {
-			return nil
-		}
-		isExtended = sparseHeader[oldGNUSparseExtendedHeaderIsExtendedOffset] != 0
-		s = slicer(sparseHeader)
-		for i := 0; i < oldGNUSparseExtendedHeaderNumEntries; i++ {
-			offset := p.parseNumeric(s.next(oldGNUSparseOffsetSize))
-			numBytes := p.parseNumeric(s.next(oldGNUSparseNumBytesSize))
-			if p.err != nil {
-				tr.err = p.err
-				return nil
-			}
-			if offset == 0 && numBytes == 0 {
-				break
-			}
-			sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
-		}
-	}
-	return sp
-}
-
-// readGNUSparseMap1x0 reads the sparse map as stored in GNU's PAX sparse format
-// version 1.0. The format of the sparse map consists of a series of
-// newline-terminated numeric fields. The first field is the number of entries
-// and is always present. Following this are the entries, consisting of two
-// fields (offset, numBytes). This function must stop reading at the end
-// boundary of the block containing the last newline.
-//
-// Note that the GNU manual says that numeric values should be encoded in octal
-// format. However, the GNU tar utility itself outputs these values in decimal.
-// As such, this library treats values as being encoded in decimal.
-func readGNUSparseMap1x0(r io.Reader) ([]sparseEntry, error) {
-	var cntNewline int64
-	var buf bytes.Buffer
-	var blk = make([]byte, blockSize)
-
-	// feedTokens copies data in numBlock chunks from r into buf until there are
-	// at least cnt newlines in buf. It will not read more blocks than needed.
-	var feedTokens = func(cnt int64) error {
-		for cntNewline < cnt {
-			if _, err := io.ReadFull(r, blk); err != nil {
-				if err == io.EOF {
-					err = io.ErrUnexpectedEOF
-				}
-				return err
-			}
-			buf.Write(blk)
-			for _, c := range blk {
-				if c == '\n' {
-					cntNewline++
-				}
-			}
-		}
-		return nil
-	}
-
-	// nextToken gets the next token delimited by a newline. This assumes that
-	// at least one newline exists in the buffer.
-	var nextToken = func() string {
-		cntNewline--
-		tok, _ := buf.ReadString('\n')
-		return tok[:len(tok)-1] // Cut off newline
-	}
-
-	// Parse for the number of entries.
-	// Use integer overflow resistant math to check this.
-	if err := feedTokens(1); err != nil {
-		return nil, err
-	}
-	numEntries, err := strconv.ParseInt(nextToken(), 10, 0) // Intentionally parse as native int
-	if err != nil || numEntries < 0 || int(2*numEntries) < int(numEntries) {
-		return nil, ErrHeader
-	}
-
-	// Parse for all member entries.
-	// numEntries is trusted after this since a potential attacker must have
-	// committed resources proportional to what this library used.
-	if err := feedTokens(2 * numEntries); err != nil {
-		return nil, err
-	}
-	sp := make([]sparseEntry, 0, numEntries)
-	for i := int64(0); i < numEntries; i++ {
-		offset, err := strconv.ParseInt(nextToken(), 10, 64)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		numBytes, err := strconv.ParseInt(nextToken(), 10, 64)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
-	}
-	return sp, nil
-}
-
-// readGNUSparseMap0x1 reads the sparse map as stored in GNU's PAX sparse format
-// version 0.1. The sparse map is stored in the PAX headers.
-func readGNUSparseMap0x1(extHdrs map[string]string) ([]sparseEntry, error) {
-	// Get number of entries.
-	// Use integer overflow resistant math to check this.
-	numEntriesStr := extHdrs[paxGNUSparseNumBlocks]
-	numEntries, err := strconv.ParseInt(numEntriesStr, 10, 0) // Intentionally parse as native int
-	if err != nil || numEntries < 0 || int(2*numEntries) < int(numEntries) {
-		return nil, ErrHeader
-	}
-
-	// There should be two numbers in sparseMap for each entry.
-	sparseMap := strings.Split(extHdrs[paxGNUSparseMap], ",")
-	if int64(len(sparseMap)) != 2*numEntries {
-		return nil, ErrHeader
-	}
-
-	// Loop through the entries in the sparse map.
-	// numEntries is trusted now.
-	sp := make([]sparseEntry, 0, numEntries)
-	for i := int64(0); i < numEntries; i++ {
-		offset, err := strconv.ParseInt(sparseMap[2*i], 10, 64)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		numBytes, err := strconv.ParseInt(sparseMap[2*i+1], 10, 64)
-		if err != nil {
-			return nil, ErrHeader
-		}
-		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
-	}
-	return sp, nil
-}
-
-// numBytes returns the number of bytes left to read in the current file's entry
-// in the tar archive, or 0 if there is no current file.
-func (tr *Reader) numBytes() int64 {
-	if tr.curr == nil {
-		// No current file, so no bytes
-		return 0
-	}
-	return tr.curr.numBytes()
-}
-
-// Read reads from the current entry in the tar archive.
-// It returns 0, io.EOF when it reaches the end of that entry,
-// until Next is called to advance to the next entry.
-//
-// Calling Read on special types like TypeLink, TypeSymLink, TypeChar,
-// TypeBlock, TypeDir, and TypeFifo returns 0, io.EOF regardless of what
-// the Header.Size claims.
-func (tr *Reader) Read(b []byte) (n int, err error) {
-	if tr.err != nil {
-		return 0, tr.err
-	}
-	if tr.curr == nil {
-		return 0, io.EOF
-	}
-
-	n, err = tr.curr.Read(b)
-	if err != nil && err != io.EOF {
-		tr.err = err
-	}
-	return
-}
-
-func (rfr *regFileReader) Read(b []byte) (n int, err error) {
-	if rfr.nb == 0 {
-		// file consumed
-		return 0, io.EOF
-	}
-	if int64(len(b)) > rfr.nb {
-		b = b[0:rfr.nb]
-	}
-	n, err = rfr.r.Read(b)
-	rfr.nb -= int64(n)
-
-	if err == io.EOF && rfr.nb > 0 {
-		err = io.ErrUnexpectedEOF
-	}
-	return
-}
-
-// numBytes returns the number of bytes left to read in the file's data in the tar archive.
-func (rfr *regFileReader) numBytes() int64 {
-	return rfr.nb
-}
-
-// newSparseFileReader creates a new sparseFileReader, but validates all of the
-// sparse entries before doing so.
-func newSparseFileReader(rfr numBytesReader, sp []sparseEntry, total int64) (*sparseFileReader, error) {
-	if total < 0 {
-		return nil, ErrHeader // Total size cannot be negative
-	}
-
-	// Validate all sparse entries. These are the same checks as performed by
-	// the BSD tar utility.
-	for i, s := range sp {
-		switch {
-		case s.offset < 0 || s.numBytes < 0:
-			return nil, ErrHeader // Negative values are never okay
-		case s.offset > math.MaxInt64-s.numBytes:
-			return nil, ErrHeader // Integer overflow with large length
-		case s.offset+s.numBytes > total:
-			return nil, ErrHeader // Region extends beyond the "real" size
-		case i > 0 && sp[i-1].offset+sp[i-1].numBytes > s.offset:
-			return nil, ErrHeader // Regions can't overlap and must be in order
-		}
-	}
-	return &sparseFileReader{rfr: rfr, sp: sp, total: total}, nil
-}
-
-// readHole reads a sparse hole ending at endOffset.
-func (sfr *sparseFileReader) readHole(b []byte, endOffset int64) int {
-	n64 := endOffset - sfr.pos
-	if n64 > int64(len(b)) {
-		n64 = int64(len(b))
-	}
-	n := int(n64)
-	for i := 0; i < n; i++ {
-		b[i] = 0
-	}
-	sfr.pos += n64
-	return n
-}
-
-// Read reads the sparse file data in expanded form.
-func (sfr *sparseFileReader) Read(b []byte) (n int, err error) {
-	// Skip past all empty fragments.
-	for len(sfr.sp) > 0 && sfr.sp[0].numBytes == 0 {
-		sfr.sp = sfr.sp[1:]
-	}
-
-	// If there are no more fragments, then it is possible that there
-	// is one last sparse hole.
-	if len(sfr.sp) == 0 {
-		// This behavior matches the BSD tar utility.
-		// However, GNU tar stops returning data even if sfr.total is unmet.
-		if sfr.pos < sfr.total {
-			return sfr.readHole(b, sfr.total), nil
-		}
-		return 0, io.EOF
-	}
-
-	// In front of a data fragment, so read a hole.
-	if sfr.pos < sfr.sp[0].offset {
-		return sfr.readHole(b, sfr.sp[0].offset), nil
-	}
-
-	// In a data fragment, so read from it.
-	// This math is overflow free since we verify that offset and numBytes can
-	// be safely added when creating the sparseFileReader.
-	endPos := sfr.sp[0].offset + sfr.sp[0].numBytes // End offset of fragment
-	bytesLeft := endPos - sfr.pos                   // Bytes left in fragment
-	if int64(len(b)) > bytesLeft {
-		b = b[:bytesLeft]
-	}
-
-	n, err = sfr.rfr.Read(b)
-	sfr.pos += int64(n)
-	if err == io.EOF {
-		if sfr.pos < endPos {
-			err = io.ErrUnexpectedEOF // There was supposed to be more data
-		} else if sfr.pos < sfr.total {
-			err = nil // There is still an implicit sparse hole at the end
-		}
-	}
-
-	if sfr.pos == endPos {
-		sfr.sp = sfr.sp[1:] // We are done with this fragment, so pop it
-	}
-	return n, err
-}
-
-// numBytes returns the number of bytes left to read in the sparse file's
-// sparse-encoded data in the tar archive.
-func (sfr *sparseFileReader) numBytes() int64 {
-	return sfr.rfr.numBytes()
-}

+ 0 - 1125
vendor/github.com/Microsoft/go-winio/archive/tar/reader_test.go

@@ -1,1125 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar
-
-import (
-	"bytes"
-	"crypto/md5"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"math"
-	"os"
-	"reflect"
-	"strings"
-	"testing"
-	"time"
-)
-
-type untarTest struct {
-	file    string    // Test input file
-	headers []*Header // Expected output headers
-	chksums []string  // MD5 checksum of files, leave as nil if not checked
-	err     error     // Expected error to occur
-}
-
-var gnuTarTest = &untarTest{
-	file: "testdata/gnu.tar",
-	headers: []*Header{
-		{
-			Name:     "small.txt",
-			Mode:     0640,
-			Uid:      73025,
-			Gid:      5000,
-			Size:     5,
-			ModTime:  time.Unix(1244428340, 0),
-			Typeflag: '0',
-			Uname:    "dsymonds",
-			Gname:    "eng",
-		},
-		{
-			Name:     "small2.txt",
-			Mode:     0640,
-			Uid:      73025,
-			Gid:      5000,
-			Size:     11,
-			ModTime:  time.Unix(1244436044, 0),
-			Typeflag: '0',
-			Uname:    "dsymonds",
-			Gname:    "eng",
-		},
-	},
-	chksums: []string{
-		"e38b27eaccb4391bdec553a7f3ae6b2f",
-		"c65bd2e50a56a2138bf1716f2fd56fe9",
-	},
-}
-
-var sparseTarTest = &untarTest{
-	file: "testdata/sparse-formats.tar",
-	headers: []*Header{
-		{
-			Name:     "sparse-gnu",
-			Mode:     420,
-			Uid:      1000,
-			Gid:      1000,
-			Size:     200,
-			ModTime:  time.Unix(1392395740, 0),
-			Typeflag: 0x53,
-			Linkname: "",
-			Uname:    "david",
-			Gname:    "david",
-			Devmajor: 0,
-			Devminor: 0,
-		},
-		{
-			Name:     "sparse-posix-0.0",
-			Mode:     420,
-			Uid:      1000,
-			Gid:      1000,
-			Size:     200,
-			ModTime:  time.Unix(1392342187, 0),
-			Typeflag: 0x30,
-			Linkname: "",
-			Uname:    "david",
-			Gname:    "david",
-			Devmajor: 0,
-			Devminor: 0,
-		},
-		{
-			Name:     "sparse-posix-0.1",
-			Mode:     420,
-			Uid:      1000,
-			Gid:      1000,
-			Size:     200,
-			ModTime:  time.Unix(1392340456, 0),
-			Typeflag: 0x30,
-			Linkname: "",
-			Uname:    "david",
-			Gname:    "david",
-			Devmajor: 0,
-			Devminor: 0,
-		},
-		{
-			Name:     "sparse-posix-1.0",
-			Mode:     420,
-			Uid:      1000,
-			Gid:      1000,
-			Size:     200,
-			ModTime:  time.Unix(1392337404, 0),
-			Typeflag: 0x30,
-			Linkname: "",
-			Uname:    "david",
-			Gname:    "david",
-			Devmajor: 0,
-			Devminor: 0,
-		},
-		{
-			Name:     "end",
-			Mode:     420,
-			Uid:      1000,
-			Gid:      1000,
-			Size:     4,
-			ModTime:  time.Unix(1392398319, 0),
-			Typeflag: 0x30,
-			Linkname: "",
-			Uname:    "david",
-			Gname:    "david",
-			Devmajor: 0,
-			Devminor: 0,
-		},
-	},
-	chksums: []string{
-		"6f53234398c2449fe67c1812d993012f",
-		"6f53234398c2449fe67c1812d993012f",
-		"6f53234398c2449fe67c1812d993012f",
-		"6f53234398c2449fe67c1812d993012f",
-		"b0061974914468de549a2af8ced10316",
-	},
-}
-
-var untarTests = []*untarTest{
-	gnuTarTest,
-	sparseTarTest,
-	{
-		file: "testdata/star.tar",
-		headers: []*Header{
-			{
-				Name:       "small.txt",
-				Mode:       0640,
-				Uid:        73025,
-				Gid:        5000,
-				Size:       5,
-				ModTime:    time.Unix(1244592783, 0),
-				Typeflag:   '0',
-				Uname:      "dsymonds",
-				Gname:      "eng",
-				AccessTime: time.Unix(1244592783, 0),
-				ChangeTime: time.Unix(1244592783, 0),
-			},
-			{
-				Name:       "small2.txt",
-				Mode:       0640,
-				Uid:        73025,
-				Gid:        5000,
-				Size:       11,
-				ModTime:    time.Unix(1244592783, 0),
-				Typeflag:   '0',
-				Uname:      "dsymonds",
-				Gname:      "eng",
-				AccessTime: time.Unix(1244592783, 0),
-				ChangeTime: time.Unix(1244592783, 0),
-			},
-		},
-	},
-	{
-		file: "testdata/v7.tar",
-		headers: []*Header{
-			{
-				Name:     "small.txt",
-				Mode:     0444,
-				Uid:      73025,
-				Gid:      5000,
-				Size:     5,
-				ModTime:  time.Unix(1244593104, 0),
-				Typeflag: '\x00',
-			},
-			{
-				Name:     "small2.txt",
-				Mode:     0444,
-				Uid:      73025,
-				Gid:      5000,
-				Size:     11,
-				ModTime:  time.Unix(1244593104, 0),
-				Typeflag: '\x00',
-			},
-		},
-	},
-	{
-		file: "testdata/pax.tar",
-		headers: []*Header{
-			{
-				Name:       "a/123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100",
-				Mode:       0664,
-				Uid:        1000,
-				Gid:        1000,
-				Uname:      "shane",
-				Gname:      "shane",
-				Size:       7,
-				ModTime:    time.Unix(1350244992, 23960108),
-				ChangeTime: time.Unix(1350244992, 23960108),
-				AccessTime: time.Unix(1350244992, 23960108),
-				Typeflag:   TypeReg,
-			},
-			{
-				Name:       "a/b",
-				Mode:       0777,
-				Uid:        1000,
-				Gid:        1000,
-				Uname:      "shane",
-				Gname:      "shane",
-				Size:       0,
-				ModTime:    time.Unix(1350266320, 910238425),
-				ChangeTime: time.Unix(1350266320, 910238425),
-				AccessTime: time.Unix(1350266320, 910238425),
-				Typeflag:   TypeSymlink,
-				Linkname:   "123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100",
-			},
-		},
-	},
-	{
-		file: "testdata/nil-uid.tar", // golang.org/issue/5290
-		headers: []*Header{
-			{
-				Name:     "P1050238.JPG.log",
-				Mode:     0664,
-				Uid:      0,
-				Gid:      0,
-				Size:     14,
-				ModTime:  time.Unix(1365454838, 0),
-				Typeflag: TypeReg,
-				Linkname: "",
-				Uname:    "eyefi",
-				Gname:    "eyefi",
-				Devmajor: 0,
-				Devminor: 0,
-			},
-		},
-	},
-	{
-		file: "testdata/xattrs.tar",
-		headers: []*Header{
-			{
-				Name:       "small.txt",
-				Mode:       0644,
-				Uid:        1000,
-				Gid:        10,
-				Size:       5,
-				ModTime:    time.Unix(1386065770, 448252320),
-				Typeflag:   '0',
-				Uname:      "alex",
-				Gname:      "wheel",
-				AccessTime: time.Unix(1389782991, 419875220),
-				ChangeTime: time.Unix(1389782956, 794414986),
-				Xattrs: map[string]string{
-					"user.key":  "value",
-					"user.key2": "value2",
-					// Interestingly, selinux encodes the terminating null inside the xattr
-					"security.selinux": "unconfined_u:object_r:default_t:s0\x00",
-				},
-			},
-			{
-				Name:       "small2.txt",
-				Mode:       0644,
-				Uid:        1000,
-				Gid:        10,
-				Size:       11,
-				ModTime:    time.Unix(1386065770, 449252304),
-				Typeflag:   '0',
-				Uname:      "alex",
-				Gname:      "wheel",
-				AccessTime: time.Unix(1389782991, 419875220),
-				ChangeTime: time.Unix(1386065770, 449252304),
-				Xattrs: map[string]string{
-					"security.selinux": "unconfined_u:object_r:default_t:s0\x00",
-				},
-			},
-		},
-	},
-	{
-		// Matches the behavior of GNU, BSD, and STAR tar utilities.
-		file: "testdata/gnu-multi-hdrs.tar",
-		headers: []*Header{
-			{
-				Name:     "GNU2/GNU2/long-path-name",
-				Linkname: "GNU4/GNU4/long-linkpath-name",
-				ModTime:  time.Unix(0, 0),
-				Typeflag: '2',
-			},
-		},
-	},
-	{
-		// Matches the behavior of GNU and BSD tar utilities.
-		file: "testdata/pax-multi-hdrs.tar",
-		headers: []*Header{
-			{
-				Name:     "bar",
-				Linkname: "PAX4/PAX4/long-linkpath-name",
-				ModTime:  time.Unix(0, 0),
-				Typeflag: '2',
-			},
-		},
-	},
-	{
-		file: "testdata/neg-size.tar",
-		err:  ErrHeader,
-	},
-	{
-		file: "testdata/issue10968.tar",
-		err:  ErrHeader,
-	},
-	{
-		file: "testdata/issue11169.tar",
-		err:  ErrHeader,
-	},
-	{
-		file: "testdata/issue12435.tar",
-		err:  ErrHeader,
-	},
-}
-
-func TestReader(t *testing.T) {
-	for i, v := range untarTests {
-		f, err := os.Open(v.file)
-		if err != nil {
-			t.Errorf("file %s, test %d: unexpected error: %v", v.file, i, err)
-			continue
-		}
-		defer f.Close()
-
-		// Capture all headers and checksums.
-		var (
-			tr      = NewReader(f)
-			hdrs    []*Header
-			chksums []string
-			rdbuf   = make([]byte, 8)
-		)
-		for {
-			var hdr *Header
-			hdr, err = tr.Next()
-			if err != nil {
-				if err == io.EOF {
-					err = nil // Expected error
-				}
-				break
-			}
-			hdrs = append(hdrs, hdr)
-
-			if v.chksums == nil {
-				continue
-			}
-			h := md5.New()
-			_, err = io.CopyBuffer(h, tr, rdbuf) // Effectively an incremental read
-			if err != nil {
-				break
-			}
-			chksums = append(chksums, fmt.Sprintf("%x", h.Sum(nil)))
-		}
-
-		for j, hdr := range hdrs {
-			if j >= len(v.headers) {
-				t.Errorf("file %s, test %d, entry %d: unexpected header:\ngot %+v",
-					v.file, i, j, *hdr)
-				continue
-			}
-			if !reflect.DeepEqual(*hdr, *v.headers[j]) {
-				t.Errorf("file %s, test %d, entry %d: incorrect header:\ngot  %+v\nwant %+v",
-					v.file, i, j, *hdr, *v.headers[j])
-			}
-		}
-		if len(hdrs) != len(v.headers) {
-			t.Errorf("file %s, test %d: got %d headers, want %d headers",
-				v.file, i, len(hdrs), len(v.headers))
-		}
-
-		for j, sum := range chksums {
-			if j >= len(v.chksums) {
-				t.Errorf("file %s, test %d, entry %d: unexpected sum: got %s",
-					v.file, i, j, sum)
-				continue
-			}
-			if sum != v.chksums[j] {
-				t.Errorf("file %s, test %d, entry %d: incorrect checksum: got %s, want %s",
-					v.file, i, j, sum, v.chksums[j])
-			}
-		}
-
-		if err != v.err {
-			t.Errorf("file %s, test %d: unexpected error: got %v, want %v",
-				v.file, i, err, v.err)
-		}
-		f.Close()
-	}
-}
-
-func TestPartialRead(t *testing.T) {
-	f, err := os.Open("testdata/gnu.tar")
-	if err != nil {
-		t.Fatalf("Unexpected error: %v", err)
-	}
-	defer f.Close()
-
-	tr := NewReader(f)
-
-	// Read the first four bytes; Next() should skip the last byte.
-	hdr, err := tr.Next()
-	if err != nil || hdr == nil {
-		t.Fatalf("Didn't get first file: %v", err)
-	}
-	buf := make([]byte, 4)
-	if _, err := io.ReadFull(tr, buf); err != nil {
-		t.Fatalf("Unexpected error: %v", err)
-	}
-	if expected := []byte("Kilt"); !bytes.Equal(buf, expected) {
-		t.Errorf("Contents = %v, want %v", buf, expected)
-	}
-
-	// Second file
-	hdr, err = tr.Next()
-	if err != nil || hdr == nil {
-		t.Fatalf("Didn't get second file: %v", err)
-	}
-	buf = make([]byte, 6)
-	if _, err := io.ReadFull(tr, buf); err != nil {
-		t.Fatalf("Unexpected error: %v", err)
-	}
-	if expected := []byte("Google"); !bytes.Equal(buf, expected) {
-		t.Errorf("Contents = %v, want %v", buf, expected)
-	}
-}
-
-func TestParsePAXHeader(t *testing.T) {
-	paxTests := [][3]string{
-		{"a", "a=name", "10 a=name\n"}, // Test case involving multiple acceptable lengths
-		{"a", "a=name", "9 a=name\n"},  // Test case involving multiple acceptable length
-		{"mtime", "mtime=1350244992.023960108", "30 mtime=1350244992.023960108\n"}}
-	for _, test := range paxTests {
-		key, expected, raw := test[0], test[1], test[2]
-		reader := bytes.NewReader([]byte(raw))
-		headers, err := parsePAX(reader)
-		if err != nil {
-			t.Errorf("Couldn't parse correctly formatted headers: %v", err)
-			continue
-		}
-		if strings.EqualFold(headers[key], expected) {
-			t.Errorf("mtime header incorrectly parsed: got %s, wanted %s", headers[key], expected)
-			continue
-		}
-		trailer := make([]byte, 100)
-		n, err := reader.Read(trailer)
-		if err != io.EOF || n != 0 {
-			t.Error("Buffer wasn't consumed")
-		}
-	}
-	badHeaderTests := [][]byte{
-		[]byte("3 somelongkey=\n"),
-		[]byte("50 tooshort=\n"),
-	}
-	for _, test := range badHeaderTests {
-		if _, err := parsePAX(bytes.NewReader(test)); err != ErrHeader {
-			t.Fatal("Unexpected success when parsing bad header")
-		}
-	}
-}
-
-func TestParsePAXTime(t *testing.T) {
-	// Some valid PAX time values
-	timestamps := map[string]time.Time{
-		"1350244992.023960108":  time.Unix(1350244992, 23960108), // The common case
-		"1350244992.02396010":   time.Unix(1350244992, 23960100), // Lower precision value
-		"1350244992.0239601089": time.Unix(1350244992, 23960108), // Higher precision value
-		"1350244992":            time.Unix(1350244992, 0),        // Low precision value
-	}
-	for input, expected := range timestamps {
-		ts, err := parsePAXTime(input)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !ts.Equal(expected) {
-			t.Fatalf("Time parsing failure %s %s", ts, expected)
-		}
-	}
-}
-
-func TestMergePAX(t *testing.T) {
-	hdr := new(Header)
-	// Test a string, integer, and time based value.
-	headers := map[string]string{
-		"path":  "a/b/c",
-		"uid":   "1000",
-		"mtime": "1350244992.023960108",
-	}
-	err := mergePAX(hdr, headers)
-	if err != nil {
-		t.Fatal(err)
-	}
-	want := &Header{
-		Name:    "a/b/c",
-		Uid:     1000,
-		ModTime: time.Unix(1350244992, 23960108),
-	}
-	if !reflect.DeepEqual(hdr, want) {
-		t.Errorf("incorrect merge: got %+v, want %+v", hdr, want)
-	}
-}
-
-func TestSparseFileReader(t *testing.T) {
-	var vectors = []struct {
-		realSize   int64         // Real size of the output file
-		sparseMap  []sparseEntry // Input sparse map
-		sparseData string        // Input compact data
-		expected   string        // Expected output data
-		err        error         // Expected error outcome
-	}{{
-		realSize: 8,
-		sparseMap: []sparseEntry{
-			{offset: 0, numBytes: 2},
-			{offset: 5, numBytes: 3},
-		},
-		sparseData: "abcde",
-		expected:   "ab\x00\x00\x00cde",
-	}, {
-		realSize: 10,
-		sparseMap: []sparseEntry{
-			{offset: 0, numBytes: 2},
-			{offset: 5, numBytes: 3},
-		},
-		sparseData: "abcde",
-		expected:   "ab\x00\x00\x00cde\x00\x00",
-	}, {
-		realSize: 8,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 2},
-		},
-		sparseData: "abcde",
-		expected:   "\x00abc\x00\x00de",
-	}, {
-		realSize: 8,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 0},
-			{offset: 6, numBytes: 0},
-			{offset: 6, numBytes: 2},
-		},
-		sparseData: "abcde",
-		expected:   "\x00abc\x00\x00de",
-	}, {
-		realSize: 10,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 2},
-		},
-		sparseData: "abcde",
-		expected:   "\x00abc\x00\x00de\x00\x00",
-	}, {
-		realSize: 10,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 2},
-			{offset: 8, numBytes: 0},
-			{offset: 8, numBytes: 0},
-			{offset: 8, numBytes: 0},
-			{offset: 8, numBytes: 0},
-		},
-		sparseData: "abcde",
-		expected:   "\x00abc\x00\x00de\x00\x00",
-	}, {
-		realSize:   2,
-		sparseMap:  []sparseEntry{},
-		sparseData: "",
-		expected:   "\x00\x00",
-	}, {
-		realSize:  -2,
-		sparseMap: []sparseEntry{},
-		err:       ErrHeader,
-	}, {
-		realSize: -10,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 2},
-		},
-		sparseData: "abcde",
-		err:        ErrHeader,
-	}, {
-		realSize: 10,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 5},
-		},
-		sparseData: "abcde",
-		err:        ErrHeader,
-	}, {
-		realSize: 35,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: 5},
-		},
-		sparseData: "abcde",
-		err:        io.ErrUnexpectedEOF,
-	}, {
-		realSize: 35,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 6, numBytes: -5},
-		},
-		sparseData: "abcde",
-		err:        ErrHeader,
-	}, {
-		realSize: 35,
-		sparseMap: []sparseEntry{
-			{offset: math.MaxInt64, numBytes: 3},
-			{offset: 6, numBytes: -5},
-		},
-		sparseData: "abcde",
-		err:        ErrHeader,
-	}, {
-		realSize: 10,
-		sparseMap: []sparseEntry{
-			{offset: 1, numBytes: 3},
-			{offset: 2, numBytes: 2},
-		},
-		sparseData: "abcde",
-		err:        ErrHeader,
-	}}
-
-	for i, v := range vectors {
-		r := bytes.NewReader([]byte(v.sparseData))
-		rfr := &regFileReader{r: r, nb: int64(len(v.sparseData))}
-
-		var sfr *sparseFileReader
-		var err error
-		var buf []byte
-
-		sfr, err = newSparseFileReader(rfr, v.sparseMap, v.realSize)
-		if err != nil {
-			goto fail
-		}
-		if sfr.numBytes() != int64(len(v.sparseData)) {
-			t.Errorf("test %d, numBytes() before reading: got %d, want %d", i, sfr.numBytes(), len(v.sparseData))
-		}
-		buf, err = ioutil.ReadAll(sfr)
-		if err != nil {
-			goto fail
-		}
-		if string(buf) != v.expected {
-			t.Errorf("test %d, ReadAll(): got %q, want %q", i, string(buf), v.expected)
-		}
-		if sfr.numBytes() != 0 {
-			t.Errorf("test %d, numBytes() after reading: got %d, want %d", i, sfr.numBytes(), 0)
-		}
-
-	fail:
-		if err != v.err {
-			t.Errorf("test %d, unexpected error: got %v, want %v", i, err, v.err)
-		}
-	}
-}
-
-func TestReadGNUSparseMap0x1(t *testing.T) {
-	const (
-		maxUint = ^uint(0)
-		maxInt  = int(maxUint >> 1)
-	)
-	var (
-		big1 = fmt.Sprintf("%d", int64(maxInt))
-		big2 = fmt.Sprintf("%d", (int64(maxInt)/2)+1)
-		big3 = fmt.Sprintf("%d", (int64(maxInt) / 3))
-	)
-
-	var vectors = []struct {
-		extHdrs   map[string]string // Input data
-		sparseMap []sparseEntry     // Expected sparse entries to be outputted
-		err       error             // Expected errors that may be raised
-	}{{
-		extHdrs: map[string]string{paxGNUSparseNumBlocks: "-4"},
-		err:     ErrHeader,
-	}, {
-		extHdrs: map[string]string{paxGNUSparseNumBlocks: "fee "},
-		err:     ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: big1,
-			paxGNUSparseMap:       "0,5,10,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: big2,
-			paxGNUSparseMap:       "0,5,10,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: big3,
-			paxGNUSparseMap:       "0,5,10,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: "4",
-			paxGNUSparseMap:       "0.5,5,10,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: "4",
-			paxGNUSparseMap:       "0,5.5,10,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: "4",
-			paxGNUSparseMap:       "0,fewafewa.5,fewafw,5,20,5,30,5",
-		},
-		err: ErrHeader,
-	}, {
-		extHdrs: map[string]string{
-			paxGNUSparseNumBlocks: "4",
-			paxGNUSparseMap:       "0,5,10,5,20,5,30,5",
-		},
-		sparseMap: []sparseEntry{{0, 5}, {10, 5}, {20, 5}, {30, 5}},
-	}}
-
-	for i, v := range vectors {
-		sp, err := readGNUSparseMap0x1(v.extHdrs)
-		if !reflect.DeepEqual(sp, v.sparseMap) && !(len(sp) == 0 && len(v.sparseMap) == 0) {
-			t.Errorf("test %d, readGNUSparseMap0x1(...): got %v, want %v", i, sp, v.sparseMap)
-		}
-		if err != v.err {
-			t.Errorf("test %d, unexpected error: got %v, want %v", i, err, v.err)
-		}
-	}
-}
-
-func TestReadGNUSparseMap1x0(t *testing.T) {
-	var sp = []sparseEntry{{1, 2}, {3, 4}}
-	for i := 0; i < 98; i++ {
-		sp = append(sp, sparseEntry{54321, 12345})
-	}
-
-	var vectors = []struct {
-		input     string        // Input data
-		sparseMap []sparseEntry // Expected sparse entries to be outputted
-		cnt       int           // Expected number of bytes read
-		err       error         // Expected errors that may be raised
-	}{{
-		input: "",
-		cnt:   0,
-		err:   io.ErrUnexpectedEOF,
-	}, {
-		input: "ab",
-		cnt:   2,
-		err:   io.ErrUnexpectedEOF,
-	}, {
-		input: strings.Repeat("\x00", 512),
-		cnt:   512,
-		err:   io.ErrUnexpectedEOF,
-	}, {
-		input: strings.Repeat("\x00", 511) + "\n",
-		cnt:   512,
-		err:   ErrHeader,
-	}, {
-		input: strings.Repeat("\n", 512),
-		cnt:   512,
-		err:   ErrHeader,
-	}, {
-		input:     "0\n" + strings.Repeat("\x00", 510) + strings.Repeat("a", 512),
-		sparseMap: []sparseEntry{},
-		cnt:       512,
-	}, {
-		input:     strings.Repeat("0", 512) + "0\n" + strings.Repeat("\x00", 510),
-		sparseMap: []sparseEntry{},
-		cnt:       1024,
-	}, {
-		input:     strings.Repeat("0", 1024) + "1\n2\n3\n" + strings.Repeat("\x00", 506),
-		sparseMap: []sparseEntry{{2, 3}},
-		cnt:       1536,
-	}, {
-		input: strings.Repeat("0", 1024) + "1\n2\n\n" + strings.Repeat("\x00", 509),
-		cnt:   1536,
-		err:   ErrHeader,
-	}, {
-		input: strings.Repeat("0", 1024) + "1\n2\n" + strings.Repeat("\x00", 508),
-		cnt:   1536,
-		err:   io.ErrUnexpectedEOF,
-	}, {
-		input: "-1\n2\n\n" + strings.Repeat("\x00", 506),
-		cnt:   512,
-		err:   ErrHeader,
-	}, {
-		input: "1\nk\n2\n" + strings.Repeat("\x00", 506),
-		cnt:   512,
-		err:   ErrHeader,
-	}, {
-		input:     "100\n1\n2\n3\n4\n" + strings.Repeat("54321\n0000000000000012345\n", 98) + strings.Repeat("\x00", 512),
-		cnt:       2560,
-		sparseMap: sp,
-	}}
-
-	for i, v := range vectors {
-		r := strings.NewReader(v.input)
-		sp, err := readGNUSparseMap1x0(r)
-		if !reflect.DeepEqual(sp, v.sparseMap) && !(len(sp) == 0 && len(v.sparseMap) == 0) {
-			t.Errorf("test %d, readGNUSparseMap1x0(...): got %v, want %v", i, sp, v.sparseMap)
-		}
-		if numBytes := len(v.input) - r.Len(); numBytes != v.cnt {
-			t.Errorf("test %d, bytes read: got %v, want %v", i, numBytes, v.cnt)
-		}
-		if err != v.err {
-			t.Errorf("test %d, unexpected error: got %v, want %v", i, err, v.err)
-		}
-	}
-}
-
-func TestUninitializedRead(t *testing.T) {
-	test := gnuTarTest
-	f, err := os.Open(test.file)
-	if err != nil {
-		t.Fatalf("Unexpected error: %v", err)
-	}
-	defer f.Close()
-
-	tr := NewReader(f)
-	_, err = tr.Read([]byte{})
-	if err == nil || err != io.EOF {
-		t.Errorf("Unexpected error: %v, wanted %v", err, io.EOF)
-	}
-
-}
-
-type reader struct{ io.Reader }
-type readSeeker struct{ io.ReadSeeker }
-type readBadSeeker struct{ io.ReadSeeker }
-
-func (rbs *readBadSeeker) Seek(int64, int) (int64, error) { return 0, fmt.Errorf("illegal seek") }
-
-// TestReadTruncation test the ending condition on various truncated files and
-// that truncated files are still detected even if the underlying io.Reader
-// satisfies io.Seeker.
-func TestReadTruncation(t *testing.T) {
-	var ss []string
-	for _, p := range []string{
-		"testdata/gnu.tar",
-		"testdata/ustar-file-reg.tar",
-		"testdata/pax-path-hdr.tar",
-		"testdata/sparse-formats.tar",
-	} {
-		buf, err := ioutil.ReadFile(p)
-		if err != nil {
-			t.Fatalf("unexpected error: %v", err)
-		}
-		ss = append(ss, string(buf))
-	}
-
-	data1, data2, pax, sparse := ss[0], ss[1], ss[2], ss[3]
-	data2 += strings.Repeat("\x00", 10*512)
-	trash := strings.Repeat("garbage ", 64) // Exactly 512 bytes
-
-	var vectors = []struct {
-		input string // Input stream
-		cnt   int    // Expected number of headers read
-		err   error  // Expected error outcome
-	}{
-		{"", 0, io.EOF}, // Empty file is a "valid" tar file
-		{data1[:511], 0, io.ErrUnexpectedEOF},
-		{data1[:512], 1, io.ErrUnexpectedEOF},
-		{data1[:1024], 1, io.EOF},
-		{data1[:1536], 2, io.ErrUnexpectedEOF},
-		{data1[:2048], 2, io.EOF},
-		{data1, 2, io.EOF},
-		{data1[:2048] + data2[:1536], 3, io.EOF},
-		{data2[:511], 0, io.ErrUnexpectedEOF},
-		{data2[:512], 1, io.ErrUnexpectedEOF},
-		{data2[:1195], 1, io.ErrUnexpectedEOF},
-		{data2[:1196], 1, io.EOF}, // Exact end of data and start of padding
-		{data2[:1200], 1, io.EOF},
-		{data2[:1535], 1, io.EOF},
-		{data2[:1536], 1, io.EOF}, // Exact end of padding
-		{data2[:1536] + trash[:1], 1, io.ErrUnexpectedEOF},
-		{data2[:1536] + trash[:511], 1, io.ErrUnexpectedEOF},
-		{data2[:1536] + trash, 1, ErrHeader},
-		{data2[:2048], 1, io.EOF}, // Exactly 1 empty block
-		{data2[:2048] + trash[:1], 1, io.ErrUnexpectedEOF},
-		{data2[:2048] + trash[:511], 1, io.ErrUnexpectedEOF},
-		{data2[:2048] + trash, 1, ErrHeader},
-		{data2[:2560], 1, io.EOF}, // Exactly 2 empty blocks (normal end-of-stream)
-		{data2[:2560] + trash[:1], 1, io.EOF},
-		{data2[:2560] + trash[:511], 1, io.EOF},
-		{data2[:2560] + trash, 1, io.EOF},
-		{data2[:3072], 1, io.EOF},
-		{pax, 0, io.EOF}, // PAX header without data is a "valid" tar file
-		{pax + trash[:1], 0, io.ErrUnexpectedEOF},
-		{pax + trash[:511], 0, io.ErrUnexpectedEOF},
-		{sparse[:511], 0, io.ErrUnexpectedEOF},
-		// TODO(dsnet): This should pass, but currently fails.
-		// {sparse[:512], 0, io.ErrUnexpectedEOF},
-		{sparse[:3584], 1, io.EOF},
-		{sparse[:9200], 1, io.EOF}, // Terminate in padding of sparse header
-		{sparse[:9216], 1, io.EOF},
-		{sparse[:9728], 2, io.ErrUnexpectedEOF},
-		{sparse[:10240], 2, io.EOF},
-		{sparse[:11264], 2, io.ErrUnexpectedEOF},
-		{sparse, 5, io.EOF},
-		{sparse + trash, 5, io.EOF},
-	}
-
-	for i, v := range vectors {
-		for j := 0; j < 6; j++ {
-			var tr *Reader
-			var s1, s2 string
-
-			switch j {
-			case 0:
-				tr = NewReader(&reader{strings.NewReader(v.input)})
-				s1, s2 = "io.Reader", "auto"
-			case 1:
-				tr = NewReader(&reader{strings.NewReader(v.input)})
-				s1, s2 = "io.Reader", "manual"
-			case 2:
-				tr = NewReader(&readSeeker{strings.NewReader(v.input)})
-				s1, s2 = "io.ReadSeeker", "auto"
-			case 3:
-				tr = NewReader(&readSeeker{strings.NewReader(v.input)})
-				s1, s2 = "io.ReadSeeker", "manual"
-			case 4:
-				tr = NewReader(&readBadSeeker{strings.NewReader(v.input)})
-				s1, s2 = "ReadBadSeeker", "auto"
-			case 5:
-				tr = NewReader(&readBadSeeker{strings.NewReader(v.input)})
-				s1, s2 = "ReadBadSeeker", "manual"
-			}
-
-			var cnt int
-			var err error
-			for {
-				if _, err = tr.Next(); err != nil {
-					break
-				}
-				cnt++
-				if s2 == "manual" {
-					if _, err = io.Copy(ioutil.Discard, tr); err != nil {
-						break
-					}
-				}
-			}
-			if err != v.err {
-				t.Errorf("test %d, NewReader(%s(...)) with %s discard: got %v, want %v",
-					i, s1, s2, err, v.err)
-			}
-			if cnt != v.cnt {
-				t.Errorf("test %d, NewReader(%s(...)) with %s discard: got %d headers, want %d headers",
-					i, s1, s2, cnt, v.cnt)
-			}
-		}
-	}
-}
-
-// TestReadHeaderOnly tests that Reader does not attempt to read special
-// header-only files.
-func TestReadHeaderOnly(t *testing.T) {
-	f, err := os.Open("testdata/hdr-only.tar")
-	if err != nil {
-		t.Fatalf("unexpected error: %v", err)
-	}
-	defer f.Close()
-
-	var hdrs []*Header
-	tr := NewReader(f)
-	for {
-		hdr, err := tr.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Errorf("Next(): got %v, want %v", err, nil)
-			continue
-		}
-		hdrs = append(hdrs, hdr)
-
-		// If a special flag, we should read nothing.
-		cnt, _ := io.ReadFull(tr, []byte{0})
-		if cnt > 0 && hdr.Typeflag != TypeReg {
-			t.Errorf("ReadFull(...): got %d bytes, want 0 bytes", cnt)
-		}
-	}
-
-	// File is crafted with 16 entries. The later 8 are identical to the first
-	// 8 except that the size is set.
-	if len(hdrs) != 16 {
-		t.Fatalf("len(hdrs): got %d, want %d", len(hdrs), 16)
-	}
-	for i := 0; i < 8; i++ {
-		var hdr1, hdr2 = hdrs[i+0], hdrs[i+8]
-		hdr1.Size, hdr2.Size = 0, 0
-		if !reflect.DeepEqual(*hdr1, *hdr2) {
-			t.Errorf("incorrect header:\ngot  %+v\nwant %+v", *hdr1, *hdr2)
-		}
-	}
-}
-
-func TestParsePAXRecord(t *testing.T) {
-	var medName = strings.Repeat("CD", 50)
-	var longName = strings.Repeat("AB", 100)
-
-	var vectors = []struct {
-		input     string
-		residual  string
-		outputKey string
-		outputVal string
-		ok        bool
-	}{
-		{"6 k=v\n\n", "\n", "k", "v", true},
-		{"19 path=/etc/hosts\n", "", "path", "/etc/hosts", true},
-		{"210 path=" + longName + "\nabc", "abc", "path", longName, true},
-		{"110 path=" + medName + "\n", "", "path", medName, true},
-		{"9 foo=ba\n", "", "foo", "ba", true},
-		{"11 foo=bar\n\x00", "\x00", "foo", "bar", true},
-		{"18 foo=b=\nar=\n==\x00\n", "", "foo", "b=\nar=\n==\x00", true},
-		{"27 foo=hello9 foo=ba\nworld\n", "", "foo", "hello9 foo=ba\nworld", true},
-		{"27 ☺☻☹=日a本b語ç\nmeow mix", "meow mix", "☺☻☹", "日a本b語ç", true},
-		{"17 \x00hello=\x00world\n", "", "\x00hello", "\x00world", true},
-		{"1 k=1\n", "1 k=1\n", "", "", false},
-		{"6 k~1\n", "6 k~1\n", "", "", false},
-		{"6_k=1\n", "6_k=1\n", "", "", false},
-		{"6 k=1 ", "6 k=1 ", "", "", false},
-		{"632 k=1\n", "632 k=1\n", "", "", false},
-		{"16 longkeyname=hahaha\n", "16 longkeyname=hahaha\n", "", "", false},
-		{"3 somelongkey=\n", "3 somelongkey=\n", "", "", false},
-		{"50 tooshort=\n", "50 tooshort=\n", "", "", false},
-	}
-
-	for _, v := range vectors {
-		key, val, res, err := parsePAXRecord(v.input)
-		ok := (err == nil)
-		if v.ok != ok {
-			if v.ok {
-				t.Errorf("parsePAXRecord(%q): got parsing failure, want success", v.input)
-			} else {
-				t.Errorf("parsePAXRecord(%q): got parsing success, want failure", v.input)
-			}
-		}
-		if ok && (key != v.outputKey || val != v.outputVal) {
-			t.Errorf("parsePAXRecord(%q): got (%q: %q), want (%q: %q)",
-				v.input, key, val, v.outputKey, v.outputVal)
-		}
-		if res != v.residual {
-			t.Errorf("parsePAXRecord(%q): got residual %q, want residual %q",
-				v.input, res, v.residual)
-		}
-	}
-}
-
-func TestParseNumeric(t *testing.T) {
-	var vectors = []struct {
-		input  string
-		output int64
-		ok     bool
-	}{
-		// Test base-256 (binary) encoded values.
-		{"", 0, true},
-		{"\x80", 0, true},
-		{"\x80\x00", 0, true},
-		{"\x80\x00\x00", 0, true},
-		{"\xbf", (1 << 6) - 1, true},
-		{"\xbf\xff", (1 << 14) - 1, true},
-		{"\xbf\xff\xff", (1 << 22) - 1, true},
-		{"\xff", -1, true},
-		{"\xff\xff", -1, true},
-		{"\xff\xff\xff", -1, true},
-		{"\xc0", -1 * (1 << 6), true},
-		{"\xc0\x00", -1 * (1 << 14), true},
-		{"\xc0\x00\x00", -1 * (1 << 22), true},
-		{"\x87\x76\xa2\x22\xeb\x8a\x72\x61", 537795476381659745, true},
-		{"\x80\x00\x00\x00\x07\x76\xa2\x22\xeb\x8a\x72\x61", 537795476381659745, true},
-		{"\xf7\x76\xa2\x22\xeb\x8a\x72\x61", -615126028225187231, true},
-		{"\xff\xff\xff\xff\xf7\x76\xa2\x22\xeb\x8a\x72\x61", -615126028225187231, true},
-		{"\x80\x7f\xff\xff\xff\xff\xff\xff\xff", math.MaxInt64, true},
-		{"\x80\x80\x00\x00\x00\x00\x00\x00\x00", 0, false},
-		{"\xff\x80\x00\x00\x00\x00\x00\x00\x00", math.MinInt64, true},
-		{"\xff\x7f\xff\xff\xff\xff\xff\xff\xff", 0, false},
-		{"\xf5\xec\xd1\xc7\x7e\x5f\x26\x48\x81\x9f\x8f\x9b", 0, false},
-
-		// Test base-8 (octal) encoded values.
-		{"0000000\x00", 0, true},
-		{" \x0000000\x00", 0, true},
-		{" \x0000003\x00", 3, true},
-		{"00000000227\x00", 0227, true},
-		{"032033\x00 ", 032033, true},
-		{"320330\x00 ", 0320330, true},
-		{"0000660\x00 ", 0660, true},
-		{"\x00 0000660\x00 ", 0660, true},
-		{"0123456789abcdef", 0, false},
-		{"0123456789\x00abcdef", 0, false},
-		{"01234567\x0089abcdef", 342391, true},
-		{"0123\x7e\x5f\x264123", 0, false},
-	}
-
-	for _, v := range vectors {
-		var p parser
-		num := p.parseNumeric([]byte(v.input))
-		ok := (p.err == nil)
-		if v.ok != ok {
-			if v.ok {
-				t.Errorf("parseNumeric(%q): got parsing failure, want success", v.input)
-			} else {
-				t.Errorf("parseNumeric(%q): got parsing success, want failure", v.input)
-			}
-		}
-		if ok && num != v.output {
-			t.Errorf("parseNumeric(%q): got %d, want %d", v.input, num, v.output)
-		}
-	}
-}

+ 0 - 20
vendor/github.com/Microsoft/go-winio/archive/tar/stat_atim.go

@@ -1,20 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build linux dragonfly openbsd solaris
-
-package tar
-
-import (
-	"syscall"
-	"time"
-)
-
-func statAtime(st *syscall.Stat_t) time.Time {
-	return time.Unix(st.Atim.Unix())
-}
-
-func statCtime(st *syscall.Stat_t) time.Time {
-	return time.Unix(st.Ctim.Unix())
-}

+ 0 - 20
vendor/github.com/Microsoft/go-winio/archive/tar/stat_atimespec.go

@@ -1,20 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin freebsd netbsd
-
-package tar
-
-import (
-	"syscall"
-	"time"
-)
-
-func statAtime(st *syscall.Stat_t) time.Time {
-	return time.Unix(st.Atimespec.Unix())
-}
-
-func statCtime(st *syscall.Stat_t) time.Time {
-	return time.Unix(st.Ctimespec.Unix())
-}

+ 0 - 32
vendor/github.com/Microsoft/go-winio/archive/tar/stat_unix.go

@@ -1,32 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build linux darwin dragonfly freebsd openbsd netbsd solaris
-
-package tar
-
-import (
-	"os"
-	"syscall"
-)
-
-func init() {
-	sysStat = statUnix
-}
-
-func statUnix(fi os.FileInfo, h *Header) error {
-	sys, ok := fi.Sys().(*syscall.Stat_t)
-	if !ok {
-		return nil
-	}
-	h.Uid = int(sys.Uid)
-	h.Gid = int(sys.Gid)
-	// TODO(bradfitz): populate username & group.  os/user
-	// doesn't cache LookupId lookups, and lacks group
-	// lookup functions.
-	h.AccessTime = statAtime(sys)
-	h.ChangeTime = statCtime(sys)
-	// TODO(bradfitz): major/minor device numbers?
-	return nil
-}

+ 0 - 325
vendor/github.com/Microsoft/go-winio/archive/tar/tar_test.go

@@ -1,325 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar
-
-import (
-	"bytes"
-	"io/ioutil"
-	"os"
-	"path"
-	"reflect"
-	"strings"
-	"testing"
-	"time"
-)
-
-func TestFileInfoHeader(t *testing.T) {
-	fi, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	h, err := FileInfoHeader(fi, "")
-	if err != nil {
-		t.Fatalf("FileInfoHeader: %v", err)
-	}
-	if g, e := h.Name, "small.txt"; g != e {
-		t.Errorf("Name = %q; want %q", g, e)
-	}
-	if g, e := h.Mode, int64(fi.Mode().Perm())|c_ISREG; g != e {
-		t.Errorf("Mode = %#o; want %#o", g, e)
-	}
-	if g, e := h.Size, int64(5); g != e {
-		t.Errorf("Size = %v; want %v", g, e)
-	}
-	if g, e := h.ModTime, fi.ModTime(); !g.Equal(e) {
-		t.Errorf("ModTime = %v; want %v", g, e)
-	}
-	// FileInfoHeader should error when passing nil FileInfo
-	if _, err := FileInfoHeader(nil, ""); err == nil {
-		t.Fatalf("Expected error when passing nil to FileInfoHeader")
-	}
-}
-
-func TestFileInfoHeaderDir(t *testing.T) {
-	fi, err := os.Stat("testdata")
-	if err != nil {
-		t.Fatal(err)
-	}
-	h, err := FileInfoHeader(fi, "")
-	if err != nil {
-		t.Fatalf("FileInfoHeader: %v", err)
-	}
-	if g, e := h.Name, "testdata/"; g != e {
-		t.Errorf("Name = %q; want %q", g, e)
-	}
-	// Ignoring c_ISGID for golang.org/issue/4867
-	if g, e := h.Mode&^c_ISGID, int64(fi.Mode().Perm())|c_ISDIR; g != e {
-		t.Errorf("Mode = %#o; want %#o", g, e)
-	}
-	if g, e := h.Size, int64(0); g != e {
-		t.Errorf("Size = %v; want %v", g, e)
-	}
-	if g, e := h.ModTime, fi.ModTime(); !g.Equal(e) {
-		t.Errorf("ModTime = %v; want %v", g, e)
-	}
-}
-
-func TestFileInfoHeaderSymlink(t *testing.T) {
-	h, err := FileInfoHeader(symlink{}, "some-target")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if g, e := h.Name, "some-symlink"; g != e {
-		t.Errorf("Name = %q; want %q", g, e)
-	}
-	if g, e := h.Linkname, "some-target"; g != e {
-		t.Errorf("Linkname = %q; want %q", g, e)
-	}
-}
-
-type symlink struct{}
-
-func (symlink) Name() string       { return "some-symlink" }
-func (symlink) Size() int64        { return 0 }
-func (symlink) Mode() os.FileMode  { return os.ModeSymlink }
-func (symlink) ModTime() time.Time { return time.Time{} }
-func (symlink) IsDir() bool        { return false }
-func (symlink) Sys() interface{}   { return nil }
-
-func TestRoundTrip(t *testing.T) {
-	data := []byte("some file contents")
-
-	var b bytes.Buffer
-	tw := NewWriter(&b)
-	hdr := &Header{
-		Name:    "file.txt",
-		Uid:     1 << 21, // too big for 8 octal digits
-		Size:    int64(len(data)),
-		ModTime: time.Now(),
-	}
-	// tar only supports second precision.
-	hdr.ModTime = hdr.ModTime.Add(-time.Duration(hdr.ModTime.Nanosecond()) * time.Nanosecond)
-	if err := tw.WriteHeader(hdr); err != nil {
-		t.Fatalf("tw.WriteHeader: %v", err)
-	}
-	if _, err := tw.Write(data); err != nil {
-		t.Fatalf("tw.Write: %v", err)
-	}
-	if err := tw.Close(); err != nil {
-		t.Fatalf("tw.Close: %v", err)
-	}
-
-	// Read it back.
-	tr := NewReader(&b)
-	rHdr, err := tr.Next()
-	if err != nil {
-		t.Fatalf("tr.Next: %v", err)
-	}
-	if !reflect.DeepEqual(rHdr, hdr) {
-		t.Errorf("Header mismatch.\n got %+v\nwant %+v", rHdr, hdr)
-	}
-	rData, err := ioutil.ReadAll(tr)
-	if err != nil {
-		t.Fatalf("Read: %v", err)
-	}
-	if !bytes.Equal(rData, data) {
-		t.Errorf("Data mismatch.\n got %q\nwant %q", rData, data)
-	}
-}
-
-type headerRoundTripTest struct {
-	h  *Header
-	fm os.FileMode
-}
-
-func TestHeaderRoundTrip(t *testing.T) {
-	golden := []headerRoundTripTest{
-		// regular file.
-		{
-			h: &Header{
-				Name:     "test.txt",
-				Mode:     0644 | c_ISREG,
-				Size:     12,
-				ModTime:  time.Unix(1360600916, 0),
-				Typeflag: TypeReg,
-			},
-			fm: 0644,
-		},
-		// symbolic link.
-		{
-			h: &Header{
-				Name:     "link.txt",
-				Mode:     0777 | c_ISLNK,
-				Size:     0,
-				ModTime:  time.Unix(1360600852, 0),
-				Typeflag: TypeSymlink,
-			},
-			fm: 0777 | os.ModeSymlink,
-		},
-		// character device node.
-		{
-			h: &Header{
-				Name:     "dev/null",
-				Mode:     0666 | c_ISCHR,
-				Size:     0,
-				ModTime:  time.Unix(1360578951, 0),
-				Typeflag: TypeChar,
-			},
-			fm: 0666 | os.ModeDevice | os.ModeCharDevice,
-		},
-		// block device node.
-		{
-			h: &Header{
-				Name:     "dev/sda",
-				Mode:     0660 | c_ISBLK,
-				Size:     0,
-				ModTime:  time.Unix(1360578954, 0),
-				Typeflag: TypeBlock,
-			},
-			fm: 0660 | os.ModeDevice,
-		},
-		// directory.
-		{
-			h: &Header{
-				Name:     "dir/",
-				Mode:     0755 | c_ISDIR,
-				Size:     0,
-				ModTime:  time.Unix(1360601116, 0),
-				Typeflag: TypeDir,
-			},
-			fm: 0755 | os.ModeDir,
-		},
-		// fifo node.
-		{
-			h: &Header{
-				Name:     "dev/initctl",
-				Mode:     0600 | c_ISFIFO,
-				Size:     0,
-				ModTime:  time.Unix(1360578949, 0),
-				Typeflag: TypeFifo,
-			},
-			fm: 0600 | os.ModeNamedPipe,
-		},
-		// setuid.
-		{
-			h: &Header{
-				Name:     "bin/su",
-				Mode:     0755 | c_ISREG | c_ISUID,
-				Size:     23232,
-				ModTime:  time.Unix(1355405093, 0),
-				Typeflag: TypeReg,
-			},
-			fm: 0755 | os.ModeSetuid,
-		},
-		// setguid.
-		{
-			h: &Header{
-				Name:     "group.txt",
-				Mode:     0750 | c_ISREG | c_ISGID,
-				Size:     0,
-				ModTime:  time.Unix(1360602346, 0),
-				Typeflag: TypeReg,
-			},
-			fm: 0750 | os.ModeSetgid,
-		},
-		// sticky.
-		{
-			h: &Header{
-				Name:     "sticky.txt",
-				Mode:     0600 | c_ISREG | c_ISVTX,
-				Size:     7,
-				ModTime:  time.Unix(1360602540, 0),
-				Typeflag: TypeReg,
-			},
-			fm: 0600 | os.ModeSticky,
-		},
-		// hard link.
-		{
-			h: &Header{
-				Name:     "hard.txt",
-				Mode:     0644 | c_ISREG,
-				Size:     0,
-				Linkname: "file.txt",
-				ModTime:  time.Unix(1360600916, 0),
-				Typeflag: TypeLink,
-			},
-			fm: 0644,
-		},
-		// More information.
-		{
-			h: &Header{
-				Name:     "info.txt",
-				Mode:     0600 | c_ISREG,
-				Size:     0,
-				Uid:      1000,
-				Gid:      1000,
-				ModTime:  time.Unix(1360602540, 0),
-				Uname:    "slartibartfast",
-				Gname:    "users",
-				Typeflag: TypeReg,
-			},
-			fm: 0600,
-		},
-	}
-
-	for i, g := range golden {
-		fi := g.h.FileInfo()
-		h2, err := FileInfoHeader(fi, "")
-		if err != nil {
-			t.Error(err)
-			continue
-		}
-		if strings.Contains(fi.Name(), "/") {
-			t.Errorf("FileInfo of %q contains slash: %q", g.h.Name, fi.Name())
-		}
-		name := path.Base(g.h.Name)
-		if fi.IsDir() {
-			name += "/"
-		}
-		if got, want := h2.Name, name; got != want {
-			t.Errorf("i=%d: Name: got %v, want %v", i, got, want)
-		}
-		if got, want := h2.Size, g.h.Size; got != want {
-			t.Errorf("i=%d: Size: got %v, want %v", i, got, want)
-		}
-		if got, want := h2.Uid, g.h.Uid; got != want {
-			t.Errorf("i=%d: Uid: got %d, want %d", i, got, want)
-		}
-		if got, want := h2.Gid, g.h.Gid; got != want {
-			t.Errorf("i=%d: Gid: got %d, want %d", i, got, want)
-		}
-		if got, want := h2.Uname, g.h.Uname; got != want {
-			t.Errorf("i=%d: Uname: got %q, want %q", i, got, want)
-		}
-		if got, want := h2.Gname, g.h.Gname; got != want {
-			t.Errorf("i=%d: Gname: got %q, want %q", i, got, want)
-		}
-		if got, want := h2.Linkname, g.h.Linkname; got != want {
-			t.Errorf("i=%d: Linkname: got %v, want %v", i, got, want)
-		}
-		if got, want := h2.Typeflag, g.h.Typeflag; got != want {
-			t.Logf("%#v %#v", g.h, fi.Sys())
-			t.Errorf("i=%d: Typeflag: got %q, want %q", i, got, want)
-		}
-		if got, want := h2.Mode, g.h.Mode; got != want {
-			t.Errorf("i=%d: Mode: got %o, want %o", i, got, want)
-		}
-		if got, want := fi.Mode(), g.fm; got != want {
-			t.Errorf("i=%d: fi.Mode: got %o, want %o", i, got, want)
-		}
-		if got, want := h2.AccessTime, g.h.AccessTime; got != want {
-			t.Errorf("i=%d: AccessTime: got %v, want %v", i, got, want)
-		}
-		if got, want := h2.ChangeTime, g.h.ChangeTime; got != want {
-			t.Errorf("i=%d: ChangeTime: got %v, want %v", i, got, want)
-		}
-		if got, want := h2.ModTime, g.h.ModTime; got != want {
-			t.Errorf("i=%d: ModTime: got %v, want %v", i, got, want)
-		}
-		if sysh, ok := fi.Sys().(*Header); !ok || sysh != g.h {
-			t.Errorf("i=%d: Sys didn't return original *Header", i)
-		}
-	}
-}

BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/gnu-multi-hdrs.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/gnu.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/hardlink.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/hdr-only.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue10968.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue11169.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/issue12435.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/neg-size.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/nil-uid.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax-multi-hdrs.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax-path-hdr.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/pax.tar


+ 0 - 1
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/small.txt

@@ -1 +0,0 @@
-Kilts

+ 0 - 1
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/small2.txt

@@ -1 +0,0 @@
-Google.com

BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/sparse-formats.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/star.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/ustar-file-reg.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/ustar.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/v7.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer-big-long.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer-big.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/writer.tar


BIN
vendor/github.com/Microsoft/go-winio/archive/tar/testdata/xattrs.tar


+ 0 - 444
vendor/github.com/Microsoft/go-winio/archive/tar/writer.go

@@ -1,444 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar
-
-// TODO(dsymonds):
-// - catch more errors (no first header, etc.)
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"io"
-	"path"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
-)
-
-var (
-	ErrWriteTooLong    = errors.New("archive/tar: write too long")
-	ErrFieldTooLong    = errors.New("archive/tar: header field too long")
-	ErrWriteAfterClose = errors.New("archive/tar: write after close")
-	errInvalidHeader   = errors.New("archive/tar: header field too long or contains invalid values")
-)
-
-// A Writer provides sequential writing of a tar archive in POSIX.1 format.
-// A tar archive consists of a sequence of files.
-// Call WriteHeader to begin a new file, and then call Write to supply that file's data,
-// writing at most hdr.Size bytes in total.
-type Writer struct {
-	w          io.Writer
-	err        error
-	nb         int64 // number of unwritten bytes for current file entry
-	pad        int64 // amount of padding to write after current file entry
-	closed     bool
-	usedBinary bool            // whether the binary numeric field extension was used
-	preferPax  bool            // use pax header instead of binary numeric header
-	hdrBuff    [blockSize]byte // buffer to use in writeHeader when writing a regular header
-	paxHdrBuff [blockSize]byte // buffer to use in writeHeader when writing a pax header
-}
-
-type formatter struct {
-	err error // Last error seen
-}
-
-// NewWriter creates a new Writer writing to w.
-func NewWriter(w io.Writer) *Writer { return &Writer{w: w, preferPax: true} }
-
-// Flush finishes writing the current file (optional).
-func (tw *Writer) Flush() error {
-	if tw.nb > 0 {
-		tw.err = fmt.Errorf("archive/tar: missed writing %d bytes", tw.nb)
-		return tw.err
-	}
-
-	n := tw.nb + tw.pad
-	for n > 0 && tw.err == nil {
-		nr := n
-		if nr > blockSize {
-			nr = blockSize
-		}
-		var nw int
-		nw, tw.err = tw.w.Write(zeroBlock[0:nr])
-		n -= int64(nw)
-	}
-	tw.nb = 0
-	tw.pad = 0
-	return tw.err
-}
-
-// Write s into b, terminating it with a NUL if there is room.
-func (f *formatter) formatString(b []byte, s string) {
-	if len(s) > len(b) {
-		f.err = ErrFieldTooLong
-		return
-	}
-	ascii := toASCII(s)
-	copy(b, ascii)
-	if len(ascii) < len(b) {
-		b[len(ascii)] = 0
-	}
-}
-
-// Encode x as an octal ASCII string and write it into b with leading zeros.
-func (f *formatter) formatOctal(b []byte, x int64) {
-	s := strconv.FormatInt(x, 8)
-	// leading zeros, but leave room for a NUL.
-	for len(s)+1 < len(b) {
-		s = "0" + s
-	}
-	f.formatString(b, s)
-}
-
-// fitsInBase256 reports whether x can be encoded into n bytes using base-256
-// encoding. Unlike octal encoding, base-256 encoding does not require that the
-// string ends with a NUL character. Thus, all n bytes are available for output.
-//
-// If operating in binary mode, this assumes strict GNU binary mode; which means
-// that the first byte can only be either 0x80 or 0xff. Thus, the first byte is
-// equivalent to the sign bit in two's complement form.
-func fitsInBase256(n int, x int64) bool {
-	var binBits = uint(n-1) * 8
-	return n >= 9 || (x >= -1<<binBits && x < 1<<binBits)
-}
-
-// Write x into b, as binary (GNUtar/star extension).
-func (f *formatter) formatNumeric(b []byte, x int64) {
-	if fitsInBase256(len(b), x) {
-		for i := len(b) - 1; i >= 0; i-- {
-			b[i] = byte(x)
-			x >>= 8
-		}
-		b[0] |= 0x80 // Highest bit indicates binary format
-		return
-	}
-
-	f.formatOctal(b, 0) // Last resort, just write zero
-	f.err = ErrFieldTooLong
-}
-
-var (
-	minTime = time.Unix(0, 0)
-	// There is room for 11 octal digits (33 bits) of mtime.
-	maxTime = minTime.Add((1<<33 - 1) * time.Second)
-)
-
-// WriteHeader writes hdr and prepares to accept the file's contents.
-// WriteHeader calls Flush if it is not the first header.
-// Calling after a Close will return ErrWriteAfterClose.
-func (tw *Writer) WriteHeader(hdr *Header) error {
-	return tw.writeHeader(hdr, true)
-}
-
-// WriteHeader writes hdr and prepares to accept the file's contents.
-// WriteHeader calls Flush if it is not the first header.
-// Calling after a Close will return ErrWriteAfterClose.
-// As this method is called internally by writePax header to allow it to
-// suppress writing the pax header.
-func (tw *Writer) writeHeader(hdr *Header, allowPax bool) error {
-	if tw.closed {
-		return ErrWriteAfterClose
-	}
-	if tw.err == nil {
-		tw.Flush()
-	}
-	if tw.err != nil {
-		return tw.err
-	}
-
-	// a map to hold pax header records, if any are needed
-	paxHeaders := make(map[string]string)
-
-	// TODO(shanemhansen): we might want to use PAX headers for
-	// subsecond time resolution, but for now let's just capture
-	// too long fields or non ascii characters
-
-	var f formatter
-	var header []byte
-
-	// We need to select which scratch buffer to use carefully,
-	// since this method is called recursively to write PAX headers.
-	// If allowPax is true, this is the non-recursive call, and we will use hdrBuff.
-	// If allowPax is false, we are being called by writePAXHeader, and hdrBuff is
-	// already being used by the non-recursive call, so we must use paxHdrBuff.
-	header = tw.hdrBuff[:]
-	if !allowPax {
-		header = tw.paxHdrBuff[:]
-	}
-	copy(header, zeroBlock)
-	s := slicer(header)
-
-	// Wrappers around formatter that automatically sets paxHeaders if the
-	// argument extends beyond the capacity of the input byte slice.
-	var formatString = func(b []byte, s string, paxKeyword string) {
-		needsPaxHeader := paxKeyword != paxNone && len(s) > len(b) || !isASCII(s)
-		if needsPaxHeader {
-			paxHeaders[paxKeyword] = s
-			return
-		}
-		f.formatString(b, s)
-	}
-	var formatNumeric = func(b []byte, x int64, paxKeyword string) {
-		// Try octal first.
-		s := strconv.FormatInt(x, 8)
-		if len(s) < len(b) {
-			f.formatOctal(b, x)
-			return
-		}
-
-		// If it is too long for octal, and PAX is preferred, use a PAX header.
-		if paxKeyword != paxNone && tw.preferPax {
-			f.formatOctal(b, 0)
-			s := strconv.FormatInt(x, 10)
-			paxHeaders[paxKeyword] = s
-			return
-		}
-
-		tw.usedBinary = true
-		f.formatNumeric(b, x)
-	}
-	var formatTime = func(b []byte, t time.Time, paxKeyword string) {
-		var unixTime int64
-		if !t.Before(minTime) && !t.After(maxTime) {
-			unixTime = t.Unix()
-		}
-		formatNumeric(b, unixTime, paxNone)
-
-		// Write a PAX header if the time didn't fit precisely.
-		if paxKeyword != "" && tw.preferPax && allowPax && (t.Nanosecond() != 0 || !t.Before(minTime) || !t.After(maxTime)) {
-			paxHeaders[paxKeyword] = formatPAXTime(t)
-		}
-	}
-
-	// keep a reference to the filename to allow to overwrite it later if we detect that we can use ustar longnames instead of pax
-	pathHeaderBytes := s.next(fileNameSize)
-
-	formatString(pathHeaderBytes, hdr.Name, paxPath)
-
-	f.formatOctal(s.next(8), hdr.Mode)               // 100:108
-	formatNumeric(s.next(8), int64(hdr.Uid), paxUid) // 108:116
-	formatNumeric(s.next(8), int64(hdr.Gid), paxGid) // 116:124
-	formatNumeric(s.next(12), hdr.Size, paxSize)     // 124:136
-	formatTime(s.next(12), hdr.ModTime, paxMtime)    // 136:148
-	s.next(8)                                        // chksum (148:156)
-	s.next(1)[0] = hdr.Typeflag                      // 156:157
-
-	formatString(s.next(100), hdr.Linkname, paxLinkpath)
-
-	copy(s.next(8), []byte("ustar\x0000"))          // 257:265
-	formatString(s.next(32), hdr.Uname, paxUname)   // 265:297
-	formatString(s.next(32), hdr.Gname, paxGname)   // 297:329
-	formatNumeric(s.next(8), hdr.Devmajor, paxNone) // 329:337
-	formatNumeric(s.next(8), hdr.Devminor, paxNone) // 337:345
-
-	// keep a reference to the prefix to allow to overwrite it later if we detect that we can use ustar longnames instead of pax
-	prefixHeaderBytes := s.next(155)
-	formatString(prefixHeaderBytes, "", paxNone) // 345:500  prefix
-
-	// Use the GNU magic instead of POSIX magic if we used any GNU extensions.
-	if tw.usedBinary {
-		copy(header[257:265], []byte("ustar  \x00"))
-	}
-
-	_, paxPathUsed := paxHeaders[paxPath]
-	// try to use a ustar header when only the name is too long
-	if !tw.preferPax && len(paxHeaders) == 1 && paxPathUsed {
-		prefix, suffix, ok := splitUSTARPath(hdr.Name)
-		if ok {
-			// Since we can encode in USTAR format, disable PAX header.
-			delete(paxHeaders, paxPath)
-
-			// Update the path fields
-			formatString(pathHeaderBytes, suffix, paxNone)
-			formatString(prefixHeaderBytes, prefix, paxNone)
-		}
-	}
-
-	// The chksum field is terminated by a NUL and a space.
-	// This is different from the other octal fields.
-	chksum, _ := checksum(header)
-	f.formatOctal(header[148:155], chksum) // Never fails
-	header[155] = ' '
-
-	// Check if there were any formatting errors.
-	if f.err != nil {
-		tw.err = f.err
-		return tw.err
-	}
-
-	if allowPax {
-		if !hdr.AccessTime.IsZero() {
-			paxHeaders[paxAtime] = formatPAXTime(hdr.AccessTime)
-		}
-		if !hdr.ChangeTime.IsZero() {
-			paxHeaders[paxCtime] = formatPAXTime(hdr.ChangeTime)
-		}
-		if !hdr.CreationTime.IsZero() {
-			paxHeaders[paxCreationTime] = formatPAXTime(hdr.CreationTime)
-		}
-		for k, v := range hdr.Xattrs {
-			paxHeaders[paxXattr+k] = v
-		}
-		for k, v := range hdr.Winheaders {
-			paxHeaders[paxWindows+k] = v
-		}
-	}
-
-	if len(paxHeaders) > 0 {
-		if !allowPax {
-			return errInvalidHeader
-		}
-		if err := tw.writePAXHeader(hdr, paxHeaders); err != nil {
-			return err
-		}
-	}
-	tw.nb = int64(hdr.Size)
-	tw.pad = (blockSize - (tw.nb % blockSize)) % blockSize
-
-	_, tw.err = tw.w.Write(header)
-	return tw.err
-}
-
-func formatPAXTime(t time.Time) string {
-	sec := t.Unix()
-	usec := t.Nanosecond()
-	s := strconv.FormatInt(sec, 10)
-	if usec != 0 {
-		s = fmt.Sprintf("%s.%09d", s, usec)
-	}
-	return s
-}
-
-// splitUSTARPath splits a path according to USTAR prefix and suffix rules.
-// If the path is not splittable, then it will return ("", "", false).
-func splitUSTARPath(name string) (prefix, suffix string, ok bool) {
-	length := len(name)
-	if length <= fileNameSize || !isASCII(name) {
-		return "", "", false
-	} else if length > fileNamePrefixSize+1 {
-		length = fileNamePrefixSize + 1
-	} else if name[length-1] == '/' {
-		length--
-	}
-
-	i := strings.LastIndex(name[:length], "/")
-	nlen := len(name) - i - 1 // nlen is length of suffix
-	plen := i                 // plen is length of prefix
-	if i <= 0 || nlen > fileNameSize || nlen == 0 || plen > fileNamePrefixSize {
-		return "", "", false
-	}
-	return name[:i], name[i+1:], true
-}
-
-// writePaxHeader writes an extended pax header to the
-// archive.
-func (tw *Writer) writePAXHeader(hdr *Header, paxHeaders map[string]string) error {
-	// Prepare extended header
-	ext := new(Header)
-	ext.Typeflag = TypeXHeader
-	// Setting ModTime is required for reader parsing to
-	// succeed, and seems harmless enough.
-	ext.ModTime = hdr.ModTime
-	// The spec asks that we namespace our pseudo files
-	// with the current pid.  However, this results in differing outputs
-	// for identical inputs.  As such, the constant 0 is now used instead.
-	// golang.org/issue/12358
-	dir, file := path.Split(hdr.Name)
-	fullName := path.Join(dir, "PaxHeaders.0", file)
-
-	ascii := toASCII(fullName)
-	if len(ascii) > 100 {
-		ascii = ascii[:100]
-	}
-	ext.Name = ascii
-	// Construct the body
-	var buf bytes.Buffer
-
-	// Keys are sorted before writing to body to allow deterministic output.
-	var keys []string
-	for k := range paxHeaders {
-		keys = append(keys, k)
-	}
-	sort.Strings(keys)
-
-	for _, k := range keys {
-		fmt.Fprint(&buf, formatPAXRecord(k, paxHeaders[k]))
-	}
-
-	ext.Size = int64(len(buf.Bytes()))
-	if err := tw.writeHeader(ext, false); err != nil {
-		return err
-	}
-	if _, err := tw.Write(buf.Bytes()); err != nil {
-		return err
-	}
-	if err := tw.Flush(); err != nil {
-		return err
-	}
-	return nil
-}
-
-// formatPAXRecord formats a single PAX record, prefixing it with the
-// appropriate length.
-func formatPAXRecord(k, v string) string {
-	const padding = 3 // Extra padding for ' ', '=', and '\n'
-	size := len(k) + len(v) + padding
-	size += len(strconv.Itoa(size))
-	record := fmt.Sprintf("%d %s=%s\n", size, k, v)
-
-	// Final adjustment if adding size field increased the record size.
-	if len(record) != size {
-		size = len(record)
-		record = fmt.Sprintf("%d %s=%s\n", size, k, v)
-	}
-	return record
-}
-
-// Write writes to the current entry in the tar archive.
-// Write returns the error ErrWriteTooLong if more than
-// hdr.Size bytes are written after WriteHeader.
-func (tw *Writer) Write(b []byte) (n int, err error) {
-	if tw.closed {
-		err = ErrWriteAfterClose
-		return
-	}
-	overwrite := false
-	if int64(len(b)) > tw.nb {
-		b = b[0:tw.nb]
-		overwrite = true
-	}
-	n, err = tw.w.Write(b)
-	tw.nb -= int64(n)
-	if err == nil && overwrite {
-		err = ErrWriteTooLong
-		return
-	}
-	tw.err = err
-	return
-}
-
-// Close closes the tar archive, flushing any unwritten
-// data to the underlying writer.
-func (tw *Writer) Close() error {
-	if tw.err != nil || tw.closed {
-		return tw.err
-	}
-	tw.Flush()
-	tw.closed = true
-	if tw.err != nil {
-		return tw.err
-	}
-
-	// trailer: two zero blocks
-	for i := 0; i < 2; i++ {
-		_, tw.err = tw.w.Write(zeroBlock)
-		if tw.err != nil {
-			break
-		}
-	}
-	return tw.err
-}

+ 0 - 739
vendor/github.com/Microsoft/go-winio/archive/tar/writer_test.go

@@ -1,739 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tar
-
-import (
-	"bytes"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"math"
-	"os"
-	"reflect"
-	"sort"
-	"strings"
-	"testing"
-	"testing/iotest"
-	"time"
-)
-
-type writerTestEntry struct {
-	header   *Header
-	contents string
-}
-
-type writerTest struct {
-	file    string // filename of expected output
-	entries []*writerTestEntry
-}
-
-var writerTests = []*writerTest{
-	// The writer test file was produced with this command:
-	// tar (GNU tar) 1.26
-	//   ln -s small.txt link.txt
-	//   tar -b 1 --format=ustar -c -f writer.tar small.txt small2.txt link.txt
-	{
-		file: "testdata/writer.tar",
-		entries: []*writerTestEntry{
-			{
-				header: &Header{
-					Name:     "small.txt",
-					Mode:     0640,
-					Uid:      73025,
-					Gid:      5000,
-					Size:     5,
-					ModTime:  time.Unix(1246508266, 0),
-					Typeflag: '0',
-					Uname:    "dsymonds",
-					Gname:    "eng",
-				},
-				contents: "Kilts",
-			},
-			{
-				header: &Header{
-					Name:     "small2.txt",
-					Mode:     0640,
-					Uid:      73025,
-					Gid:      5000,
-					Size:     11,
-					ModTime:  time.Unix(1245217492, 0),
-					Typeflag: '0',
-					Uname:    "dsymonds",
-					Gname:    "eng",
-				},
-				contents: "Google.com\n",
-			},
-			{
-				header: &Header{
-					Name:     "link.txt",
-					Mode:     0777,
-					Uid:      1000,
-					Gid:      1000,
-					Size:     0,
-					ModTime:  time.Unix(1314603082, 0),
-					Typeflag: '2',
-					Linkname: "small.txt",
-					Uname:    "strings",
-					Gname:    "strings",
-				},
-				// no contents
-			},
-		},
-	},
-	// The truncated test file was produced using these commands:
-	//   dd if=/dev/zero bs=1048576 count=16384 > /tmp/16gig.txt
-	//   tar -b 1 -c -f- /tmp/16gig.txt | dd bs=512 count=8 > writer-big.tar
-	{
-		file: "testdata/writer-big.tar",
-		entries: []*writerTestEntry{
-			{
-				header: &Header{
-					Name:     "tmp/16gig.txt",
-					Mode:     0640,
-					Uid:      73025,
-					Gid:      5000,
-					Size:     16 << 30,
-					ModTime:  time.Unix(1254699560, 0),
-					Typeflag: '0',
-					Uname:    "dsymonds",
-					Gname:    "eng",
-				},
-				// fake contents
-				contents: strings.Repeat("\x00", 4<<10),
-			},
-		},
-	},
-	// The truncated test file was produced using these commands:
-	//   dd if=/dev/zero bs=1048576 count=16384 > (longname/)*15 /16gig.txt
-	//   tar -b 1 -c -f- (longname/)*15 /16gig.txt | dd bs=512 count=8 > writer-big-long.tar
-	{
-		file: "testdata/writer-big-long.tar",
-		entries: []*writerTestEntry{
-			{
-				header: &Header{
-					Name:     strings.Repeat("longname/", 15) + "16gig.txt",
-					Mode:     0644,
-					Uid:      1000,
-					Gid:      1000,
-					Size:     16 << 30,
-					ModTime:  time.Unix(1399583047, 0),
-					Typeflag: '0',
-					Uname:    "guillaume",
-					Gname:    "guillaume",
-				},
-				// fake contents
-				contents: strings.Repeat("\x00", 4<<10),
-			},
-		},
-	},
-	// This file was produced using gnu tar 1.17
-	// gnutar  -b 4 --format=ustar (longname/)*15 + file.txt
-	{
-		file: "testdata/ustar.tar",
-		entries: []*writerTestEntry{
-			{
-				header: &Header{
-					Name:     strings.Repeat("longname/", 15) + "file.txt",
-					Mode:     0644,
-					Uid:      0765,
-					Gid:      024,
-					Size:     06,
-					ModTime:  time.Unix(1360135598, 0),
-					Typeflag: '0',
-					Uname:    "shane",
-					Gname:    "staff",
-				},
-				contents: "hello\n",
-			},
-		},
-	},
-	// This file was produced using gnu tar 1.26
-	// echo "Slartibartfast" > file.txt
-	// ln file.txt hard.txt
-	// tar -b 1 --format=ustar -c -f hardlink.tar file.txt hard.txt
-	{
-		file: "testdata/hardlink.tar",
-		entries: []*writerTestEntry{
-			{
-				header: &Header{
-					Name:     "file.txt",
-					Mode:     0644,
-					Uid:      1000,
-					Gid:      100,
-					Size:     15,
-					ModTime:  time.Unix(1425484303, 0),
-					Typeflag: '0',
-					Uname:    "vbatts",
-					Gname:    "users",
-				},
-				contents: "Slartibartfast\n",
-			},
-			{
-				header: &Header{
-					Name:     "hard.txt",
-					Mode:     0644,
-					Uid:      1000,
-					Gid:      100,
-					Size:     0,
-					ModTime:  time.Unix(1425484303, 0),
-					Typeflag: '1',
-					Linkname: "file.txt",
-					Uname:    "vbatts",
-					Gname:    "users",
-				},
-				// no contents
-			},
-		},
-	},
-}
-
-// Render byte array in a two-character hexadecimal string, spaced for easy visual inspection.
-func bytestr(offset int, b []byte) string {
-	const rowLen = 32
-	s := fmt.Sprintf("%04x ", offset)
-	for _, ch := range b {
-		switch {
-		case '0' <= ch && ch <= '9', 'A' <= ch && ch <= 'Z', 'a' <= ch && ch <= 'z':
-			s += fmt.Sprintf("  %c", ch)
-		default:
-			s += fmt.Sprintf(" %02x", ch)
-		}
-	}
-	return s
-}
-
-// Render a pseudo-diff between two blocks of bytes.
-func bytediff(a []byte, b []byte) string {
-	const rowLen = 32
-	s := fmt.Sprintf("(%d bytes vs. %d bytes)\n", len(a), len(b))
-	for offset := 0; len(a)+len(b) > 0; offset += rowLen {
-		na, nb := rowLen, rowLen
-		if na > len(a) {
-			na = len(a)
-		}
-		if nb > len(b) {
-			nb = len(b)
-		}
-		sa := bytestr(offset, a[0:na])
-		sb := bytestr(offset, b[0:nb])
-		if sa != sb {
-			s += fmt.Sprintf("-%v\n+%v\n", sa, sb)
-		}
-		a = a[na:]
-		b = b[nb:]
-	}
-	return s
-}
-
-func TestWriter(t *testing.T) {
-testLoop:
-	for i, test := range writerTests {
-		expected, err := ioutil.ReadFile(test.file)
-		if err != nil {
-			t.Errorf("test %d: Unexpected error: %v", i, err)
-			continue
-		}
-
-		buf := new(bytes.Buffer)
-		tw := NewWriter(iotest.TruncateWriter(buf, 4<<10)) // only catch the first 4 KB
-		big := false
-		for j, entry := range test.entries {
-			big = big || entry.header.Size > 1<<10
-			if err := tw.WriteHeader(entry.header); err != nil {
-				t.Errorf("test %d, entry %d: Failed writing header: %v", i, j, err)
-				continue testLoop
-			}
-			if _, err := io.WriteString(tw, entry.contents); err != nil {
-				t.Errorf("test %d, entry %d: Failed writing contents: %v", i, j, err)
-				continue testLoop
-			}
-		}
-		// Only interested in Close failures for the small tests.
-		if err := tw.Close(); err != nil && !big {
-			t.Errorf("test %d: Failed closing archive: %v", i, err)
-			continue testLoop
-		}
-
-		actual := buf.Bytes()
-		if !bytes.Equal(expected, actual) {
-			t.Errorf("test %d: Incorrect result: (-=expected, +=actual)\n%v",
-				i, bytediff(expected, actual))
-		}
-		if testing.Short() { // The second test is expensive.
-			break
-		}
-	}
-}
-
-func TestPax(t *testing.T) {
-	// Create an archive with a large name
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	hdr, err := FileInfoHeader(fileinfo, "")
-	if err != nil {
-		t.Fatalf("os.Stat: %v", err)
-	}
-	// Force a PAX long name to be written
-	longName := strings.Repeat("ab", 100)
-	contents := strings.Repeat(" ", int(hdr.Size))
-	hdr.Name = longName
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if _, err = writer.Write([]byte(contents)); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Simple test to make sure PAX extensions are in effect
-	if !bytes.Contains(buf.Bytes(), []byte("PaxHeaders.0")) {
-		t.Fatal("Expected at least one PAX header to be written.")
-	}
-	// Test that we can get a long name back out of the archive.
-	reader := NewReader(&buf)
-	hdr, err = reader.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-	if hdr.Name != longName {
-		t.Fatal("Couldn't recover long file name")
-	}
-}
-
-func TestPaxSymlink(t *testing.T) {
-	// Create an archive with a large linkname
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	hdr, err := FileInfoHeader(fileinfo, "")
-	hdr.Typeflag = TypeSymlink
-	if err != nil {
-		t.Fatalf("os.Stat:1 %v", err)
-	}
-	// Force a PAX long linkname to be written
-	longLinkname := strings.Repeat("1234567890/1234567890", 10)
-	hdr.Linkname = longLinkname
-
-	hdr.Size = 0
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Simple test to make sure PAX extensions are in effect
-	if !bytes.Contains(buf.Bytes(), []byte("PaxHeaders.0")) {
-		t.Fatal("Expected at least one PAX header to be written.")
-	}
-	// Test that we can get a long name back out of the archive.
-	reader := NewReader(&buf)
-	hdr, err = reader.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-	if hdr.Linkname != longLinkname {
-		t.Fatal("Couldn't recover long link name")
-	}
-}
-
-func TestPaxNonAscii(t *testing.T) {
-	// Create an archive with non ascii. These should trigger a pax header
-	// because pax headers have a defined utf-8 encoding.
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	hdr, err := FileInfoHeader(fileinfo, "")
-	if err != nil {
-		t.Fatalf("os.Stat:1 %v", err)
-	}
-
-	// some sample data
-	chineseFilename := "文件名"
-	chineseGroupname := "組"
-	chineseUsername := "用戶名"
-
-	hdr.Name = chineseFilename
-	hdr.Gname = chineseGroupname
-	hdr.Uname = chineseUsername
-
-	contents := strings.Repeat(" ", int(hdr.Size))
-
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if _, err = writer.Write([]byte(contents)); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Simple test to make sure PAX extensions are in effect
-	if !bytes.Contains(buf.Bytes(), []byte("PaxHeaders.0")) {
-		t.Fatal("Expected at least one PAX header to be written.")
-	}
-	// Test that we can get a long name back out of the archive.
-	reader := NewReader(&buf)
-	hdr, err = reader.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-	if hdr.Name != chineseFilename {
-		t.Fatal("Couldn't recover unicode name")
-	}
-	if hdr.Gname != chineseGroupname {
-		t.Fatal("Couldn't recover unicode group")
-	}
-	if hdr.Uname != chineseUsername {
-		t.Fatal("Couldn't recover unicode user")
-	}
-}
-
-func TestPaxXattrs(t *testing.T) {
-	xattrs := map[string]string{
-		"user.key": "value",
-	}
-
-	// Create an archive with an xattr
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	hdr, err := FileInfoHeader(fileinfo, "")
-	if err != nil {
-		t.Fatalf("os.Stat: %v", err)
-	}
-	contents := "Kilts"
-	hdr.Xattrs = xattrs
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if _, err = writer.Write([]byte(contents)); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Test that we can get the xattrs back out of the archive.
-	reader := NewReader(&buf)
-	hdr, err = reader.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !reflect.DeepEqual(hdr.Xattrs, xattrs) {
-		t.Fatalf("xattrs did not survive round trip: got %+v, want %+v",
-			hdr.Xattrs, xattrs)
-	}
-}
-
-func TestPaxHeadersSorted(t *testing.T) {
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	hdr, err := FileInfoHeader(fileinfo, "")
-	if err != nil {
-		t.Fatalf("os.Stat: %v", err)
-	}
-	contents := strings.Repeat(" ", int(hdr.Size))
-
-	hdr.Xattrs = map[string]string{
-		"foo": "foo",
-		"bar": "bar",
-		"baz": "baz",
-		"qux": "qux",
-	}
-
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if _, err = writer.Write([]byte(contents)); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Simple test to make sure PAX extensions are in effect
-	if !bytes.Contains(buf.Bytes(), []byte("PaxHeaders.0")) {
-		t.Fatal("Expected at least one PAX header to be written.")
-	}
-
-	// xattr bar should always appear before others
-	indices := []int{
-		bytes.Index(buf.Bytes(), []byte("bar=bar")),
-		bytes.Index(buf.Bytes(), []byte("baz=baz")),
-		bytes.Index(buf.Bytes(), []byte("foo=foo")),
-		bytes.Index(buf.Bytes(), []byte("qux=qux")),
-	}
-	if !sort.IntsAreSorted(indices) {
-		t.Fatal("PAX headers are not sorted")
-	}
-}
-
-func TestUSTARLongName(t *testing.T) {
-	// Create an archive with a path that failed to split with USTAR extension in previous versions.
-	fileinfo, err := os.Stat("testdata/small.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	hdr, err := FileInfoHeader(fileinfo, "")
-	hdr.Typeflag = TypeDir
-	if err != nil {
-		t.Fatalf("os.Stat:1 %v", err)
-	}
-	// Force a PAX long name to be written. The name was taken from a practical example
-	// that fails and replaced ever char through numbers to anonymize the sample.
-	longName := "/0000_0000000/00000-000000000/0000_0000000/00000-0000000000000/0000_0000000/00000-0000000-00000000/0000_0000000/00000000/0000_0000000/000/0000_0000000/00000000v00/0000_0000000/000000/0000_0000000/0000000/0000_0000000/00000y-00/0000/0000/00000000/0x000000/"
-	hdr.Name = longName
-
-	hdr.Size = 0
-	var buf bytes.Buffer
-	writer := NewWriter(&buf)
-	if err := writer.WriteHeader(hdr); err != nil {
-		t.Fatal(err)
-	}
-	if err := writer.Close(); err != nil {
-		t.Fatal(err)
-	}
-	// Test that we can get a long name back out of the archive.
-	reader := NewReader(&buf)
-	hdr, err = reader.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-	if hdr.Name != longName {
-		t.Fatal("Couldn't recover long name")
-	}
-}
-
-func TestValidTypeflagWithPAXHeader(t *testing.T) {
-	var buffer bytes.Buffer
-	tw := NewWriter(&buffer)
-
-	fileName := strings.Repeat("ab", 100)
-
-	hdr := &Header{
-		Name:     fileName,
-		Size:     4,
-		Typeflag: 0,
-	}
-	if err := tw.WriteHeader(hdr); err != nil {
-		t.Fatalf("Failed to write header: %s", err)
-	}
-	if _, err := tw.Write([]byte("fooo")); err != nil {
-		t.Fatalf("Failed to write the file's data: %s", err)
-	}
-	tw.Close()
-
-	tr := NewReader(&buffer)
-
-	for {
-		header, err := tr.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatalf("Failed to read header: %s", err)
-		}
-		if header.Typeflag != 0 {
-			t.Fatalf("Typeflag should've been 0, found %d", header.Typeflag)
-		}
-	}
-}
-
-func TestWriteAfterClose(t *testing.T) {
-	var buffer bytes.Buffer
-	tw := NewWriter(&buffer)
-
-	hdr := &Header{
-		Name: "small.txt",
-		Size: 5,
-	}
-	if err := tw.WriteHeader(hdr); err != nil {
-		t.Fatalf("Failed to write header: %s", err)
-	}
-	tw.Close()
-	if _, err := tw.Write([]byte("Kilts")); err != ErrWriteAfterClose {
-		t.Fatalf("Write: got %v; want ErrWriteAfterClose", err)
-	}
-}
-
-func TestSplitUSTARPath(t *testing.T) {
-	var sr = strings.Repeat
-
-	var vectors = []struct {
-		input  string // Input path
-		prefix string // Expected output prefix
-		suffix string // Expected output suffix
-		ok     bool   // Split success?
-	}{
-		{"", "", "", false},
-		{"abc", "", "", false},
-		{"用戶名", "", "", false},
-		{sr("a", fileNameSize), "", "", false},
-		{sr("a", fileNameSize) + "/", "", "", false},
-		{sr("a", fileNameSize) + "/a", sr("a", fileNameSize), "a", true},
-		{sr("a", fileNamePrefixSize) + "/", "", "", false},
-		{sr("a", fileNamePrefixSize) + "/a", sr("a", fileNamePrefixSize), "a", true},
-		{sr("a", fileNameSize+1), "", "", false},
-		{sr("/", fileNameSize+1), sr("/", fileNameSize-1), "/", true},
-		{sr("a", fileNamePrefixSize) + "/" + sr("b", fileNameSize),
-			sr("a", fileNamePrefixSize), sr("b", fileNameSize), true},
-		{sr("a", fileNamePrefixSize) + "//" + sr("b", fileNameSize), "", "", false},
-		{sr("a/", fileNameSize), sr("a/", 77) + "a", sr("a/", 22), true},
-	}
-
-	for _, v := range vectors {
-		prefix, suffix, ok := splitUSTARPath(v.input)
-		if prefix != v.prefix || suffix != v.suffix || ok != v.ok {
-			t.Errorf("splitUSTARPath(%q):\ngot  (%q, %q, %v)\nwant (%q, %q, %v)",
-				v.input, prefix, suffix, ok, v.prefix, v.suffix, v.ok)
-		}
-	}
-}
-
-func TestFormatPAXRecord(t *testing.T) {
-	var medName = strings.Repeat("CD", 50)
-	var longName = strings.Repeat("AB", 100)
-
-	var vectors = []struct {
-		inputKey string
-		inputVal string
-		output   string
-	}{
-		{"k", "v", "6 k=v\n"},
-		{"path", "/etc/hosts", "19 path=/etc/hosts\n"},
-		{"path", longName, "210 path=" + longName + "\n"},
-		{"path", medName, "110 path=" + medName + "\n"},
-		{"foo", "ba", "9 foo=ba\n"},
-		{"foo", "bar", "11 foo=bar\n"},
-		{"foo", "b=\nar=\n==\x00", "18 foo=b=\nar=\n==\x00\n"},
-		{"foo", "hello9 foo=ba\nworld", "27 foo=hello9 foo=ba\nworld\n"},
-		{"☺☻☹", "日a本b語ç", "27 ☺☻☹=日a本b語ç\n"},
-		{"\x00hello", "\x00world", "17 \x00hello=\x00world\n"},
-	}
-
-	for _, v := range vectors {
-		output := formatPAXRecord(v.inputKey, v.inputVal)
-		if output != v.output {
-			t.Errorf("formatPAXRecord(%q, %q): got %q, want %q",
-				v.inputKey, v.inputVal, output, v.output)
-		}
-	}
-}
-
-func TestFitsInBase256(t *testing.T) {
-	var vectors = []struct {
-		input int64
-		width int
-		ok    bool
-	}{
-		{+1, 8, true},
-		{0, 8, true},
-		{-1, 8, true},
-		{1 << 56, 8, false},
-		{(1 << 56) - 1, 8, true},
-		{-1 << 56, 8, true},
-		{(-1 << 56) - 1, 8, false},
-		{121654, 8, true},
-		{-9849849, 8, true},
-		{math.MaxInt64, 9, true},
-		{0, 9, true},
-		{math.MinInt64, 9, true},
-		{math.MaxInt64, 12, true},
-		{0, 12, true},
-		{math.MinInt64, 12, true},
-	}
-
-	for _, v := range vectors {
-		ok := fitsInBase256(v.width, v.input)
-		if ok != v.ok {
-			t.Errorf("checkNumeric(%d, %d): got %v, want %v", v.input, v.width, ok, v.ok)
-		}
-	}
-}
-
-func TestFormatNumeric(t *testing.T) {
-	var vectors = []struct {
-		input  int64
-		output string
-		ok     bool
-	}{
-		// Test base-256 (binary) encoded values.
-		{-1, "\xff", true},
-		{-1, "\xff\xff", true},
-		{-1, "\xff\xff\xff", true},
-		{(1 << 0), "0", false},
-		{(1 << 8) - 1, "\x80\xff", true},
-		{(1 << 8), "0\x00", false},
-		{(1 << 16) - 1, "\x80\xff\xff", true},
-		{(1 << 16), "00\x00", false},
-		{-1 * (1 << 0), "\xff", true},
-		{-1*(1<<0) - 1, "0", false},
-		{-1 * (1 << 8), "\xff\x00", true},
-		{-1*(1<<8) - 1, "0\x00", false},
-		{-1 * (1 << 16), "\xff\x00\x00", true},
-		{-1*(1<<16) - 1, "00\x00", false},
-		{537795476381659745, "0000000\x00", false},
-		{537795476381659745, "\x80\x00\x00\x00\x07\x76\xa2\x22\xeb\x8a\x72\x61", true},
-		{-615126028225187231, "0000000\x00", false},
-		{-615126028225187231, "\xff\xff\xff\xff\xf7\x76\xa2\x22\xeb\x8a\x72\x61", true},
-		{math.MaxInt64, "0000000\x00", false},
-		{math.MaxInt64, "\x80\x00\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff", true},
-		{math.MinInt64, "0000000\x00", false},
-		{math.MinInt64, "\xff\xff\xff\xff\x80\x00\x00\x00\x00\x00\x00\x00", true},
-		{math.MaxInt64, "\x80\x7f\xff\xff\xff\xff\xff\xff\xff", true},
-		{math.MinInt64, "\xff\x80\x00\x00\x00\x00\x00\x00\x00", true},
-	}
-
-	for _, v := range vectors {
-		var f formatter
-		output := make([]byte, len(v.output))
-		f.formatNumeric(output, v.input)
-		ok := (f.err == nil)
-		if ok != v.ok {
-			if v.ok {
-				t.Errorf("formatNumeric(%d): got formatting failure, want success", v.input)
-			} else {
-				t.Errorf("formatNumeric(%d): got formatting success, want failure", v.input)
-			}
-		}
-		if string(output) != v.output {
-			t.Errorf("formatNumeric(%d): got %q, want %q", v.input, output, v.output)
-		}
-	}
-}
-
-func TestFormatPAXTime(t *testing.T) {
-	t1 := time.Date(2000, 1, 1, 11, 0, 0, 0, time.UTC)
-	t2 := time.Date(2000, 1, 1, 11, 0, 0, 100, time.UTC)
-	t3 := time.Date(1960, 1, 1, 11, 0, 0, 0, time.UTC)
-	t4 := time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)
-	verify := func(time time.Time, s string) {
-		p := formatPAXTime(time)
-		if p != s {
-			t.Errorf("for %v, expected %s, got %s", time, s, p)
-		}
-	}
-	verify(t1, "946724400")
-	verify(t2, "946724400.000000100")
-	verify(t3, "-315579600")
-	verify(t4, "0")
-}

+ 0 - 255
vendor/github.com/Microsoft/go-winio/backup_test.go

@@ -1,255 +0,0 @@
-package winio
-
-import (
-	"io"
-	"io/ioutil"
-	"os"
-	"syscall"
-	"testing"
-)
-
-var testFileName string
-
-func TestMain(m *testing.M) {
-	f, err := ioutil.TempFile("", "tmp")
-	if err != nil {
-		panic(err)
-	}
-	testFileName = f.Name()
-	f.Close()
-	defer os.Remove(testFileName)
-	os.Exit(m.Run())
-}
-
-func makeTestFile(makeADS bool) error {
-	os.Remove(testFileName)
-	f, err := os.Create(testFileName)
-	if err != nil {
-		return err
-	}
-	defer f.Close()
-	_, err = f.Write([]byte("testing 1 2 3\n"))
-	if err != nil {
-		return err
-	}
-	if makeADS {
-		a, err := os.Create(testFileName + ":ads.txt")
-		if err != nil {
-			return err
-		}
-		defer a.Close()
-		_, err = a.Write([]byte("alternate data stream\n"))
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func TestBackupRead(t *testing.T) {
-	err := makeTestFile(true)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	f, err := os.Open(testFileName)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer f.Close()
-	r := NewBackupFileReader(f, false)
-	defer r.Close()
-	b, err := ioutil.ReadAll(r)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if len(b) == 0 {
-		t.Fatal("no data")
-	}
-}
-
-func TestBackupStreamRead(t *testing.T) {
-	err := makeTestFile(true)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	f, err := os.Open(testFileName)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer f.Close()
-	r := NewBackupFileReader(f, false)
-	defer r.Close()
-
-	br := NewBackupStreamReader(r)
-	gotData := false
-	gotAltData := false
-	for {
-		hdr, err := br.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		switch hdr.Id {
-		case BackupData:
-			if gotData {
-				t.Fatal("duplicate data")
-			}
-			if hdr.Name != "" {
-				t.Fatalf("unexpected name %s", hdr.Name)
-			}
-			b, err := ioutil.ReadAll(br)
-			if err != nil {
-				t.Fatal(err)
-			}
-			if string(b) != "testing 1 2 3\n" {
-				t.Fatalf("incorrect data %v", b)
-			}
-			gotData = true
-		case BackupAlternateData:
-			if gotAltData {
-				t.Fatal("duplicate alt data")
-			}
-			if hdr.Name != ":ads.txt:$DATA" {
-				t.Fatalf("incorrect name %s", hdr.Name)
-			}
-			b, err := ioutil.ReadAll(br)
-			if err != nil {
-				t.Fatal(err)
-			}
-			if string(b) != "alternate data stream\n" {
-				t.Fatalf("incorrect data %v", b)
-			}
-			gotAltData = true
-		default:
-			t.Fatalf("unknown stream ID %d", hdr.Id)
-		}
-	}
-	if !gotData || !gotAltData {
-		t.Fatal("missing stream")
-	}
-}
-
-func TestBackupStreamWrite(t *testing.T) {
-	f, err := os.Create(testFileName)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer f.Close()
-	w := NewBackupFileWriter(f, false)
-	defer w.Close()
-
-	data := "testing 1 2 3\n"
-	altData := "alternate stream\n"
-
-	br := NewBackupStreamWriter(w)
-	err = br.WriteHeader(&BackupHeader{Id: BackupData, Size: int64(len(data))})
-	if err != nil {
-		t.Fatal(err)
-	}
-	n, err := br.Write([]byte(data))
-	if err != nil {
-		t.Fatal(err)
-	}
-	if n != len(data) {
-		t.Fatal("short write")
-	}
-
-	err = br.WriteHeader(&BackupHeader{Id: BackupAlternateData, Size: int64(len(altData)), Name: ":ads.txt:$DATA"})
-	if err != nil {
-		t.Fatal(err)
-	}
-	n, err = br.Write([]byte(altData))
-	if err != nil {
-		t.Fatal(err)
-	}
-	if n != len(altData) {
-		t.Fatal("short write")
-	}
-
-	f.Close()
-
-	b, err := ioutil.ReadFile(testFileName)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if string(b) != data {
-		t.Fatalf("wrong data %v", b)
-	}
-
-	b, err = ioutil.ReadFile(testFileName + ":ads.txt")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if string(b) != altData {
-		t.Fatalf("wrong data %v", b)
-	}
-}
-
-func makeSparseFile() error {
-	os.Remove(testFileName)
-	f, err := os.Create(testFileName)
-	if err != nil {
-		return err
-	}
-	defer f.Close()
-
-	const (
-		FSCTL_SET_SPARSE    = 0x000900c4
-		FSCTL_SET_ZERO_DATA = 0x000980c8
-	)
-
-	err = syscall.DeviceIoControl(syscall.Handle(f.Fd()), FSCTL_SET_SPARSE, nil, 0, nil, 0, nil, nil)
-	if err != nil {
-		return err
-	}
-
-	_, err = f.Write([]byte("testing 1 2 3\n"))
-	if err != nil {
-		return err
-	}
-
-	_, err = f.Seek(1000000, 0)
-	if err != nil {
-		return err
-	}
-
-	_, err = f.Write([]byte("more data later\n"))
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func TestBackupSparseFile(t *testing.T) {
-	err := makeSparseFile()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	f, err := os.Open(testFileName)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer f.Close()
-	r := NewBackupFileReader(f, false)
-	defer r.Close()
-
-	br := NewBackupStreamReader(r)
-	for {
-		hdr, err := br.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		t.Log(hdr)
-	}
-}

+ 0 - 4
vendor/github.com/Microsoft/go-winio/backuptar/noop.go

@@ -1,4 +0,0 @@
-// +build !windows
-// This file only exists to allow go get on non-Windows platforms.
-
-package backuptar

+ 0 - 439
vendor/github.com/Microsoft/go-winio/backuptar/tar.go

@@ -1,439 +0,0 @@
-// +build windows
-
-package backuptar
-
-import (
-	"encoding/base64"
-	"errors"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"path/filepath"
-	"strconv"
-	"strings"
-	"syscall"
-	"time"
-
-	"github.com/Microsoft/go-winio"
-	"github.com/Microsoft/go-winio/archive/tar" // until archive/tar supports pax extensions in its interface
-)
-
-const (
-	c_ISUID  = 04000   // Set uid
-	c_ISGID  = 02000   // Set gid
-	c_ISVTX  = 01000   // Save text (sticky bit)
-	c_ISDIR  = 040000  // Directory
-	c_ISFIFO = 010000  // FIFO
-	c_ISREG  = 0100000 // Regular file
-	c_ISLNK  = 0120000 // Symbolic link
-	c_ISBLK  = 060000  // Block special file
-	c_ISCHR  = 020000  // Character special file
-	c_ISSOCK = 0140000 // Socket
-)
-
-const (
-	hdrFileAttributes        = "fileattr"
-	hdrSecurityDescriptor    = "sd"
-	hdrRawSecurityDescriptor = "rawsd"
-	hdrMountPoint            = "mountpoint"
-	hdrEaPrefix              = "xattr."
-)
-
-func writeZeroes(w io.Writer, count int64) error {
-	buf := make([]byte, 8192)
-	c := len(buf)
-	for i := int64(0); i < count; i += int64(c) {
-		if int64(c) > count-i {
-			c = int(count - i)
-		}
-		_, err := w.Write(buf[:c])
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func copySparse(t *tar.Writer, br *winio.BackupStreamReader) error {
-	curOffset := int64(0)
-	for {
-		bhdr, err := br.Next()
-		if err == io.EOF {
-			err = io.ErrUnexpectedEOF
-		}
-		if err != nil {
-			return err
-		}
-		if bhdr.Id != winio.BackupSparseBlock {
-			return fmt.Errorf("unexpected stream %d", bhdr.Id)
-		}
-
-		// archive/tar does not support writing sparse files
-		// so just write zeroes to catch up to the current offset.
-		err = writeZeroes(t, bhdr.Offset-curOffset)
-		if bhdr.Size == 0 {
-			break
-		}
-		n, err := io.Copy(t, br)
-		if err != nil {
-			return err
-		}
-		curOffset = bhdr.Offset + n
-	}
-	return nil
-}
-
-// BasicInfoHeader creates a tar header from basic file information.
-func BasicInfoHeader(name string, size int64, fileInfo *winio.FileBasicInfo) *tar.Header {
-	hdr := &tar.Header{
-		Name:         filepath.ToSlash(name),
-		Size:         size,
-		Typeflag:     tar.TypeReg,
-		ModTime:      time.Unix(0, fileInfo.LastWriteTime.Nanoseconds()),
-		ChangeTime:   time.Unix(0, fileInfo.ChangeTime.Nanoseconds()),
-		AccessTime:   time.Unix(0, fileInfo.LastAccessTime.Nanoseconds()),
-		CreationTime: time.Unix(0, fileInfo.CreationTime.Nanoseconds()),
-		Winheaders:   make(map[string]string),
-	}
-	hdr.Winheaders[hdrFileAttributes] = fmt.Sprintf("%d", fileInfo.FileAttributes)
-
-	if (fileInfo.FileAttributes & syscall.FILE_ATTRIBUTE_DIRECTORY) != 0 {
-		hdr.Mode |= c_ISDIR
-		hdr.Size = 0
-		hdr.Typeflag = tar.TypeDir
-	}
-	return hdr
-}
-
-// WriteTarFileFromBackupStream writes a file to a tar writer using data from a Win32 backup stream.
-//
-// This encodes Win32 metadata as tar pax vendor extensions starting with MSWINDOWS.
-//
-// The additional Win32 metadata is:
-//
-// MSWINDOWS.fileattr: The Win32 file attributes, as a decimal value
-//
-// MSWINDOWS.rawsd: The Win32 security descriptor, in raw binary format
-//
-// MSWINDOWS.mountpoint: If present, this is a mount point and not a symlink, even though the type is '2' (symlink)
-func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size int64, fileInfo *winio.FileBasicInfo) error {
-	name = filepath.ToSlash(name)
-	hdr := BasicInfoHeader(name, size, fileInfo)
-
-	// If r can be seeked, then this function is two-pass: pass 1 collects the
-	// tar header data, and pass 2 copies the data stream. If r cannot be
-	// seeked, then some header data (in particular EAs) will be silently lost.
-	var (
-		restartPos int64
-		err        error
-	)
-	sr, readTwice := r.(io.Seeker)
-	if readTwice {
-		if restartPos, err = sr.Seek(0, io.SeekCurrent); err != nil {
-			readTwice = false
-		}
-	}
-
-	br := winio.NewBackupStreamReader(r)
-	var dataHdr *winio.BackupHeader
-	for dataHdr == nil {
-		bhdr, err := br.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			return err
-		}
-		switch bhdr.Id {
-		case winio.BackupData:
-			hdr.Mode |= c_ISREG
-			if !readTwice {
-				dataHdr = bhdr
-			}
-		case winio.BackupSecurity:
-			sd, err := ioutil.ReadAll(br)
-			if err != nil {
-				return err
-			}
-			hdr.Winheaders[hdrRawSecurityDescriptor] = base64.StdEncoding.EncodeToString(sd)
-
-		case winio.BackupReparseData:
-			hdr.Mode |= c_ISLNK
-			hdr.Typeflag = tar.TypeSymlink
-			reparseBuffer, err := ioutil.ReadAll(br)
-			rp, err := winio.DecodeReparsePoint(reparseBuffer)
-			if err != nil {
-				return err
-			}
-			if rp.IsMountPoint {
-				hdr.Winheaders[hdrMountPoint] = "1"
-			}
-			hdr.Linkname = rp.Target
-
-		case winio.BackupEaData:
-			eab, err := ioutil.ReadAll(br)
-			if err != nil {
-				return err
-			}
-			eas, err := winio.DecodeExtendedAttributes(eab)
-			if err != nil {
-				return err
-			}
-			for _, ea := range eas {
-				// Use base64 encoding for the binary value. Note that there
-				// is no way to encode the EA's flags, since their use doesn't
-				// make any sense for persisted EAs.
-				hdr.Winheaders[hdrEaPrefix+ea.Name] = base64.StdEncoding.EncodeToString(ea.Value)
-			}
-
-		case winio.BackupAlternateData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData:
-			// ignore these streams
-		default:
-			return fmt.Errorf("%s: unknown stream ID %d", name, bhdr.Id)
-		}
-	}
-
-	err = t.WriteHeader(hdr)
-	if err != nil {
-		return err
-	}
-
-	if readTwice {
-		// Get back to the data stream.
-		if _, err = sr.Seek(restartPos, io.SeekStart); err != nil {
-			return err
-		}
-		for dataHdr == nil {
-			bhdr, err := br.Next()
-			if err == io.EOF {
-				break
-			}
-			if err != nil {
-				return err
-			}
-			if bhdr.Id == winio.BackupData {
-				dataHdr = bhdr
-			}
-		}
-	}
-
-	if dataHdr != nil {
-		// A data stream was found. Copy the data.
-		if (dataHdr.Attributes & winio.StreamSparseAttributes) == 0 {
-			if size != dataHdr.Size {
-				return fmt.Errorf("%s: mismatch between file size %d and header size %d", name, size, dataHdr.Size)
-			}
-			_, err = io.Copy(t, br)
-			if err != nil {
-				return err
-			}
-		} else {
-			err = copySparse(t, br)
-			if err != nil {
-				return err
-			}
-		}
-	}
-
-	// Look for streams after the data stream. The only ones we handle are alternate data streams.
-	// Other streams may have metadata that could be serialized, but the tar header has already
-	// been written. In practice, this means that we don't get EA or TXF metadata.
-	for {
-		bhdr, err := br.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			return err
-		}
-		switch bhdr.Id {
-		case winio.BackupAlternateData:
-			altName := bhdr.Name
-			if strings.HasSuffix(altName, ":$DATA") {
-				altName = altName[:len(altName)-len(":$DATA")]
-			}
-			if (bhdr.Attributes & winio.StreamSparseAttributes) == 0 {
-				hdr = &tar.Header{
-					Name:       name + altName,
-					Mode:       hdr.Mode,
-					Typeflag:   tar.TypeReg,
-					Size:       bhdr.Size,
-					ModTime:    hdr.ModTime,
-					AccessTime: hdr.AccessTime,
-					ChangeTime: hdr.ChangeTime,
-				}
-				err = t.WriteHeader(hdr)
-				if err != nil {
-					return err
-				}
-				_, err = io.Copy(t, br)
-				if err != nil {
-					return err
-				}
-
-			} else {
-				// Unsupported for now, since the size of the alternate stream is not present
-				// in the backup stream until after the data has been read.
-				return errors.New("tar of sparse alternate data streams is unsupported")
-			}
-		case winio.BackupEaData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData:
-			// ignore these streams
-		default:
-			return fmt.Errorf("%s: unknown stream ID %d after data", name, bhdr.Id)
-		}
-	}
-	return nil
-}
-
-// FileInfoFromHeader retrieves basic Win32 file information from a tar header, using the additional metadata written by
-// WriteTarFileFromBackupStream.
-func FileInfoFromHeader(hdr *tar.Header) (name string, size int64, fileInfo *winio.FileBasicInfo, err error) {
-	name = hdr.Name
-	if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
-		size = hdr.Size
-	}
-	fileInfo = &winio.FileBasicInfo{
-		LastAccessTime: syscall.NsecToFiletime(hdr.AccessTime.UnixNano()),
-		LastWriteTime:  syscall.NsecToFiletime(hdr.ModTime.UnixNano()),
-		ChangeTime:     syscall.NsecToFiletime(hdr.ChangeTime.UnixNano()),
-		CreationTime:   syscall.NsecToFiletime(hdr.CreationTime.UnixNano()),
-	}
-	if attrStr, ok := hdr.Winheaders[hdrFileAttributes]; ok {
-		attr, err := strconv.ParseUint(attrStr, 10, 32)
-		if err != nil {
-			return "", 0, nil, err
-		}
-		fileInfo.FileAttributes = uint32(attr)
-	} else {
-		if hdr.Typeflag == tar.TypeDir {
-			fileInfo.FileAttributes |= syscall.FILE_ATTRIBUTE_DIRECTORY
-		}
-	}
-	return
-}
-
-// WriteBackupStreamFromTarFile writes a Win32 backup stream from the current tar file. Since this function may process multiple
-// tar file entries in order to collect all the alternate data streams for the file, it returns the next
-// tar file that was not processed, or io.EOF is there are no more.
-func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (*tar.Header, error) {
-	bw := winio.NewBackupStreamWriter(w)
-	var sd []byte
-	var err error
-	// Maintaining old SDDL-based behavior for backward compatibility.  All new tar headers written
-	// by this library will have raw binary for the security descriptor.
-	if sddl, ok := hdr.Winheaders[hdrSecurityDescriptor]; ok {
-		sd, err = winio.SddlToSecurityDescriptor(sddl)
-		if err != nil {
-			return nil, err
-		}
-	}
-	if sdraw, ok := hdr.Winheaders[hdrRawSecurityDescriptor]; ok {
-		sd, err = base64.StdEncoding.DecodeString(sdraw)
-		if err != nil {
-			return nil, err
-		}
-	}
-	if len(sd) != 0 {
-		bhdr := winio.BackupHeader{
-			Id:   winio.BackupSecurity,
-			Size: int64(len(sd)),
-		}
-		err := bw.WriteHeader(&bhdr)
-		if err != nil {
-			return nil, err
-		}
-		_, err = bw.Write(sd)
-		if err != nil {
-			return nil, err
-		}
-	}
-	var eas []winio.ExtendedAttribute
-	for k, v := range hdr.Winheaders {
-		if !strings.HasPrefix(k, hdrEaPrefix) {
-			continue
-		}
-		data, err := base64.StdEncoding.DecodeString(v)
-		if err != nil {
-			return nil, err
-		}
-		eas = append(eas, winio.ExtendedAttribute{
-			Name:  k[len(hdrEaPrefix):],
-			Value: data,
-		})
-	}
-	if len(eas) != 0 {
-		eadata, err := winio.EncodeExtendedAttributes(eas)
-		if err != nil {
-			return nil, err
-		}
-		bhdr := winio.BackupHeader{
-			Id:   winio.BackupEaData,
-			Size: int64(len(eadata)),
-		}
-		err = bw.WriteHeader(&bhdr)
-		if err != nil {
-			return nil, err
-		}
-		_, err = bw.Write(eadata)
-		if err != nil {
-			return nil, err
-		}
-	}
-	if hdr.Typeflag == tar.TypeSymlink {
-		_, isMountPoint := hdr.Winheaders[hdrMountPoint]
-		rp := winio.ReparsePoint{
-			Target:       filepath.FromSlash(hdr.Linkname),
-			IsMountPoint: isMountPoint,
-		}
-		reparse := winio.EncodeReparsePoint(&rp)
-		bhdr := winio.BackupHeader{
-			Id:   winio.BackupReparseData,
-			Size: int64(len(reparse)),
-		}
-		err := bw.WriteHeader(&bhdr)
-		if err != nil {
-			return nil, err
-		}
-		_, err = bw.Write(reparse)
-		if err != nil {
-			return nil, err
-		}
-	}
-	if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
-		bhdr := winio.BackupHeader{
-			Id:   winio.BackupData,
-			Size: hdr.Size,
-		}
-		err := bw.WriteHeader(&bhdr)
-		if err != nil {
-			return nil, err
-		}
-		_, err = io.Copy(bw, t)
-		if err != nil {
-			return nil, err
-		}
-	}
-	// Copy all the alternate data streams and return the next non-ADS header.
-	for {
-		ahdr, err := t.Next()
-		if err != nil {
-			return nil, err
-		}
-		if ahdr.Typeflag != tar.TypeReg || !strings.HasPrefix(ahdr.Name, hdr.Name+":") {
-			return ahdr, nil
-		}
-		bhdr := winio.BackupHeader{
-			Id:   winio.BackupAlternateData,
-			Size: ahdr.Size,
-			Name: ahdr.Name[len(hdr.Name):] + ":$DATA",
-		}
-		err = bw.WriteHeader(&bhdr)
-		if err != nil {
-			return nil, err
-		}
-		_, err = io.Copy(bw, t)
-		if err != nil {
-			return nil, err
-		}
-	}
-}

+ 0 - 84
vendor/github.com/Microsoft/go-winio/backuptar/tar_test.go

@@ -1,84 +0,0 @@
-package backuptar
-
-import (
-	"bytes"
-	"io/ioutil"
-	"os"
-	"path/filepath"
-	"reflect"
-	"testing"
-
-	"github.com/Microsoft/go-winio"
-	"github.com/Microsoft/go-winio/archive/tar"
-)
-
-func ensurePresent(t *testing.T, m map[string]string, keys ...string) {
-	for _, k := range keys {
-		if _, ok := m[k]; !ok {
-			t.Error(k, "not present in tar header")
-		}
-	}
-}
-
-func TestRoundTrip(t *testing.T) {
-	f, err := ioutil.TempFile("", "tst")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer f.Close()
-	defer os.Remove(f.Name())
-
-	if _, err = f.Write([]byte("testing 1 2 3\n")); err != nil {
-		t.Fatal(err)
-	}
-
-	if _, err = f.Seek(0, 0); err != nil {
-		t.Fatal(err)
-	}
-
-	fi, err := f.Stat()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	bi, err := winio.GetFileBasicInfo(f)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	br := winio.NewBackupFileReader(f, true)
-	defer br.Close()
-
-	var buf bytes.Buffer
-	tw := tar.NewWriter(&buf)
-
-	err = WriteTarFileFromBackupStream(tw, br, f.Name(), fi.Size(), bi)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	tr := tar.NewReader(&buf)
-	hdr, err := tr.Next()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	name, size, bi2, err := FileInfoFromHeader(hdr)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if name != filepath.ToSlash(f.Name()) {
-		t.Errorf("got name %s, expected %s", name, filepath.ToSlash(f.Name()))
-	}
-
-	if size != fi.Size() {
-		t.Errorf("got size %d, expected %d", size, fi.Size())
-	}
-
-	if !reflect.DeepEqual(*bi, *bi2) {
-		t.Errorf("got %#v, expected %#v", *bi, *bi2)
-	}
-
-	ensurePresent(t, hdr.Winheaders, "fileattr", "rawsd")
-}

+ 0 - 89
vendor/github.com/Microsoft/go-winio/ea_test.go

@@ -1,89 +0,0 @@
-package winio
-
-import (
-	"io/ioutil"
-	"os"
-	"reflect"
-	"syscall"
-	"testing"
-	"unsafe"
-)
-
-var (
-	testEas = []ExtendedAttribute{
-		{Name: "foo", Value: []byte("bar")},
-		{Name: "fizz", Value: []byte("buzz")},
-	}
-
-	testEasEncoded   = []byte{16, 0, 0, 0, 0, 3, 3, 0, 102, 111, 111, 0, 98, 97, 114, 0, 0, 0, 0, 0, 0, 4, 4, 0, 102, 105, 122, 122, 0, 98, 117, 122, 122, 0, 0, 0}
-	testEasNotPadded = testEasEncoded[0 : len(testEasEncoded)-3]
-	testEasTruncated = testEasEncoded[0:20]
-)
-
-func Test_RoundTripEas(t *testing.T) {
-	b, err := EncodeExtendedAttributes(testEas)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !reflect.DeepEqual(testEasEncoded, b) {
-		t.Fatalf("encoded mismatch %v %v", testEasEncoded, b)
-	}
-	eas, err := DecodeExtendedAttributes(b)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !reflect.DeepEqual(testEas, eas) {
-		t.Fatalf("mismatch %+v %+v", testEas, eas)
-	}
-}
-
-func Test_EasDontNeedPaddingAtEnd(t *testing.T) {
-	eas, err := DecodeExtendedAttributes(testEasNotPadded)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !reflect.DeepEqual(testEas, eas) {
-		t.Fatalf("mismatch %+v %+v", testEas, eas)
-	}
-}
-
-func Test_TruncatedEasFailCorrectly(t *testing.T) {
-	_, err := DecodeExtendedAttributes(testEasTruncated)
-	if err == nil {
-		t.Fatal("expected error")
-	}
-}
-
-func Test_NilEasEncodeAndDecodeAsNil(t *testing.T) {
-	b, err := EncodeExtendedAttributes(nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if len(b) != 0 {
-		t.Fatal("expected empty")
-	}
-	eas, err := DecodeExtendedAttributes(nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if len(eas) != 0 {
-		t.Fatal("expected empty")
-	}
-}
-
-// Test_SetFileEa makes sure that the test buffer is actually parsable by NtSetEaFile.
-func Test_SetFileEa(t *testing.T) {
-	f, err := ioutil.TempFile("", "winio")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer os.Remove(f.Name())
-	defer f.Close()
-	ntdll := syscall.MustLoadDLL("ntdll.dll")
-	ntSetEaFile := ntdll.MustFindProc("NtSetEaFile")
-	var iosb [2]uintptr
-	r, _, _ := ntSetEaFile.Call(f.Fd(), uintptr(unsafe.Pointer(&iosb[0])), uintptr(unsafe.Pointer(&testEasEncoded[0])), uintptr(len(testEasEncoded)))
-	if r != 0 {
-		t.Fatalf("NtSetEaFile failed with %08x", r)
-	}
-}

+ 0 - 516
vendor/github.com/Microsoft/go-winio/pipe_test.go

@@ -1,516 +0,0 @@
-package winio
-
-import (
-	"bufio"
-	"bytes"
-	"io"
-	"net"
-	"os"
-	"sync"
-	"syscall"
-	"testing"
-	"time"
-	"unsafe"
-)
-
-var testPipeName = `\\.\pipe\winiotestpipe`
-
-var aLongTimeAgo = time.Unix(1, 0)
-
-func TestDialUnknownFailsImmediately(t *testing.T) {
-	_, err := DialPipe(testPipeName, nil)
-	if err.(*os.PathError).Err != syscall.ENOENT {
-		t.Fatalf("expected ENOENT got %v", err)
-	}
-}
-
-func TestDialListenerTimesOut(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-	var d = time.Duration(10 * time.Millisecond)
-	_, err = DialPipe(testPipeName, &d)
-	if err != ErrTimeout {
-		t.Fatalf("expected ErrTimeout, got %v", err)
-	}
-}
-
-func TestDialAccessDeniedWithRestrictedSD(t *testing.T) {
-	c := PipeConfig{
-		SecurityDescriptor: "D:P(A;;0x1200FF;;;WD)",
-	}
-	l, err := ListenPipe(testPipeName, &c)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-	_, err = DialPipe(testPipeName, nil)
-	if err.(*os.PathError).Err != syscall.ERROR_ACCESS_DENIED {
-		t.Fatalf("expected ERROR_ACCESS_DENIED, got %v", err)
-	}
-}
-
-func getConnection(cfg *PipeConfig) (client net.Conn, server net.Conn, err error) {
-	l, err := ListenPipe(testPipeName, cfg)
-	if err != nil {
-		return
-	}
-	defer l.Close()
-
-	type response struct {
-		c   net.Conn
-		err error
-	}
-	ch := make(chan response)
-	go func() {
-		c, err := l.Accept()
-		ch <- response{c, err}
-	}()
-
-	c, err := DialPipe(testPipeName, nil)
-	if err != nil {
-		return
-	}
-
-	r := <-ch
-	if err = r.err; err != nil {
-		c.Close()
-		return
-	}
-
-	client = c
-	server = r.c
-	return
-}
-
-func TestReadTimeout(t *testing.T) {
-	c, s, err := getConnection(nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-	defer s.Close()
-
-	c.SetReadDeadline(time.Now().Add(10 * time.Millisecond))
-
-	buf := make([]byte, 10)
-	_, err = c.Read(buf)
-	if err != ErrTimeout {
-		t.Fatalf("expected ErrTimeout, got %v", err)
-	}
-}
-
-func server(l net.Listener, ch chan int) {
-	c, err := l.Accept()
-	if err != nil {
-		panic(err)
-	}
-	rw := bufio.NewReadWriter(bufio.NewReader(c), bufio.NewWriter(c))
-	s, err := rw.ReadString('\n')
-	if err != nil {
-		panic(err)
-	}
-	_, err = rw.WriteString("got " + s)
-	if err != nil {
-		panic(err)
-	}
-	err = rw.Flush()
-	if err != nil {
-		panic(err)
-	}
-	c.Close()
-	ch <- 1
-}
-
-func TestFullListenDialReadWrite(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-
-	ch := make(chan int)
-	go server(l, ch)
-
-	c, err := DialPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-
-	rw := bufio.NewReadWriter(bufio.NewReader(c), bufio.NewWriter(c))
-	_, err = rw.WriteString("hello world\n")
-	if err != nil {
-		t.Fatal(err)
-	}
-	err = rw.Flush()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	s, err := rw.ReadString('\n')
-	if err != nil {
-		t.Fatal(err)
-	}
-	ms := "got hello world\n"
-	if s != ms {
-		t.Errorf("expected '%s', got '%s'", ms, s)
-	}
-
-	<-ch
-}
-
-func TestCloseAbortsListen(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	ch := make(chan error)
-	go func() {
-		_, err := l.Accept()
-		ch <- err
-	}()
-
-	time.Sleep(30 * time.Millisecond)
-	l.Close()
-
-	err = <-ch
-	if err != ErrPipeListenerClosed {
-		t.Fatalf("expected ErrPipeListenerClosed, got %v", err)
-	}
-}
-
-func ensureEOFOnClose(t *testing.T, r io.Reader, w io.Closer) {
-	b := make([]byte, 10)
-	w.Close()
-	n, err := r.Read(b)
-	if n > 0 {
-		t.Errorf("unexpected byte count %d", n)
-	}
-	if err != io.EOF {
-		t.Errorf("expected EOF: %v", err)
-	}
-}
-
-func TestCloseClientEOFServer(t *testing.T) {
-	c, s, err := getConnection(nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-	defer s.Close()
-	ensureEOFOnClose(t, c, s)
-}
-
-func TestCloseServerEOFClient(t *testing.T) {
-	c, s, err := getConnection(nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-	defer s.Close()
-	ensureEOFOnClose(t, s, c)
-}
-
-func TestCloseWriteEOF(t *testing.T) {
-	cfg := &PipeConfig{
-		MessageMode: true,
-	}
-	c, s, err := getConnection(cfg)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-	defer s.Close()
-
-	type closeWriter interface {
-		CloseWrite() error
-	}
-
-	err = c.(closeWriter).CloseWrite()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	b := make([]byte, 10)
-	_, err = s.Read(b)
-	if err != io.EOF {
-		t.Fatal(err)
-	}
-}
-
-func TestAcceptAfterCloseFails(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	l.Close()
-	_, err = l.Accept()
-	if err != ErrPipeListenerClosed {
-		t.Fatalf("expected ErrPipeListenerClosed, got %v", err)
-	}
-}
-
-func TestDialTimesOutByDefault(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-	_, err = DialPipe(testPipeName, nil)
-	if err != ErrTimeout {
-		t.Fatalf("expected ErrTimeout, got %v", err)
-	}
-}
-
-func TestTimeoutPendingRead(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-
-	serverDone := make(chan struct{})
-
-	go func() {
-		s, err := l.Accept()
-		if err != nil {
-			t.Fatal(err)
-		}
-		time.Sleep(1 * time.Second)
-		s.Close()
-		close(serverDone)
-	}()
-
-	client, err := DialPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer client.Close()
-
-	clientErr := make(chan error)
-	go func() {
-		buf := make([]byte, 10)
-		_, err = client.Read(buf)
-		clientErr <- err
-	}()
-
-	time.Sleep(100 * time.Millisecond) // make *sure* the pipe is reading before we set the deadline
-	client.SetReadDeadline(aLongTimeAgo)
-
-	select {
-	case err = <-clientErr:
-		if err != ErrTimeout {
-			t.Fatalf("expected ErrTimeout, got %v", err)
-		}
-	case <-time.After(100 * time.Millisecond):
-		t.Fatalf("timed out while waiting for read to cancel")
-		<-clientErr
-	}
-	<-serverDone
-}
-
-func TestTimeoutPendingWrite(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-
-	serverDone := make(chan struct{})
-
-	go func() {
-		s, err := l.Accept()
-		if err != nil {
-			t.Fatal(err)
-		}
-		time.Sleep(1 * time.Second)
-		s.Close()
-		close(serverDone)
-	}()
-
-	client, err := DialPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer client.Close()
-
-	clientErr := make(chan error)
-	go func() {
-		_, err = client.Write([]byte("this should timeout"))
-		clientErr <- err
-	}()
-
-	time.Sleep(100 * time.Millisecond) // make *sure* the pipe is writing before we set the deadline
-	client.SetWriteDeadline(aLongTimeAgo)
-
-	select {
-	case err = <-clientErr:
-		if err != ErrTimeout {
-			t.Fatalf("expected ErrTimeout, got %v", err)
-		}
-	case <-time.After(100 * time.Millisecond):
-		t.Fatalf("timed out while waiting for write to cancel")
-		<-clientErr
-	}
-	<-serverDone
-}
-
-type CloseWriter interface {
-	CloseWrite() error
-}
-
-func TestEchoWithMessaging(t *testing.T) {
-	c := PipeConfig{
-		MessageMode:      true,  // Use message mode so that CloseWrite() is supported
-		InputBufferSize:  65536, // Use 64KB buffers to improve performance
-		OutputBufferSize: 65536,
-	}
-	l, err := ListenPipe(testPipeName, &c)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-
-	listenerDone := make(chan bool)
-	clientDone := make(chan bool)
-	go func() {
-		// server echo
-		conn, e := l.Accept()
-		if e != nil {
-			t.Fatal(e)
-		}
-		defer conn.Close()
-
-		time.Sleep(500 * time.Millisecond) // make *sure* we don't begin to read before eof signal is sent
-		io.Copy(conn, conn)
-		conn.(CloseWriter).CloseWrite()
-		close(listenerDone)
-	}()
-	timeout := 1 * time.Second
-	client, err := DialPipe(testPipeName, &timeout)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer client.Close()
-
-	go func() {
-		// client read back
-		bytes := make([]byte, 2)
-		n, e := client.Read(bytes)
-		if e != nil {
-			t.Fatal(e)
-		}
-		if n != 2 {
-			t.Fatalf("expected 2 bytes, got %v", n)
-		}
-		close(clientDone)
-	}()
-
-	payload := make([]byte, 2)
-	payload[0] = 0
-	payload[1] = 1
-
-	n, err := client.Write(payload)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if n != 2 {
-		t.Fatalf("expected 2 bytes, got %v", n)
-	}
-	client.(CloseWriter).CloseWrite()
-	<-listenerDone
-	<-clientDone
-}
-
-func TestConnectRace(t *testing.T) {
-	l, err := ListenPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-	go func() {
-		for {
-			s, err := l.Accept()
-			if err == ErrPipeListenerClosed {
-				return
-			}
-
-			if err != nil {
-				t.Fatal(err)
-			}
-			s.Close()
-		}
-	}()
-
-	for i := 0; i < 1000; i++ {
-		c, err := DialPipe(testPipeName, nil)
-		if err != nil {
-			t.Fatal(err)
-		}
-		c.Close()
-	}
-}
-
-func TestMessageReadMode(t *testing.T) {
-	var wg sync.WaitGroup
-	defer wg.Wait()
-
-	l, err := ListenPipe(testPipeName, &PipeConfig{MessageMode: true})
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer l.Close()
-
-	msg := ([]byte)("hello world")
-
-	wg.Add(1)
-	go func() {
-		defer wg.Done()
-		s, err := l.Accept()
-		if err != nil {
-			t.Fatal(err)
-		}
-		_, err = s.Write(msg)
-		if err != nil {
-			t.Fatal(err)
-		}
-		s.Close()
-	}()
-
-	c, err := DialPipe(testPipeName, nil)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer c.Close()
-
-	setNamedPipeHandleState := syscall.NewLazyDLL("kernel32.dll").NewProc("SetNamedPipeHandleState")
-
-	p := c.(*win32MessageBytePipe)
-	mode := uint32(cPIPE_READMODE_MESSAGE)
-	if s, _, err := setNamedPipeHandleState.Call(uintptr(p.handle), uintptr(unsafe.Pointer(&mode)), 0, 0); s == 0 {
-		t.Fatal(err)
-	}
-
-	ch := make([]byte, 1)
-	var vmsg []byte
-	for {
-		n, err := c.Read(ch)
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-		if n != 1 {
-			t.Fatal("expected 1: ", n)
-		}
-		vmsg = append(vmsg, ch[0])
-	}
-	if !bytes.Equal(msg, vmsg) {
-		t.Fatalf("expected %s: %s", msg, vmsg)
-	}
-}

+ 0 - 17
vendor/github.com/Microsoft/go-winio/privileges_test.go

@@ -1,17 +0,0 @@
-package winio
-
-import "testing"
-
-func TestRunWithUnavailablePrivilege(t *testing.T) {
-	err := RunWithPrivilege("SeCreateTokenPrivilege", func() error { return nil })
-	if _, ok := err.(*PrivilegeError); err == nil || !ok {
-		t.Fatal("expected PrivilegeError")
-	}
-}
-
-func TestRunWithPrivileges(t *testing.T) {
-	err := RunWithPrivilege("SeShutdownPrivilege", func() error { return nil })
-	if err != nil {
-		t.Fatal(err)
-	}
-}

+ 0 - 26
vendor/github.com/Microsoft/go-winio/sd_test.go

@@ -1,26 +0,0 @@
-package winio
-
-import "testing"
-
-func TestLookupInvalidSid(t *testing.T) {
-	_, err := LookupSidByName(".\\weoifjdsklfj")
-	aerr, ok := err.(*AccountLookupError)
-	if !ok || aerr.Err != cERROR_NONE_MAPPED {
-		t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
-	}
-}
-
-func TestLookupValidSid(t *testing.T) {
-	sid, err := LookupSidByName("Everyone")
-	if err != nil || sid != "S-1-1-0" {
-		t.Fatalf("expected S-1-1-0, got %s, %s", sid, err)
-	}
-}
-
-func TestLookupEmptyNameFails(t *testing.T) {
-	_, err := LookupSidByName(".\\weoifjdsklfj")
-	aerr, ok := err.(*AccountLookupError)
-	if !ok || aerr.Err != cERROR_NONE_MAPPED {
-		t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
-	}
-}

+ 0 - 901
vendor/github.com/Microsoft/go-winio/vhd/mksyscall_windows.go

@@ -1,901 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Hard-coding unicode mode for VHD library.
-
-// +build ignore
-
-/*
-mksyscall_windows generates windows system call bodies
-
-It parses all files specified on command line containing function
-prototypes (like syscall_windows.go) and prints system call bodies
-to standard output.
-
-The prototypes are marked by lines beginning with "//sys" and read
-like func declarations if //sys is replaced by func, but:
-
-* The parameter lists must give a name for each argument. This
-  includes return parameters.
-
-* The parameter lists must give a type for each argument:
-  the (x, y, z int) shorthand is not allowed.
-
-* If the return parameter is an error number, it must be named err.
-
-* If go func name needs to be different from it's winapi dll name,
-  the winapi name could be specified at the end, after "=" sign, like
-  //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
-
-* Each function that returns err needs to supply a condition, that
-  return value of winapi will be tested against to detect failure.
-  This would set err to windows "last-error", otherwise it will be nil.
-  The value can be provided at end of //sys declaration, like
-  //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
-  and is [failretval==0] by default.
-
-Usage:
-	mksyscall_windows [flags] [path ...]
-
-The flags are:
-	-output
-		Specify output file name (outputs to console if blank).
-	-trace
-		Generate print statement after every syscall.
-*/
-package main
-
-import (
-	"bufio"
-	"bytes"
-	"errors"
-	"flag"
-	"fmt"
-	"go/format"
-	"go/parser"
-	"go/token"
-	"io"
-	"io/ioutil"
-	"log"
-	"os"
-	"path/filepath"
-	"runtime"
-	"sort"
-	"strconv"
-	"strings"
-	"text/template"
-)
-
-var (
-	filename       = flag.String("output", "", "output file name (standard output if omitted)")
-	printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
-	systemDLL      = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory")
-)
-
-func trim(s string) string {
-	return strings.Trim(s, " \t")
-}
-
-var packageName string
-
-func packagename() string {
-	return packageName
-}
-
-func syscalldot() string {
-	if packageName == "syscall" {
-		return ""
-	}
-	return "syscall."
-}
-
-// Param is function parameter
-type Param struct {
-	Name      string
-	Type      string
-	fn        *Fn
-	tmpVarIdx int
-}
-
-// tmpVar returns temp variable name that will be used to represent p during syscall.
-func (p *Param) tmpVar() string {
-	if p.tmpVarIdx < 0 {
-		p.tmpVarIdx = p.fn.curTmpVarIdx
-		p.fn.curTmpVarIdx++
-	}
-	return fmt.Sprintf("_p%d", p.tmpVarIdx)
-}
-
-// BoolTmpVarCode returns source code for bool temp variable.
-func (p *Param) BoolTmpVarCode() string {
-	const code = `var %s uint32
-	if %s {
-		%s = 1
-	} else {
-		%s = 0
-	}`
-	tmp := p.tmpVar()
-	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
-}
-
-// SliceTmpVarCode returns source code for slice temp variable.
-func (p *Param) SliceTmpVarCode() string {
-	const code = `var %s *%s
-	if len(%s) > 0 {
-		%s = &%s[0]
-	}`
-	tmp := p.tmpVar()
-	return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
-}
-
-// StringTmpVarCode returns source code for string temp variable.
-func (p *Param) StringTmpVarCode() string {
-	errvar := p.fn.Rets.ErrorVarName()
-	if errvar == "" {
-		errvar = "_"
-	}
-	tmp := p.tmpVar()
-	const code = `var %s %s
-	%s, %s = %s(%s)`
-	s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
-	if errvar == "-" {
-		return s
-	}
-	const morecode = `
-	if %s != nil {
-		return
-	}`
-	return s + fmt.Sprintf(morecode, errvar)
-}
-
-// TmpVarCode returns source code for temp variable.
-func (p *Param) TmpVarCode() string {
-	switch {
-	case p.Type == "bool":
-		return p.BoolTmpVarCode()
-	case strings.HasPrefix(p.Type, "[]"):
-		return p.SliceTmpVarCode()
-	default:
-		return ""
-	}
-}
-
-// TmpVarHelperCode returns source code for helper's temp variable.
-func (p *Param) TmpVarHelperCode() string {
-	if p.Type != "string" {
-		return ""
-	}
-	return p.StringTmpVarCode()
-}
-
-// SyscallArgList returns source code fragments representing p parameter
-// in syscall. Slices are translated into 2 syscall parameters: pointer to
-// the first element and length.
-func (p *Param) SyscallArgList() []string {
-	t := p.HelperType()
-	var s string
-	switch {
-	case t[0] == '*':
-		s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
-	case t == "bool":
-		s = p.tmpVar()
-	case strings.HasPrefix(t, "[]"):
-		return []string{
-			fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
-			fmt.Sprintf("uintptr(len(%s))", p.Name),
-		}
-	default:
-		s = p.Name
-	}
-	return []string{fmt.Sprintf("uintptr(%s)", s)}
-}
-
-// IsError determines if p parameter is used to return error.
-func (p *Param) IsError() bool {
-	return p.Name == "err" && p.Type == "error"
-}
-
-// HelperType returns type of parameter p used in helper function.
-func (p *Param) HelperType() string {
-	if p.Type == "string" {
-		return p.fn.StrconvType()
-	}
-	return p.Type
-}
-
-// join concatenates parameters ps into a string with sep separator.
-// Each parameter is converted into string by applying fn to it
-// before conversion.
-func join(ps []*Param, fn func(*Param) string, sep string) string {
-	if len(ps) == 0 {
-		return ""
-	}
-	a := make([]string, 0)
-	for _, p := range ps {
-		a = append(a, fn(p))
-	}
-	return strings.Join(a, sep)
-}
-
-// Rets describes function return parameters.
-type Rets struct {
-	Name         string
-	Type         string
-	ReturnsError bool
-	FailCond     string
-}
-
-// ErrorVarName returns error variable name for r.
-func (r *Rets) ErrorVarName() string {
-	if r.ReturnsError {
-		return "err"
-	}
-	if r.Type == "error" {
-		return r.Name
-	}
-	return ""
-}
-
-// ToParams converts r into slice of *Param.
-func (r *Rets) ToParams() []*Param {
-	ps := make([]*Param, 0)
-	if len(r.Name) > 0 {
-		ps = append(ps, &Param{Name: r.Name, Type: r.Type})
-	}
-	if r.ReturnsError {
-		ps = append(ps, &Param{Name: "err", Type: "error"})
-	}
-	return ps
-}
-
-// List returns source code of syscall return parameters.
-func (r *Rets) List() string {
-	s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
-	if len(s) > 0 {
-		s = "(" + s + ")"
-	}
-	return s
-}
-
-// PrintList returns source code of trace printing part correspondent
-// to syscall return values.
-func (r *Rets) PrintList() string {
-	return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
-}
-
-// SetReturnValuesCode returns source code that accepts syscall return values.
-func (r *Rets) SetReturnValuesCode() string {
-	if r.Name == "" && !r.ReturnsError {
-		return ""
-	}
-	retvar := "r0"
-	if r.Name == "" {
-		retvar = "r1"
-	}
-	errvar := "_"
-	if r.ReturnsError {
-		errvar = "e1"
-	}
-	return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
-}
-
-func (r *Rets) useLongHandleErrorCode(retvar string) string {
-	const code = `if %s {
-		if e1 != 0 {
-			err = errnoErr(e1)
-		} else {
-			err = %sEINVAL
-		}
-	}`
-	cond := retvar + " == 0"
-	if r.FailCond != "" {
-		cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
-	}
-	return fmt.Sprintf(code, cond, syscalldot())
-}
-
-// SetErrorCode returns source code that sets return parameters.
-func (r *Rets) SetErrorCode() string {
-	const code = `if r0 != 0 {
-		%s = %sErrno(r0)
-	}`
-	if r.Name == "" && !r.ReturnsError {
-		return ""
-	}
-	if r.Name == "" {
-		return r.useLongHandleErrorCode("r1")
-	}
-	if r.Type == "error" {
-		return fmt.Sprintf(code, r.Name, syscalldot())
-	}
-	s := ""
-	switch {
-	case r.Type[0] == '*':
-		s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
-	case r.Type == "bool":
-		s = fmt.Sprintf("%s = r0 != 0", r.Name)
-	default:
-		s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
-	}
-	if !r.ReturnsError {
-		return s
-	}
-	return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
-}
-
-// Fn describes syscall function.
-type Fn struct {
-	Name        string
-	Params      []*Param
-	Rets        *Rets
-	PrintTrace  bool
-	dllname     string
-	dllfuncname string
-	src         string
-	// TODO: get rid of this field and just use parameter index instead
-	curTmpVarIdx int // insure tmp variables have uniq names
-}
-
-// extractParams parses s to extract function parameters.
-func extractParams(s string, f *Fn) ([]*Param, error) {
-	s = trim(s)
-	if s == "" {
-		return nil, nil
-	}
-	a := strings.Split(s, ",")
-	ps := make([]*Param, len(a))
-	for i := range ps {
-		s2 := trim(a[i])
-		b := strings.Split(s2, " ")
-		if len(b) != 2 {
-			b = strings.Split(s2, "\t")
-			if len(b) != 2 {
-				return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
-			}
-		}
-		ps[i] = &Param{
-			Name:      trim(b[0]),
-			Type:      trim(b[1]),
-			fn:        f,
-			tmpVarIdx: -1,
-		}
-	}
-	return ps, nil
-}
-
-// extractSection extracts text out of string s starting after start
-// and ending just before end. found return value will indicate success,
-// and prefix, body and suffix will contain correspondent parts of string s.
-func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
-	s = trim(s)
-	if strings.HasPrefix(s, string(start)) {
-		// no prefix
-		body = s[1:]
-	} else {
-		a := strings.SplitN(s, string(start), 2)
-		if len(a) != 2 {
-			return "", "", s, false
-		}
-		prefix = a[0]
-		body = a[1]
-	}
-	a := strings.SplitN(body, string(end), 2)
-	if len(a) != 2 {
-		return "", "", "", false
-	}
-	return prefix, a[0], a[1], true
-}
-
-// newFn parses string s and return created function Fn.
-func newFn(s string) (*Fn, error) {
-	s = trim(s)
-	f := &Fn{
-		Rets:       &Rets{},
-		src:        s,
-		PrintTrace: *printTraceFlag,
-	}
-	// function name and args
-	prefix, body, s, found := extractSection(s, '(', ')')
-	if !found || prefix == "" {
-		return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
-	}
-	f.Name = prefix
-	var err error
-	f.Params, err = extractParams(body, f)
-	if err != nil {
-		return nil, err
-	}
-	// return values
-	_, body, s, found = extractSection(s, '(', ')')
-	if found {
-		r, err := extractParams(body, f)
-		if err != nil {
-			return nil, err
-		}
-		switch len(r) {
-		case 0:
-		case 1:
-			if r[0].IsError() {
-				f.Rets.ReturnsError = true
-			} else {
-				f.Rets.Name = r[0].Name
-				f.Rets.Type = r[0].Type
-			}
-		case 2:
-			if !r[1].IsError() {
-				return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
-			}
-			f.Rets.ReturnsError = true
-			f.Rets.Name = r[0].Name
-			f.Rets.Type = r[0].Type
-		default:
-			return nil, errors.New("Too many return values in \"" + f.src + "\"")
-		}
-	}
-	// fail condition
-	_, body, s, found = extractSection(s, '[', ']')
-	if found {
-		f.Rets.FailCond = body
-	}
-	// dll and dll function names
-	s = trim(s)
-	if s == "" {
-		return f, nil
-	}
-	if !strings.HasPrefix(s, "=") {
-		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
-	}
-	s = trim(s[1:])
-	a := strings.Split(s, ".")
-	switch len(a) {
-	case 1:
-		f.dllfuncname = a[0]
-	case 2:
-		f.dllname = a[0]
-		f.dllfuncname = a[1]
-	default:
-		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
-	}
-	return f, nil
-}
-
-// DLLName returns DLL name for function f.
-func (f *Fn) DLLName() string {
-	if f.dllname == "" {
-		return "kernel32"
-	}
-	return f.dllname
-}
-
-// DLLName returns DLL function name for function f.
-func (f *Fn) DLLFuncName() string {
-	if f.dllfuncname == "" {
-		return f.Name
-	}
-	return f.dllfuncname
-}
-
-// ParamList returns source code for function f parameters.
-func (f *Fn) ParamList() string {
-	return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
-}
-
-// HelperParamList returns source code for helper function f parameters.
-func (f *Fn) HelperParamList() string {
-	return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
-}
-
-// ParamPrintList returns source code of trace printing part correspondent
-// to syscall input parameters.
-func (f *Fn) ParamPrintList() string {
-	return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
-}
-
-// ParamCount return number of syscall parameters for function f.
-func (f *Fn) ParamCount() int {
-	n := 0
-	for _, p := range f.Params {
-		n += len(p.SyscallArgList())
-	}
-	return n
-}
-
-// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
-// to use. It returns parameter count for correspondent SyscallX function.
-func (f *Fn) SyscallParamCount() int {
-	n := f.ParamCount()
-	switch {
-	case n <= 3:
-		return 3
-	case n <= 6:
-		return 6
-	case n <= 9:
-		return 9
-	case n <= 12:
-		return 12
-	case n <= 15:
-		return 15
-	default:
-		panic("too many arguments to system call")
-	}
-}
-
-// Syscall determines which SyscallX function to use for function f.
-func (f *Fn) Syscall() string {
-	c := f.SyscallParamCount()
-	if c == 3 {
-		return syscalldot() + "Syscall"
-	}
-	return syscalldot() + "Syscall" + strconv.Itoa(c)
-}
-
-// SyscallParamList returns source code for SyscallX parameters for function f.
-func (f *Fn) SyscallParamList() string {
-	a := make([]string, 0)
-	for _, p := range f.Params {
-		a = append(a, p.SyscallArgList()...)
-	}
-	for len(a) < f.SyscallParamCount() {
-		a = append(a, "0")
-	}
-	return strings.Join(a, ", ")
-}
-
-// HelperCallParamList returns source code of call into function f helper.
-func (f *Fn) HelperCallParamList() string {
-	a := make([]string, 0, len(f.Params))
-	for _, p := range f.Params {
-		s := p.Name
-		if p.Type == "string" {
-			s = p.tmpVar()
-		}
-		a = append(a, s)
-	}
-	return strings.Join(a, ", ")
-}
-
-// IsUTF16 is true, if f is W (utf16) function. It is false
-// for all A (ascii) functions.
-func (f *Fn) IsUTF16() bool {
-	return true
-}
-
-// StrconvFunc returns name of Go string to OS string function for f.
-func (f *Fn) StrconvFunc() string {
-	if f.IsUTF16() {
-		return syscalldot() + "UTF16PtrFromString"
-	}
-	return syscalldot() + "BytePtrFromString"
-}
-
-// StrconvType returns Go type name used for OS string for f.
-func (f *Fn) StrconvType() string {
-	if f.IsUTF16() {
-		return "*uint16"
-	}
-	return "*byte"
-}
-
-// HasStringParam is true, if f has at least one string parameter.
-// Otherwise it is false.
-func (f *Fn) HasStringParam() bool {
-	for _, p := range f.Params {
-		if p.Type == "string" {
-			return true
-		}
-	}
-	return false
-}
-
-// HelperName returns name of function f helper.
-func (f *Fn) HelperName() string {
-	if !f.HasStringParam() {
-		return f.Name
-	}
-	return "_" + f.Name
-}
-
-// Source files and functions.
-type Source struct {
-	Funcs           []*Fn
-	Files           []string
-	StdLibImports   []string
-	ExternalImports []string
-}
-
-func (src *Source) Import(pkg string) {
-	src.StdLibImports = append(src.StdLibImports, pkg)
-	sort.Strings(src.StdLibImports)
-}
-
-func (src *Source) ExternalImport(pkg string) {
-	src.ExternalImports = append(src.ExternalImports, pkg)
-	sort.Strings(src.ExternalImports)
-}
-
-// ParseFiles parses files listed in fs and extracts all syscall
-// functions listed in  sys comments. It returns source files
-// and functions collection *Source if successful.
-func ParseFiles(fs []string) (*Source, error) {
-	src := &Source{
-		Funcs: make([]*Fn, 0),
-		Files: make([]string, 0),
-		StdLibImports: []string{
-			"unsafe",
-		},
-		ExternalImports: make([]string, 0),
-	}
-	for _, file := range fs {
-		if err := src.ParseFile(file); err != nil {
-			return nil, err
-		}
-	}
-	return src, nil
-}
-
-// DLLs return dll names for a source set src.
-func (src *Source) DLLs() []string {
-	uniq := make(map[string]bool)
-	r := make([]string, 0)
-	for _, f := range src.Funcs {
-		name := f.DLLName()
-		if _, found := uniq[name]; !found {
-			uniq[name] = true
-			r = append(r, name)
-		}
-	}
-	return r
-}
-
-// ParseFile adds additional file path to a source set src.
-func (src *Source) ParseFile(path string) error {
-	file, err := os.Open(path)
-	if err != nil {
-		return err
-	}
-	defer file.Close()
-
-	s := bufio.NewScanner(file)
-	for s.Scan() {
-		t := trim(s.Text())
-		if len(t) < 7 {
-			continue
-		}
-		if !strings.HasPrefix(t, "//sys") {
-			continue
-		}
-		t = t[5:]
-		if !(t[0] == ' ' || t[0] == '\t') {
-			continue
-		}
-		f, err := newFn(t[1:])
-		if err != nil {
-			return err
-		}
-		src.Funcs = append(src.Funcs, f)
-	}
-	if err := s.Err(); err != nil {
-		return err
-	}
-	src.Files = append(src.Files, path)
-
-	// get package name
-	fset := token.NewFileSet()
-	_, err = file.Seek(0, 0)
-	if err != nil {
-		return err
-	}
-	pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
-	if err != nil {
-		return err
-	}
-	packageName = pkg.Name.Name
-
-	return nil
-}
-
-// IsStdRepo returns true if src is part of standard library.
-func (src *Source) IsStdRepo() (bool, error) {
-	if len(src.Files) == 0 {
-		return false, errors.New("no input files provided")
-	}
-	abspath, err := filepath.Abs(src.Files[0])
-	if err != nil {
-		return false, err
-	}
-	goroot := runtime.GOROOT()
-	if runtime.GOOS == "windows" {
-		abspath = strings.ToLower(abspath)
-		goroot = strings.ToLower(goroot)
-	}
-	sep := string(os.PathSeparator)
-	if !strings.HasSuffix(goroot, sep) {
-		goroot += sep
-	}
-	return strings.HasPrefix(abspath, goroot), nil
-}
-
-// Generate output source file from a source set src.
-func (src *Source) Generate(w io.Writer) error {
-	const (
-		pkgStd         = iota // any package in std library
-		pkgXSysWindows        // x/sys/windows package
-		pkgOther
-	)
-	isStdRepo, err := src.IsStdRepo()
-	if err != nil {
-		return err
-	}
-	var pkgtype int
-	switch {
-	case isStdRepo:
-		pkgtype = pkgStd
-	case packageName == "windows":
-		// TODO: this needs better logic than just using package name
-		pkgtype = pkgXSysWindows
-	default:
-		pkgtype = pkgOther
-	}
-	if *systemDLL {
-		switch pkgtype {
-		case pkgStd:
-			src.Import("internal/syscall/windows/sysdll")
-		case pkgXSysWindows:
-		default:
-			src.ExternalImport("golang.org/x/sys/windows")
-		}
-	}
-	if packageName != "syscall" {
-		src.Import("syscall")
-	}
-	funcMap := template.FuncMap{
-		"packagename": packagename,
-		"syscalldot":  syscalldot,
-		"newlazydll": func(dll string) string {
-			arg := "\"" + dll + ".dll\""
-			if !*systemDLL {
-				return syscalldot() + "NewLazyDLL(" + arg + ")"
-			}
-			switch pkgtype {
-			case pkgStd:
-				return syscalldot() + "NewLazyDLL(sysdll.Add(" + arg + "))"
-			case pkgXSysWindows:
-				return "NewLazySystemDLL(" + arg + ")"
-			default:
-				return "windows.NewLazySystemDLL(" + arg + ")"
-			}
-		},
-	}
-	t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
-	err = t.Execute(w, src)
-	if err != nil {
-		return errors.New("Failed to execute template: " + err.Error())
-	}
-	return nil
-}
-
-func usage() {
-	fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
-	flag.PrintDefaults()
-	os.Exit(1)
-}
-
-func main() {
-	flag.Usage = usage
-	flag.Parse()
-	if len(flag.Args()) <= 0 {
-		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
-		usage()
-	}
-
-	src, err := ParseFiles(flag.Args())
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	var buf bytes.Buffer
-	if err := src.Generate(&buf); err != nil {
-		log.Fatal(err)
-	}
-
-	data, err := format.Source(buf.Bytes())
-	if err != nil {
-		log.Fatal(err)
-	}
-	if *filename == "" {
-		_, err = os.Stdout.Write(data)
-	} else {
-		err = ioutil.WriteFile(*filename, data, 0644)
-	}
-	if err != nil {
-		log.Fatal(err)
-	}
-}
-
-// TODO: use println instead to print in the following template
-const srcTemplate = `
-
-{{define "main"}}// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
-
-package {{packagename}}
-
-import (
-{{range .StdLibImports}}"{{.}}"
-{{end}}
-
-{{range .ExternalImports}}"{{.}}"
-{{end}}
-)
-
-var _ unsafe.Pointer
-
-// Do the interface allocations only once for common
-// Errno values.
-const (
-	errnoERROR_IO_PENDING = 997
-)
-
-var (
-	errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING)
-)
-
-// errnoErr returns common boxed Errno values, to prevent
-// allocations at runtime.
-func errnoErr(e {{syscalldot}}Errno) error {
-	switch e {
-	case 0:
-		return nil
-	case errnoERROR_IO_PENDING:
-		return errERROR_IO_PENDING
-	}
-	// TODO: add more here, after collecting data on the common
-	// error values see on Windows. (perhaps when running
-	// all.bat?)
-	return e
-}
-
-var (
-{{template "dlls" .}}
-{{template "funcnames" .}})
-{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
-{{end}}
-
-{{/* help functions */}}
-
-{{define "dlls"}}{{range .DLLs}}	mod{{.}} = {{newlazydll .}}
-{{end}}{{end}}
-
-{{define "funcnames"}}{{range .Funcs}}	proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
-{{end}}{{end}}
-
-{{define "helperbody"}}
-func {{.Name}}({{.ParamList}}) {{template "results" .}}{
-{{template "helpertmpvars" .}}	return {{.HelperName}}({{.HelperCallParamList}})
-}
-{{end}}
-
-{{define "funcbody"}}
-func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
-{{template "tmpvars" .}}	{{template "syscall" .}}
-{{template "seterror" .}}{{template "printtrace" .}}	return
-}
-{{end}}
-
-{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}}	{{.TmpVarHelperCode}}
-{{end}}{{end}}{{end}}
-
-{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}}	{{.TmpVarCode}}
-{{end}}{{end}}{{end}}
-
-{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
-
-{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
-
-{{define "seterror"}}{{if .Rets.SetErrorCode}}	{{.Rets.SetErrorCode}}
-{{end}}{{end}}
-
-{{define "printtrace"}}{{if .PrintTrace}}	print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
-{{end}}{{end}}
-
-`

+ 0 - 108
vendor/github.com/Microsoft/go-winio/vhd/vhd.go

@@ -1,108 +0,0 @@
-// +build windows
-
-package vhd
-
-import "syscall"
-
-//go:generate go run mksyscall_windows.go -output zvhd.go vhd.go
-
-//sys createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.CreateVirtualDisk
-//sys openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *uintptr, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.OpenVirtualDisk
-//sys detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) [failretval != 0] = VirtDisk.DetachVirtualDisk
-
-type virtualStorageType struct {
-	DeviceID uint32
-	VendorID [16]byte
-}
-
-const virtualDiskAccessNONE uint32 = 0
-const virtualDiskAccessATTACHRO uint32 = 65536
-const virtualDiskAccessATTACHRW uint32 = 131072
-const virtualDiskAccessDETACH uint32 = 262144
-const virtualDiskAccessGETINFO uint32 = 524288
-const virtualDiskAccessCREATE uint32 = 1048576
-const virtualDiskAccessMETAOPS uint32 = 2097152
-const virtualDiskAccessREAD uint32 = 851968
-const virtualDiskAccessALL uint32 = 4128768
-const virtualDiskAccessWRITABLE uint32 = 3276800
-
-const createVirtualDiskFlagNone uint32 = 0
-const createVirtualDiskFlagFullPhysicalAllocation uint32 = 1
-const createVirtualDiskFlagPreventWritesToSourceDisk uint32 = 2
-const createVirtualDiskFlagDoNotCopyMetadataFromParent uint32 = 4
-
-type version2 struct {
-	UniqueID                 [16]byte // GUID
-	MaximumSize              uint64
-	BlockSizeInBytes         uint32
-	SectorSizeInBytes        uint32
-	ParentPath               *uint16 // string
-	SourcePath               *uint16 // string
-	OpenFlags                uint32
-	ParentVirtualStorageType virtualStorageType
-	SourceVirtualStorageType virtualStorageType
-	ResiliencyGUID           [16]byte // GUID
-}
-
-type createVirtualDiskParameters struct {
-	Version  uint32 // Must always be set to 2
-	Version2 version2
-}
-
-// CreateVhdx will create a simple vhdx file at the given path using default values.
-func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error {
-	var defaultType virtualStorageType
-
-	parameters := createVirtualDiskParameters{
-		Version: 2,
-		Version2: version2{
-			MaximumSize:      uint64(maxSizeInGb) * 1024 * 1024 * 1024,
-			BlockSizeInBytes: blockSizeInMb * 1024 * 1024,
-		},
-	}
-
-	var handle syscall.Handle
-
-	if err := createVirtualDisk(
-		&defaultType,
-		path,
-		virtualDiskAccessNONE,
-		nil,
-		createVirtualDiskFlagNone,
-		0,
-		&parameters,
-		nil,
-		&handle); err != nil {
-		return err
-	}
-
-	if err := syscall.CloseHandle(handle); err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// DetachVhd detaches a VHD attached at the given path.
-func DetachVhd(path string) error {
-	var (
-		defaultType virtualStorageType
-		handle      syscall.Handle
-	)
-
-	if err := openVirtualDisk(
-		&defaultType,
-		path,
-		virtualDiskAccessDETACH,
-		0,
-		nil,
-		&handle); err != nil {
-		return err
-	}
-	defer syscall.CloseHandle(handle)
-
-	if err := detachVirtualDisk(handle, 0, 0); err != nil {
-		return err
-	}
-	return nil
-}

+ 0 - 99
vendor/github.com/Microsoft/go-winio/vhd/zvhd.go

@@ -1,99 +0,0 @@
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
-
-package vhd
-
-import (
-	"syscall"
-	"unsafe"
-
-	"golang.org/x/sys/windows"
-)
-
-var _ unsafe.Pointer
-
-// Do the interface allocations only once for common
-// Errno values.
-const (
-	errnoERROR_IO_PENDING = 997
-)
-
-var (
-	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
-)
-
-// errnoErr returns common boxed Errno values, to prevent
-// allocations at runtime.
-func errnoErr(e syscall.Errno) error {
-	switch e {
-	case 0:
-		return nil
-	case errnoERROR_IO_PENDING:
-		return errERROR_IO_PENDING
-	}
-	// TODO: add more here, after collecting data on the common
-	// error values see on Windows. (perhaps when running
-	// all.bat?)
-	return e
-}
-
-var (
-	modVirtDisk = windows.NewLazySystemDLL("VirtDisk.dll")
-
-	procCreateVirtualDisk = modVirtDisk.NewProc("CreateVirtualDisk")
-	procOpenVirtualDisk   = modVirtDisk.NewProc("OpenVirtualDisk")
-	procDetachVirtualDisk = modVirtDisk.NewProc("DetachVirtualDisk")
-)
-
-func createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) {
-	var _p0 *uint16
-	_p0, err = syscall.UTF16PtrFromString(path)
-	if err != nil {
-		return
-	}
-	return _createVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, securityDescriptor, flags, providerSpecificFlags, parameters, o, handle)
-}
-
-func _createVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) {
-	r1, _, e1 := syscall.Syscall9(procCreateVirtualDisk.Addr(), 9, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(unsafe.Pointer(securityDescriptor)), uintptr(flags), uintptr(providerSpecificFlags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(handle)))
-	if r1 != 0 {
-		if e1 != 0 {
-			err = errnoErr(e1)
-		} else {
-			err = syscall.EINVAL
-		}
-	}
-	return
-}
-
-func openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *uintptr, handle *syscall.Handle) (err error) {
-	var _p0 *uint16
-	_p0, err = syscall.UTF16PtrFromString(path)
-	if err != nil {
-		return
-	}
-	return _openVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, flags, parameters, handle)
-}
-
-func _openVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, flags uint32, parameters *uintptr, handle *syscall.Handle) (err error) {
-	r1, _, e1 := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(flags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle)))
-	if r1 != 0 {
-		if e1 != 0 {
-			err = errnoErr(e1)
-		} else {
-			err = syscall.EINVAL
-		}
-	}
-	return
-}
-
-func detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) {
-	r1, _, e1 := syscall.Syscall(procDetachVirtualDisk.Addr(), 3, uintptr(handle), uintptr(flags), uintptr(providerSpecificFlags))
-	if r1 != 0 {
-		if e1 != 0 {
-			err = errnoErr(e1)
-		} else {
-			err = syscall.EINVAL
-		}
-	}
-	return
-}

+ 0 - 138
vendor/github.com/Microsoft/go-winio/wim/decompress.go

@@ -1,138 +0,0 @@
-package wim
-
-import (
-	"encoding/binary"
-	"io"
-	"io/ioutil"
-
-	"github.com/Microsoft/go-winio/wim/lzx"
-)
-
-const chunkSize = 32768 // Compressed resource chunk size
-
-type compressedReader struct {
-	r            *io.SectionReader
-	d            io.ReadCloser
-	chunks       []int64
-	curChunk     int
-	originalSize int64
-}
-
-func newCompressedReader(r *io.SectionReader, originalSize int64, offset int64) (*compressedReader, error) {
-	nchunks := (originalSize + chunkSize - 1) / chunkSize
-	var base int64
-	chunks := make([]int64, nchunks)
-	if originalSize <= 0xffffffff {
-		// 32-bit chunk offsets
-		base = (nchunks - 1) * 4
-		chunks32 := make([]uint32, nchunks-1)
-		err := binary.Read(r, binary.LittleEndian, chunks32)
-		if err != nil {
-			return nil, err
-		}
-		for i, n := range chunks32 {
-			chunks[i+1] = int64(n)
-		}
-
-	} else {
-		// 64-bit chunk offsets
-		base = (nchunks - 1) * 8
-		err := binary.Read(r, binary.LittleEndian, chunks[1:])
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	for i, c := range chunks {
-		chunks[i] = c + base
-	}
-
-	cr := &compressedReader{
-		r:            r,
-		chunks:       chunks,
-		originalSize: originalSize,
-	}
-
-	err := cr.reset(int(offset / chunkSize))
-	if err != nil {
-		return nil, err
-	}
-
-	suboff := offset % chunkSize
-	if suboff != 0 {
-		_, err := io.CopyN(ioutil.Discard, cr.d, suboff)
-		if err != nil {
-			return nil, err
-		}
-	}
-	return cr, nil
-}
-
-func (r *compressedReader) chunkOffset(n int) int64 {
-	if n == len(r.chunks) {
-		return r.r.Size()
-	}
-	return r.chunks[n]
-}
-
-func (r *compressedReader) chunkSize(n int) int {
-	return int(r.chunkOffset(n+1) - r.chunkOffset(n))
-}
-
-func (r *compressedReader) uncompressedSize(n int) int {
-	if n < len(r.chunks)-1 {
-		return chunkSize
-	}
-	size := int(r.originalSize % chunkSize)
-	if size == 0 {
-		size = chunkSize
-	}
-	return size
-}
-
-func (r *compressedReader) reset(n int) error {
-	if n >= len(r.chunks) {
-		return io.EOF
-	}
-	if r.d != nil {
-		r.d.Close()
-	}
-	r.curChunk = n
-	size := r.chunkSize(n)
-	uncompressedSize := r.uncompressedSize(n)
-	section := io.NewSectionReader(r.r, r.chunkOffset(n), int64(size))
-	if size != uncompressedSize {
-		d, err := lzx.NewReader(section, uncompressedSize)
-		if err != nil {
-			return err
-		}
-		r.d = d
-	} else {
-		r.d = ioutil.NopCloser(section)
-	}
-
-	return nil
-}
-
-func (r *compressedReader) Read(b []byte) (int, error) {
-	for {
-		n, err := r.d.Read(b)
-		if err != io.EOF {
-			return n, err
-		}
-
-		err = r.reset(r.curChunk + 1)
-		if err != nil {
-			return n, err
-		}
-	}
-}
-
-func (r *compressedReader) Close() error {
-	var err error
-	if r.d != nil {
-		err = r.d.Close()
-		r.d = nil
-	}
-	return err
-}

+ 0 - 606
vendor/github.com/Microsoft/go-winio/wim/lzx/lzx.go

@@ -1,606 +0,0 @@
-// Package lzx implements a decompressor for the the WIM variant of the
-// LZX compression algorithm.
-//
-// The LZX algorithm is an earlier variant of LZX DELTA, which is documented
-// at https://msdn.microsoft.com/en-us/library/cc483133(v=exchg.80).aspx.
-package lzx
-
-import (
-	"bytes"
-	"encoding/binary"
-	"errors"
-	"io"
-)
-
-const (
-	maincodecount = 496
-	maincodesplit = 256
-	lencodecount  = 249
-	lenshift      = 9
-	codemask      = 0x1ff
-	tablebits     = 9
-	tablesize     = 1 << tablebits
-
-	maxBlockSize = 32768
-	windowSize   = 32768
-
-	maxTreePathLen = 16
-
-	e8filesize  = 12000000
-	maxe8offset = 0x3fffffff
-
-	verbatimBlock      = 1
-	alignedOffsetBlock = 2
-	uncompressedBlock  = 3
-)
-
-var footerBits = [...]byte{
-	0, 0, 0, 0, 1, 1, 2, 2,
-	3, 3, 4, 4, 5, 5, 6, 6,
-	7, 7, 8, 8, 9, 9, 10, 10,
-	11, 11, 12, 12, 13, 13, 14,
-}
-
-var basePosition = [...]uint16{
-	0, 1, 2, 3, 4, 6, 8, 12,
-	16, 24, 32, 48, 64, 96, 128, 192,
-	256, 384, 512, 768, 1024, 1536, 2048, 3072,
-	4096, 6144, 8192, 12288, 16384, 24576, 32768,
-}
-
-var (
-	errCorrupt = errors.New("LZX data corrupt")
-)
-
-// Reader is an interface used by the decompressor to access
-// the input stream. If the provided io.Reader does not implement
-// Reader, then a bufio.Reader is used.
-type Reader interface {
-	io.Reader
-	io.ByteReader
-}
-
-type decompressor struct {
-	r            io.Reader
-	err          error
-	unaligned    bool
-	nbits        byte
-	c            uint32
-	lru          [3]uint16
-	uncompressed int
-	windowReader *bytes.Reader
-	mainlens     [maincodecount]byte
-	lenlens      [lencodecount]byte
-	window       [windowSize]byte
-	b            []byte
-	bv           int
-	bo           int
-}
-
-//go:noinline
-func (f *decompressor) fail(err error) {
-	if f.err == nil {
-		f.err = err
-	}
-	f.bo = 0
-	f.bv = 0
-}
-
-func (f *decompressor) ensureAtLeast(n int) error {
-	if f.bv-f.bo >= n {
-		return nil
-	}
-
-	if f.err != nil {
-		return f.err
-	}
-
-	if f.bv != f.bo {
-		copy(f.b[:f.bv-f.bo], f.b[f.bo:f.bv])
-	}
-	n, err := io.ReadAtLeast(f.r, f.b[f.bv-f.bo:], n)
-	if err != nil {
-		if err == io.EOF {
-			err = io.ErrUnexpectedEOF
-		} else {
-			f.fail(err)
-		}
-		return err
-	}
-	f.bv = f.bv - f.bo + n
-	f.bo = 0
-	return nil
-}
-
-// feed retrieves another 16-bit word from the stream and consumes
-// it into f.c. It returns false if there are no more bytes available.
-// Otherwise, on error, it sets f.err.
-func (f *decompressor) feed() bool {
-	err := f.ensureAtLeast(2)
-	if err != nil {
-		if err == io.ErrUnexpectedEOF {
-			return false
-		}
-	}
-	f.c |= (uint32(f.b[f.bo+1])<<8 | uint32(f.b[f.bo])) << (16 - f.nbits)
-	f.nbits += 16
-	f.bo += 2
-	return true
-}
-
-// getBits retrieves the next n bits from the byte stream. n
-// must be <= 16. It sets f.err on error.
-func (f *decompressor) getBits(n byte) uint16 {
-	if f.nbits < n {
-		if !f.feed() {
-			f.fail(io.ErrUnexpectedEOF)
-		}
-	}
-	c := uint16(f.c >> (32 - n))
-	f.c <<= n
-	f.nbits -= n
-	return c
-}
-
-type huffman struct {
-	extra   [][]uint16
-	maxbits byte
-	table   [tablesize]uint16
-}
-
-// buildTable builds a huffman decoding table from a slice of code lengths,
-// one per code, in order. Each code length must be <= maxTreePathLen.
-// See https://en.wikipedia.org/wiki/Canonical_Huffman_code.
-func buildTable(codelens []byte) *huffman {
-	// Determine the number of codes of each length, and the
-	// maximum length.
-	var count [maxTreePathLen + 1]uint
-	var max byte
-	for _, cl := range codelens {
-		count[cl]++
-		if max < cl {
-			max = cl
-		}
-	}
-
-	if max == 0 {
-		return &huffman{}
-	}
-
-	// Determine the first code of each length.
-	var first [maxTreePathLen + 1]uint
-	code := uint(0)
-	for i := byte(1); i <= max; i++ {
-		code <<= 1
-		first[i] = code
-		code += count[i]
-	}
-
-	if code != 1<<max {
-		return nil
-	}
-
-	// Build a table for code lookup. For code sizes < max,
-	// put all possible suffixes for the code into the table, too.
-	// For max > tablebits, split long codes into additional tables
-	// of suffixes of max-tablebits length.
-	h := &huffman{maxbits: max}
-	if max > tablebits {
-		core := first[tablebits+1] / 2 // Number of codes that fit without extra tables
-		nextra := 1<<tablebits - core  // Number of extra entries
-		h.extra = make([][]uint16, nextra)
-		for code := core; code < 1<<tablebits; code++ {
-			h.table[code] = uint16(code - core)
-			h.extra[code-core] = make([]uint16, 1<<(max-tablebits))
-		}
-	}
-
-	for i, cl := range codelens {
-		if cl != 0 {
-			code := first[cl]
-			first[cl]++
-			v := uint16(cl)<<lenshift | uint16(i)
-			if cl <= tablebits {
-				extendedCode := code << (tablebits - cl)
-				for j := uint(0); j < 1<<(tablebits-cl); j++ {
-					h.table[extendedCode+j] = v
-				}
-			} else {
-				prefix := code >> (cl - tablebits)
-				suffix := code & (1<<(cl-tablebits) - 1)
-				extendedCode := suffix << (max - cl)
-				for j := uint(0); j < 1<<(max-cl); j++ {
-					h.extra[h.table[prefix]][extendedCode+j] = v
-				}
-			}
-		}
-	}
-
-	return h
-}
-
-// getCode retrieves the next code using the provided
-// huffman tree. It sets f.err on error.
-func (f *decompressor) getCode(h *huffman) uint16 {
-	if h.maxbits > 0 {
-		if f.nbits < maxTreePathLen {
-			f.feed()
-		}
-
-		// For codes with length < tablebits, it doesn't matter
-		// what the remainder of the bits used for table lookup
-		// are, since entries with all possible suffixes were
-		// added to the table.
-		c := h.table[f.c>>(32-tablebits)]
-		if c >= 1<<lenshift {
-			// The code is already in c.
-		} else {
-			c = h.extra[c][f.c<<tablebits>>(32-(h.maxbits-tablebits))]
-		}
-
-		n := byte(c >> lenshift)
-		if f.nbits >= n {
-			// Only consume the length of the code, not the maximum
-			// code length.
-			f.c <<= n
-			f.nbits -= n
-			return c & codemask
-		}
-
-		f.fail(io.ErrUnexpectedEOF)
-		return 0
-	}
-
-	// This is an empty tree. It should not be used.
-	f.fail(errCorrupt)
-	return 0
-}
-
-// readTree updates the huffman tree path lengths in lens by
-// reading and decoding lengths from the byte stream. lens
-// should be prepopulated with the previous block's tree's path
-// lengths. For the first block, lens should be zero.
-func (f *decompressor) readTree(lens []byte) error {
-	// Get the pre-tree for the main tree.
-	var pretreeLen [20]byte
-	for i := range pretreeLen {
-		pretreeLen[i] = byte(f.getBits(4))
-	}
-	if f.err != nil {
-		return f.err
-	}
-	h := buildTable(pretreeLen[:])
-
-	// The lengths are encoded as a series of huffman codes
-	// encoded by the pre-tree.
-	for i := 0; i < len(lens); {
-		c := byte(f.getCode(h))
-		if f.err != nil {
-			return f.err
-		}
-		switch {
-		case c <= 16: // length is delta from previous length
-			lens[i] = (lens[i] + 17 - c) % 17
-			i++
-		case c == 17: // next n + 4 lengths are zero
-			zeroes := int(f.getBits(4)) + 4
-			if i+zeroes > len(lens) {
-				return errCorrupt
-			}
-			for j := 0; j < zeroes; j++ {
-				lens[i+j] = 0
-			}
-			i += zeroes
-		case c == 18: // next n + 20 lengths are zero
-			zeroes := int(f.getBits(5)) + 20
-			if i+zeroes > len(lens) {
-				return errCorrupt
-			}
-			for j := 0; j < zeroes; j++ {
-				lens[i+j] = 0
-			}
-			i += zeroes
-		case c == 19: // next n + 4 lengths all have the same value
-			same := int(f.getBits(1)) + 4
-			if i+same > len(lens) {
-				return errCorrupt
-			}
-			c = byte(f.getCode(h))
-			if c > 16 {
-				return errCorrupt
-			}
-			l := (lens[i] + 17 - c) % 17
-			for j := 0; j < same; j++ {
-				lens[i+j] = l
-			}
-			i += same
-		default:
-			return errCorrupt
-		}
-	}
-
-	if f.err != nil {
-		return f.err
-	}
-	return nil
-}
-
-func (f *decompressor) readBlockHeader() (byte, uint16, error) {
-	// If the previous block was an unaligned uncompressed block, restore
-	// 2-byte alignment.
-	if f.unaligned {
-		err := f.ensureAtLeast(1)
-		if err != nil {
-			return 0, 0, err
-		}
-		f.bo++
-		f.unaligned = false
-	}
-
-	blockType := f.getBits(3)
-	full := f.getBits(1)
-	var blockSize uint16
-	if full != 0 {
-		blockSize = maxBlockSize
-	} else {
-		blockSize = f.getBits(16)
-		if blockSize > maxBlockSize {
-			return 0, 0, errCorrupt
-		}
-	}
-
-	if f.err != nil {
-		return 0, 0, f.err
-	}
-
-	switch blockType {
-	case verbatimBlock, alignedOffsetBlock:
-		// The caller will read the huffman trees.
-	case uncompressedBlock:
-		if f.nbits > 16 {
-			panic("impossible: more than one 16-bit word remains")
-		}
-
-		// Drop the remaining bits in the current 16-bit word
-		// If there are no bits left, discard a full 16-bit word.
-		n := f.nbits
-		if n == 0 {
-			n = 16
-		}
-
-		f.getBits(n)
-
-		// Read the LRU values for the next block.
-		err := f.ensureAtLeast(12)
-		if err != nil {
-			return 0, 0, err
-		}
-
-		f.lru[0] = uint16(binary.LittleEndian.Uint32(f.b[f.bo : f.bo+4]))
-		f.lru[1] = uint16(binary.LittleEndian.Uint32(f.b[f.bo+4 : f.bo+8]))
-		f.lru[2] = uint16(binary.LittleEndian.Uint32(f.b[f.bo+8 : f.bo+12]))
-		f.bo += 12
-
-	default:
-		return 0, 0, errCorrupt
-	}
-
-	return byte(blockType), blockSize, nil
-}
-
-// readTrees reads the two or three huffman trees for the current block.
-// readAligned specifies whether to read the aligned offset tree.
-func (f *decompressor) readTrees(readAligned bool) (main *huffman, length *huffman, aligned *huffman, err error) {
-	// Aligned offset blocks start with a small aligned offset tree.
-	if readAligned {
-		var alignedLen [8]byte
-		for i := range alignedLen {
-			alignedLen[i] = byte(f.getBits(3))
-		}
-		aligned = buildTable(alignedLen[:])
-		if aligned == nil {
-			err = errors.New("corrupt")
-			return
-		}
-	}
-
-	// The main tree is encoded in two parts.
-	err = f.readTree(f.mainlens[:maincodesplit])
-	if err != nil {
-		return
-	}
-	err = f.readTree(f.mainlens[maincodesplit:])
-	if err != nil {
-		return
-	}
-
-	main = buildTable(f.mainlens[:])
-	if main == nil {
-		err = errors.New("corrupt")
-		return
-	}
-
-	// The length tree is encoding in a single part.
-	err = f.readTree(f.lenlens[:])
-	if err != nil {
-		return
-	}
-
-	length = buildTable(f.lenlens[:])
-	if length == nil {
-		err = errors.New("corrupt")
-		return
-	}
-
-	err = f.err
-	return
-}
-
-// readCompressedBlock decodes a compressed block, writing into the window
-// starting at start and ending at end, and using the provided huffman trees.
-func (f *decompressor) readCompressedBlock(start, end uint16, hmain, hlength, haligned *huffman) (int, error) {
-	i := start
-	for i < end {
-		main := f.getCode(hmain)
-		if f.err != nil {
-			break
-		}
-		if main < 256 {
-			// Literal byte.
-			f.window[i] = byte(main)
-			i++
-			continue
-		}
-
-		// This is a match backward in the window. Determine
-		// the offset and dlength.
-		matchlen := (main - 256) % 8
-		slot := (main - 256) / 8
-
-		// The length is either the low bits of the code,
-		// or if this is 7, is encoded with the length tree.
-		if matchlen == 7 {
-			matchlen += f.getCode(hlength)
-		}
-		matchlen += 2
-
-		var matchoffset uint16
-		if slot < 3 {
-			// The offset is one of the LRU values.
-			matchoffset = f.lru[slot]
-			f.lru[slot] = f.lru[0]
-			f.lru[0] = matchoffset
-		} else {
-			// The offset is encoded as a combination of the
-			// slot and more bits from the bit stream.
-			offsetbits := footerBits[slot]
-			var verbatimbits, alignedbits uint16
-			if offsetbits > 0 {
-				if haligned != nil && offsetbits >= 3 {
-					// This is an aligned offset block. Combine
-					// the bits written verbatim with the aligned
-					// offset tree code.
-					verbatimbits = f.getBits(offsetbits-3) * 8
-					alignedbits = f.getCode(haligned)
-				} else {
-					// There are no aligned offset bits to read,
-					// only verbatim bits.
-					verbatimbits = f.getBits(offsetbits)
-					alignedbits = 0
-				}
-			}
-			matchoffset = basePosition[slot] + verbatimbits + alignedbits - 2
-			// Update the LRU cache.
-			f.lru[2] = f.lru[1]
-			f.lru[1] = f.lru[0]
-			f.lru[0] = matchoffset
-		}
-
-		if matchoffset <= i && matchlen <= end-i {
-			copyend := i + matchlen
-			for ; i < copyend; i++ {
-				f.window[i] = f.window[i-matchoffset]
-			}
-		} else {
-			f.fail(errCorrupt)
-			break
-		}
-	}
-	return int(i - start), f.err
-}
-
-// readBlock decodes the current block and returns the number of uncompressed bytes.
-func (f *decompressor) readBlock(start uint16) (int, error) {
-	blockType, size, err := f.readBlockHeader()
-	if err != nil {
-		return 0, err
-	}
-
-	if blockType == uncompressedBlock {
-		if size%2 == 1 {
-			// Remember to realign the byte stream at the next block.
-			f.unaligned = true
-		}
-		copied := 0
-		if f.bo < f.bv {
-			copied = int(size)
-			s := int(start)
-			if copied > f.bv-f.bo {
-				copied = f.bv - f.bo
-			}
-			copy(f.window[s:s+copied], f.b[f.bo:f.bo+copied])
-			f.bo += copied
-		}
-		n, err := io.ReadFull(f.r, f.window[start+uint16(copied):start+size])
-		return copied + n, err
-	}
-
-	hmain, hlength, haligned, err := f.readTrees(blockType == alignedOffsetBlock)
-	if err != nil {
-		return 0, err
-	}
-
-	return f.readCompressedBlock(start, start+size, hmain, hlength, haligned)
-}
-
-// decodeE8 reverses the 0xe8 x86 instruction encoding that was performed
-// to the uncompressed data before it was compressed.
-func decodeE8(b []byte, off int64) {
-	if off > maxe8offset || len(b) < 10 {
-		return
-	}
-	for i := 0; i < len(b)-10; i++ {
-		if b[i] == 0xe8 {
-			currentPtr := int32(off) + int32(i)
-			abs := int32(binary.LittleEndian.Uint32(b[i+1 : i+5]))
-			if abs >= -currentPtr && abs < e8filesize {
-				var rel int32
-				if abs >= 0 {
-					rel = abs - currentPtr
-				} else {
-					rel = abs + e8filesize
-				}
-				binary.LittleEndian.PutUint32(b[i+1:i+5], uint32(rel))
-			}
-			i += 4
-		}
-	}
-}
-
-func (f *decompressor) Read(b []byte) (int, error) {
-	// Read and uncompress everything.
-	if f.windowReader == nil {
-		n := 0
-		for n < f.uncompressed {
-			k, err := f.readBlock(uint16(n))
-			if err != nil {
-				return 0, err
-			}
-			n += k
-		}
-		decodeE8(f.window[:f.uncompressed], 0)
-		f.windowReader = bytes.NewReader(f.window[:f.uncompressed])
-	}
-
-	// Just read directly from the window.
-	return f.windowReader.Read(b)
-}
-
-func (f *decompressor) Close() error {
-	return nil
-}
-
-// NewReader returns a new io.ReadCloser that decompresses a
-// WIM LZX stream until uncompressedSize bytes have been returned.
-func NewReader(r io.Reader, uncompressedSize int) (io.ReadCloser, error) {
-	if uncompressedSize > windowSize {
-		return nil, errors.New("uncompressed size is limited to 32KB")
-	}
-	f := &decompressor{
-		lru:          [3]uint16{1, 1, 1},
-		uncompressed: uncompressedSize,
-		b:            make([]byte, 4096),
-		r:            r,
-	}
-	return f, nil
-}

+ 0 - 51
vendor/github.com/Microsoft/go-winio/wim/validate/validate.go

@@ -1,51 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-	"os"
-
-	"github.com/Microsoft/go-winio/wim"
-)
-
-func main() {
-	flag.Parse()
-	f, err := os.Open(flag.Arg(0))
-	if err != nil {
-		panic(err)
-	}
-
-	w, err := wim.NewReader(f)
-	if err != nil {
-		panic(err)
-
-	}
-
-	fmt.Printf("%#v\n%#v\n", w.Image[0], w.Image[0].Windows)
-
-	dir, err := w.Image[0].Open()
-	if err != nil {
-		panic(err)
-	}
-
-	err = recur(dir)
-	if err != nil {
-		panic(err)
-	}
-}
-
-func recur(d *wim.File) error {
-	files, err := d.Readdir()
-	if err != nil {
-		return fmt.Errorf("%s: %s", d.Name, err)
-	}
-	for _, f := range files {
-		if f.IsDir() {
-			err = recur(f)
-			if err != nil {
-				return fmt.Errorf("%s: %s", f.Name, err)
-			}
-		}
-	}
-	return nil
-}

+ 0 - 866
vendor/github.com/Microsoft/go-winio/wim/wim.go

@@ -1,866 +0,0 @@
-// Package wim implements a WIM file parser.
-//
-// WIM files are used to distribute Windows file system and container images.
-// They are documented at https://msdn.microsoft.com/en-us/library/windows/desktop/dd861280.aspx.
-package wim
-
-import (
-	"bytes"
-	"crypto/sha1"
-	"encoding/binary"
-	"encoding/xml"
-	"errors"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"strconv"
-	"sync"
-	"time"
-	"unicode/utf16"
-)
-
-// File attribute constants from Windows.
-const (
-	FILE_ATTRIBUTE_READONLY            = 0x00000001
-	FILE_ATTRIBUTE_HIDDEN              = 0x00000002
-	FILE_ATTRIBUTE_SYSTEM              = 0x00000004
-	FILE_ATTRIBUTE_DIRECTORY           = 0x00000010
-	FILE_ATTRIBUTE_ARCHIVE             = 0x00000020
-	FILE_ATTRIBUTE_DEVICE              = 0x00000040
-	FILE_ATTRIBUTE_NORMAL              = 0x00000080
-	FILE_ATTRIBUTE_TEMPORARY           = 0x00000100
-	FILE_ATTRIBUTE_SPARSE_FILE         = 0x00000200
-	FILE_ATTRIBUTE_REPARSE_POINT       = 0x00000400
-	FILE_ATTRIBUTE_COMPRESSED          = 0x00000800
-	FILE_ATTRIBUTE_OFFLINE             = 0x00001000
-	FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
-	FILE_ATTRIBUTE_ENCRYPTED           = 0x00004000
-	FILE_ATTRIBUTE_INTEGRITY_STREAM    = 0x00008000
-	FILE_ATTRIBUTE_VIRTUAL             = 0x00010000
-	FILE_ATTRIBUTE_NO_SCRUB_DATA       = 0x00020000
-	FILE_ATTRIBUTE_EA                  = 0x00040000
-)
-
-// Windows processor architectures.
-const (
-	PROCESSOR_ARCHITECTURE_INTEL         = 0
-	PROCESSOR_ARCHITECTURE_MIPS          = 1
-	PROCESSOR_ARCHITECTURE_ALPHA         = 2
-	PROCESSOR_ARCHITECTURE_PPC           = 3
-	PROCESSOR_ARCHITECTURE_SHX           = 4
-	PROCESSOR_ARCHITECTURE_ARM           = 5
-	PROCESSOR_ARCHITECTURE_IA64          = 6
-	PROCESSOR_ARCHITECTURE_ALPHA64       = 7
-	PROCESSOR_ARCHITECTURE_MSIL          = 8
-	PROCESSOR_ARCHITECTURE_AMD64         = 9
-	PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10
-	PROCESSOR_ARCHITECTURE_NEUTRAL       = 11
-	PROCESSOR_ARCHITECTURE_ARM64         = 12
-)
-
-var wimImageTag = [...]byte{'M', 'S', 'W', 'I', 'M', 0, 0, 0}
-
-type guid struct {
-	Data1 uint32
-	Data2 uint16
-	Data3 uint16
-	Data4 [8]byte
-}
-
-func (g guid) String() string {
-	return fmt.Sprintf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", g.Data1, g.Data2, g.Data3, g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3], g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7])
-}
-
-type resourceDescriptor struct {
-	FlagsAndCompressedSize uint64
-	Offset                 int64
-	OriginalSize           int64
-}
-
-type resFlag byte
-
-const (
-	resFlagFree resFlag = 1 << iota
-	resFlagMetadata
-	resFlagCompressed
-	resFlagSpanned
-)
-
-const validate = false
-
-const supportedResFlags = resFlagMetadata | resFlagCompressed
-
-func (r *resourceDescriptor) Flags() resFlag {
-	return resFlag(r.FlagsAndCompressedSize >> 56)
-}
-
-func (r *resourceDescriptor) CompressedSize() int64 {
-	return int64(r.FlagsAndCompressedSize & 0xffffffffffffff)
-}
-
-func (r *resourceDescriptor) String() string {
-	s := fmt.Sprintf("%d bytes at %d", r.CompressedSize(), r.Offset)
-	if r.Flags()&4 != 0 {
-		s += fmt.Sprintf(" (uncompresses to %d)", r.OriginalSize)
-	}
-	return s
-}
-
-// SHA1Hash contains the SHA1 hash of a file or stream.
-type SHA1Hash [20]byte
-
-type streamDescriptor struct {
-	resourceDescriptor
-	PartNumber uint16
-	RefCount   uint32
-	Hash       SHA1Hash
-}
-
-type hdrFlag uint32
-
-const (
-	hdrFlagReserved hdrFlag = 1 << iota
-	hdrFlagCompressed
-	hdrFlagReadOnly
-	hdrFlagSpanned
-	hdrFlagResourceOnly
-	hdrFlagMetadataOnly
-	hdrFlagWriteInProgress
-	hdrFlagRpFix
-)
-
-const (
-	hdrFlagCompressReserved hdrFlag = 1 << (iota + 16)
-	hdrFlagCompressXpress
-	hdrFlagCompressLzx
-)
-
-const supportedHdrFlags = hdrFlagRpFix | hdrFlagReadOnly | hdrFlagCompressed | hdrFlagCompressLzx
-
-type wimHeader struct {
-	ImageTag        [8]byte
-	Size            uint32
-	Version         uint32
-	Flags           hdrFlag
-	CompressionSize uint32
-	WIMGuid         guid
-	PartNumber      uint16
-	TotalParts      uint16
-	ImageCount      uint32
-	OffsetTable     resourceDescriptor
-	XMLData         resourceDescriptor
-	BootMetadata    resourceDescriptor
-	BootIndex       uint32
-	Padding         uint32
-	Integrity       resourceDescriptor
-	Unused          [60]byte
-}
-
-type securityblockDisk struct {
-	TotalLength uint32
-	NumEntries  uint32
-}
-
-const securityblockDiskSize = 8
-
-type direntry struct {
-	Attributes       uint32
-	SecurityID       uint32
-	SubdirOffset     int64
-	Unused1, Unused2 int64
-	CreationTime     Filetime
-	LastAccessTime   Filetime
-	LastWriteTime    Filetime
-	Hash             SHA1Hash
-	Padding          uint32
-	ReparseHardLink  int64
-	StreamCount      uint16
-	ShortNameLength  uint16
-	FileNameLength   uint16
-}
-
-var direntrySize = int64(binary.Size(direntry{}) + 8) // includes an 8-byte length prefix
-
-type streamentry struct {
-	Unused     int64
-	Hash       SHA1Hash
-	NameLength int16
-}
-
-var streamentrySize = int64(binary.Size(streamentry{}) + 8) // includes an 8-byte length prefix
-
-// Filetime represents a Windows time.
-type Filetime struct {
-	LowDateTime  uint32
-	HighDateTime uint32
-}
-
-// Time returns the time as time.Time.
-func (ft *Filetime) Time() time.Time {
-	// 100-nanosecond intervals since January 1, 1601
-	nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
-	// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
-	nsec -= 116444736000000000
-	// convert into nanoseconds
-	nsec *= 100
-	return time.Unix(0, nsec)
-}
-
-// UnmarshalXML unmarshals the time from a WIM XML blob.
-func (ft *Filetime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
-	type time struct {
-		Low  string `xml:"LOWPART"`
-		High string `xml:"HIGHPART"`
-	}
-	var t time
-	err := d.DecodeElement(&t, &start)
-	if err != nil {
-		return err
-	}
-
-	low, err := strconv.ParseUint(t.Low, 0, 32)
-	if err != nil {
-		return err
-	}
-	high, err := strconv.ParseUint(t.High, 0, 32)
-	if err != nil {
-		return err
-	}
-
-	ft.LowDateTime = uint32(low)
-	ft.HighDateTime = uint32(high)
-	return nil
-}
-
-type info struct {
-	Image []ImageInfo `xml:"IMAGE"`
-}
-
-// ImageInfo contains information about the image.
-type ImageInfo struct {
-	Name         string       `xml:"NAME"`
-	Index        int          `xml:"INDEX,attr"`
-	CreationTime Filetime     `xml:"CREATIONTIME"`
-	ModTime      Filetime     `xml:"LASTMODIFICATIONTIME"`
-	Windows      *WindowsInfo `xml:"WINDOWS"`
-}
-
-// WindowsInfo contains information about the Windows installation in the image.
-type WindowsInfo struct {
-	Arch             byte     `xml:"ARCH"`
-	ProductName      string   `xml:"PRODUCTNAME"`
-	EditionID        string   `xml:"EDITIONID"`
-	InstallationType string   `xml:"INSTALLATIONTYPE"`
-	ProductType      string   `xml:"PRODUCTTYPE"`
-	Languages        []string `xml:"LANGUAGES>LANGUAGE"`
-	DefaultLanguage  string   `xml:"LANGUAGES>DEFAULT"`
-	Version          Version  `xml:"VERSION"`
-	SystemRoot       string   `xml:"SYSTEMROOT"`
-}
-
-// Version represents a Windows build version.
-type Version struct {
-	Major   int `xml:"MAJOR"`
-	Minor   int `xml:"MINOR"`
-	Build   int `xml:"BUILD"`
-	SPBuild int `xml:"SPBUILD"`
-	SPLevel int `xml:"SPLEVEL"`
-}
-
-// ParseError is returned when the WIM cannot be parsed.
-type ParseError struct {
-	Oper string
-	Path string
-	Err  error
-}
-
-func (e *ParseError) Error() string {
-	if e.Path == "" {
-		return "WIM parse error at " + e.Oper + ": " + e.Err.Error()
-	}
-	return fmt.Sprintf("WIM parse error: %s %s: %s", e.Oper, e.Path, e.Err.Error())
-}
-
-// Reader provides functions to read a WIM file.
-type Reader struct {
-	hdr      wimHeader
-	r        io.ReaderAt
-	fileData map[SHA1Hash]resourceDescriptor
-
-	XMLInfo string   // The XML information about the WIM.
-	Image   []*Image // The WIM's images.
-}
-
-// Image represents an image within a WIM file.
-type Image struct {
-	wim        *Reader
-	offset     resourceDescriptor
-	sds        [][]byte
-	rootOffset int64
-	r          io.ReadCloser
-	curOffset  int64
-	m          sync.Mutex
-
-	ImageInfo
-}
-
-// StreamHeader contains alternate data stream metadata.
-type StreamHeader struct {
-	Name string
-	Hash SHA1Hash
-	Size int64
-}
-
-// Stream represents an alternate data stream or reparse point data stream.
-type Stream struct {
-	StreamHeader
-	wim    *Reader
-	offset resourceDescriptor
-}
-
-// FileHeader contains file metadata.
-type FileHeader struct {
-	Name               string
-	ShortName          string
-	Attributes         uint32
-	SecurityDescriptor []byte
-	CreationTime       Filetime
-	LastAccessTime     Filetime
-	LastWriteTime      Filetime
-	Hash               SHA1Hash
-	Size               int64
-	LinkID             int64
-	ReparseTag         uint32
-	ReparseReserved    uint32
-}
-
-// File represents a file or directory in a WIM image.
-type File struct {
-	FileHeader
-	Streams      []*Stream
-	offset       resourceDescriptor
-	img          *Image
-	subdirOffset int64
-}
-
-// NewReader returns a Reader that can be used to read WIM file data.
-func NewReader(f io.ReaderAt) (*Reader, error) {
-	r := &Reader{r: f}
-	section := io.NewSectionReader(f, 0, 0xffff)
-	err := binary.Read(section, binary.LittleEndian, &r.hdr)
-	if err != nil {
-		return nil, err
-	}
-
-	if r.hdr.ImageTag != wimImageTag {
-		return nil, &ParseError{Oper: "image tag", Err: errors.New("not a WIM file")}
-	}
-
-	if r.hdr.Flags&^supportedHdrFlags != 0 {
-		return nil, fmt.Errorf("unsupported WIM flags %x", r.hdr.Flags&^supportedHdrFlags)
-	}
-
-	if r.hdr.CompressionSize != 0x8000 {
-		return nil, fmt.Errorf("unsupported compression size %d", r.hdr.CompressionSize)
-	}
-
-	if r.hdr.TotalParts != 1 {
-		return nil, errors.New("multi-part WIM not supported")
-	}
-
-	fileData, images, err := r.readOffsetTable(&r.hdr.OffsetTable)
-	if err != nil {
-		return nil, err
-	}
-
-	xmlinfo, err := r.readXML()
-	if err != nil {
-		return nil, err
-	}
-
-	var info info
-	err = xml.Unmarshal([]byte(xmlinfo), &info)
-	if err != nil {
-		return nil, &ParseError{Oper: "XML info", Err: err}
-	}
-
-	for i, img := range images {
-		for _, imgInfo := range info.Image {
-			if imgInfo.Index == i+1 {
-				img.ImageInfo = imgInfo
-				break
-			}
-		}
-	}
-
-	r.fileData = fileData
-	r.Image = images
-	r.XMLInfo = xmlinfo
-	return r, nil
-}
-
-// Close releases resources associated with the Reader.
-func (r *Reader) Close() error {
-	for _, img := range r.Image {
-		img.reset()
-	}
-	return nil
-}
-
-func (r *Reader) resourceReader(hdr *resourceDescriptor) (io.ReadCloser, error) {
-	return r.resourceReaderWithOffset(hdr, 0)
-}
-
-func (r *Reader) resourceReaderWithOffset(hdr *resourceDescriptor, offset int64) (io.ReadCloser, error) {
-	var sr io.ReadCloser
-	section := io.NewSectionReader(r.r, hdr.Offset, hdr.CompressedSize())
-	if hdr.Flags()&resFlagCompressed == 0 {
-		section.Seek(offset, 0)
-		sr = ioutil.NopCloser(section)
-	} else {
-		cr, err := newCompressedReader(section, hdr.OriginalSize, offset)
-		if err != nil {
-			return nil, err
-		}
-		sr = cr
-	}
-
-	return sr, nil
-}
-
-func (r *Reader) readResource(hdr *resourceDescriptor) ([]byte, error) {
-	rsrc, err := r.resourceReader(hdr)
-	if err != nil {
-		return nil, err
-	}
-	defer rsrc.Close()
-	return ioutil.ReadAll(rsrc)
-}
-
-func (r *Reader) readXML() (string, error) {
-	if r.hdr.XMLData.CompressedSize() == 0 {
-		return "", nil
-	}
-	rsrc, err := r.resourceReader(&r.hdr.XMLData)
-	if err != nil {
-		return "", err
-	}
-	defer rsrc.Close()
-
-	XMLData := make([]uint16, r.hdr.XMLData.OriginalSize/2)
-	err = binary.Read(rsrc, binary.LittleEndian, XMLData)
-	if err != nil {
-		return "", &ParseError{Oper: "XML data", Err: err}
-	}
-
-	// The BOM will always indicate little-endian UTF-16.
-	if XMLData[0] != 0xfeff {
-		return "", &ParseError{Oper: "XML data", Err: errors.New("invalid BOM")}
-	}
-	return string(utf16.Decode(XMLData[1:])), nil
-}
-
-func (r *Reader) readOffsetTable(res *resourceDescriptor) (map[SHA1Hash]resourceDescriptor, []*Image, error) {
-	fileData := make(map[SHA1Hash]resourceDescriptor)
-	var images []*Image
-
-	offsetTable, err := r.readResource(res)
-	if err != nil {
-		return nil, nil, &ParseError{Oper: "offset table", Err: err}
-	}
-
-	br := bytes.NewReader(offsetTable)
-	for i := 0; ; i++ {
-		var res streamDescriptor
-		err := binary.Read(br, binary.LittleEndian, &res)
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			return nil, nil, &ParseError{Oper: "offset table", Err: err}
-		}
-		if res.Flags()&^supportedResFlags != 0 {
-			return nil, nil, &ParseError{Oper: "offset table", Err: errors.New("unsupported resource flag")}
-		}
-
-		// Validation for ad-hoc testing
-		if validate {
-			sec, err := r.resourceReader(&res.resourceDescriptor)
-			if err != nil {
-				panic(fmt.Sprint(i, err))
-			}
-			hash := sha1.New()
-			_, err = io.Copy(hash, sec)
-			sec.Close()
-			if err != nil {
-				panic(fmt.Sprint(i, err))
-			}
-			var cmphash SHA1Hash
-			copy(cmphash[:], hash.Sum(nil))
-			if cmphash != res.Hash {
-				panic(fmt.Sprint(i, "hash mismatch"))
-			}
-		}
-
-		if res.Flags()&resFlagMetadata != 0 {
-			image := &Image{
-				wim:    r,
-				offset: res.resourceDescriptor,
-			}
-			images = append(images, image)
-		} else {
-			fileData[res.Hash] = res.resourceDescriptor
-		}
-	}
-
-	if len(images) != int(r.hdr.ImageCount) {
-		return nil, nil, &ParseError{Oper: "offset table", Err: errors.New("mismatched image count")}
-	}
-
-	return fileData, images, nil
-}
-
-func (r *Reader) readSecurityDescriptors(rsrc io.Reader) (sds [][]byte, n int64, err error) {
-	var secBlock securityblockDisk
-	err = binary.Read(rsrc, binary.LittleEndian, &secBlock)
-	if err != nil {
-		err = &ParseError{Oper: "security table", Err: err}
-		return
-	}
-
-	n += securityblockDiskSize
-
-	secSizes := make([]int64, secBlock.NumEntries)
-	err = binary.Read(rsrc, binary.LittleEndian, &secSizes)
-	if err != nil {
-		err = &ParseError{Oper: "security table sizes", Err: err}
-		return
-	}
-
-	n += int64(secBlock.NumEntries * 8)
-
-	sds = make([][]byte, secBlock.NumEntries)
-	for i, size := range secSizes {
-		sd := make([]byte, size&0xffffffff)
-		_, err = io.ReadFull(rsrc, sd)
-		if err != nil {
-			err = &ParseError{Oper: "security descriptor", Err: err}
-			return
-		}
-		n += int64(len(sd))
-		sds[i] = sd
-	}
-
-	secsize := int64((secBlock.TotalLength + 7) &^ 7)
-	if n > secsize {
-		err = &ParseError{Oper: "security descriptor", Err: errors.New("security descriptor table too small")}
-		return
-	}
-
-	_, err = io.CopyN(ioutil.Discard, rsrc, secsize-n)
-	if err != nil {
-		return
-	}
-
-	n = secsize
-	return
-}
-
-// Open parses the image and returns the root directory.
-func (img *Image) Open() (*File, error) {
-	if img.sds == nil {
-		rsrc, err := img.wim.resourceReaderWithOffset(&img.offset, img.rootOffset)
-		if err != nil {
-			return nil, err
-		}
-		sds, n, err := img.wim.readSecurityDescriptors(rsrc)
-		if err != nil {
-			rsrc.Close()
-			return nil, err
-		}
-		img.sds = sds
-		img.r = rsrc
-		img.rootOffset = n
-		img.curOffset = n
-	}
-
-	f, err := img.readdir(img.rootOffset)
-	if err != nil {
-		return nil, err
-	}
-	if len(f) != 1 {
-		return nil, &ParseError{Oper: "root directory", Err: errors.New("expected exactly 1 root directory entry")}
-	}
-	return f[0], err
-}
-
-func (img *Image) reset() {
-	if img.r != nil {
-		img.r.Close()
-		img.r = nil
-	}
-	img.curOffset = -1
-}
-
-func (img *Image) readdir(offset int64) ([]*File, error) {
-	img.m.Lock()
-	defer img.m.Unlock()
-
-	if offset < img.curOffset || offset > img.curOffset+chunkSize {
-		// Reset to seek backward or to seek forward very far.
-		img.reset()
-	}
-	if img.r == nil {
-		rsrc, err := img.wim.resourceReaderWithOffset(&img.offset, offset)
-		if err != nil {
-			return nil, err
-		}
-		img.r = rsrc
-		img.curOffset = offset
-	}
-	if offset > img.curOffset {
-		_, err := io.CopyN(ioutil.Discard, img.r, offset-img.curOffset)
-		if err != nil {
-			img.reset()
-			if err == io.EOF {
-				err = io.ErrUnexpectedEOF
-			}
-			return nil, err
-		}
-	}
-
-	var entries []*File
-	for {
-		e, n, err := img.readNextEntry(img.r)
-		img.curOffset += n
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			img.reset()
-			return nil, err
-		}
-		entries = append(entries, e)
-	}
-	return entries, nil
-}
-
-func (img *Image) readNextEntry(r io.Reader) (*File, int64, error) {
-	var length int64
-	err := binary.Read(r, binary.LittleEndian, &length)
-	if err != nil {
-		return nil, 0, &ParseError{Oper: "directory length check", Err: err}
-	}
-
-	if length == 0 {
-		return nil, 8, io.EOF
-	}
-
-	left := length
-	if left < direntrySize {
-		return nil, 0, &ParseError{Oper: "directory entry", Err: errors.New("size too short")}
-	}
-
-	var dentry direntry
-	err = binary.Read(r, binary.LittleEndian, &dentry)
-	if err != nil {
-		return nil, 0, &ParseError{Oper: "directory entry", Err: err}
-	}
-
-	left -= direntrySize
-
-	namesLen := int64(dentry.FileNameLength + 2 + dentry.ShortNameLength)
-	if left < namesLen {
-		return nil, 0, &ParseError{Oper: "directory entry", Err: errors.New("size too short for names")}
-	}
-
-	names := make([]uint16, namesLen/2)
-	err = binary.Read(r, binary.LittleEndian, names)
-	if err != nil {
-		return nil, 0, &ParseError{Oper: "file name", Err: err}
-	}
-
-	left -= namesLen
-
-	var name, shortName string
-	if dentry.FileNameLength > 0 {
-		name = string(utf16.Decode(names[:dentry.FileNameLength/2]))
-	}
-
-	if dentry.ShortNameLength > 0 {
-		shortName = string(utf16.Decode(names[dentry.FileNameLength/2+1:]))
-	}
-
-	var offset resourceDescriptor
-	zerohash := SHA1Hash{}
-	if dentry.Hash != zerohash {
-		var ok bool
-		offset, ok = img.wim.fileData[dentry.Hash]
-		if !ok {
-			return nil, 0, &ParseError{Oper: "directory entry", Path: name, Err: fmt.Errorf("could not find file data matching hash %#v", dentry)}
-		}
-	}
-
-	f := &File{
-		FileHeader: FileHeader{
-			Attributes:     dentry.Attributes,
-			CreationTime:   dentry.CreationTime,
-			LastAccessTime: dentry.LastAccessTime,
-			LastWriteTime:  dentry.LastWriteTime,
-			Hash:           dentry.Hash,
-			Size:           offset.OriginalSize,
-			Name:           name,
-			ShortName:      shortName,
-		},
-
-		offset:       offset,
-		img:          img,
-		subdirOffset: dentry.SubdirOffset,
-	}
-
-	isDir := false
-
-	if dentry.Attributes&FILE_ATTRIBUTE_REPARSE_POINT == 0 {
-		f.LinkID = dentry.ReparseHardLink
-		if dentry.Attributes&FILE_ATTRIBUTE_DIRECTORY != 0 {
-			isDir = true
-		}
-	} else {
-		f.ReparseTag = uint32(dentry.ReparseHardLink)
-		f.ReparseReserved = uint32(dentry.ReparseHardLink >> 32)
-	}
-
-	if isDir && f.subdirOffset == 0 {
-		return nil, 0, &ParseError{Oper: "directory entry", Path: name, Err: errors.New("no subdirectory data for directory")}
-	} else if !isDir && f.subdirOffset != 0 {
-		return nil, 0, &ParseError{Oper: "directory entry", Path: name, Err: errors.New("unexpected subdirectory data for non-directory")}
-	}
-
-	if dentry.SecurityID != 0xffffffff {
-		f.SecurityDescriptor = img.sds[dentry.SecurityID]
-	}
-
-	_, err = io.CopyN(ioutil.Discard, r, left)
-	if err != nil {
-		if err == io.EOF {
-			err = io.ErrUnexpectedEOF
-		}
-		return nil, 0, err
-	}
-
-	if dentry.StreamCount > 0 {
-		var streams []*Stream
-		for i := uint16(0); i < dentry.StreamCount; i++ {
-			s, n, err := img.readNextStream(r)
-			length += n
-			if err != nil {
-				return nil, 0, err
-			}
-			// The first unnamed stream should be treated as the file stream.
-			if i == 0 && s.Name == "" {
-				f.Hash = s.Hash
-				f.Size = s.Size
-				f.offset = s.offset
-			} else if s.Name != "" {
-				streams = append(streams, s)
-			}
-		}
-		f.Streams = streams
-	}
-
-	if dentry.Attributes&FILE_ATTRIBUTE_REPARSE_POINT != 0 && f.Size == 0 {
-		return nil, 0, &ParseError{Oper: "directory entry", Path: name, Err: errors.New("reparse point is missing reparse stream")}
-	}
-
-	return f, length, nil
-}
-
-func (img *Image) readNextStream(r io.Reader) (*Stream, int64, error) {
-	var length int64
-	err := binary.Read(r, binary.LittleEndian, &length)
-	if err != nil {
-		if err == io.EOF {
-			err = io.ErrUnexpectedEOF
-		}
-		return nil, 0, &ParseError{Oper: "stream length check", Err: err}
-	}
-
-	left := length
-	if left < streamentrySize {
-		return nil, 0, &ParseError{Oper: "stream entry", Err: errors.New("size too short")}
-	}
-
-	var sentry streamentry
-	err = binary.Read(r, binary.LittleEndian, &sentry)
-	if err != nil {
-		return nil, 0, &ParseError{Oper: "stream entry", Err: err}
-	}
-
-	left -= streamentrySize
-
-	if left < int64(sentry.NameLength) {
-		return nil, 0, &ParseError{Oper: "stream entry", Err: errors.New("size too short for name")}
-	}
-
-	names := make([]uint16, sentry.NameLength/2)
-	err = binary.Read(r, binary.LittleEndian, names)
-	if err != nil {
-		return nil, 0, &ParseError{Oper: "file name", Err: err}
-	}
-
-	left -= int64(sentry.NameLength)
-	name := string(utf16.Decode(names))
-
-	var offset resourceDescriptor
-	if sentry.Hash != (SHA1Hash{}) {
-		var ok bool
-		offset, ok = img.wim.fileData[sentry.Hash]
-		if !ok {
-			return nil, 0, &ParseError{Oper: "stream entry", Path: name, Err: fmt.Errorf("could not find file data matching hash %v", sentry.Hash)}
-		}
-	}
-
-	s := &Stream{
-		StreamHeader: StreamHeader{
-			Hash: sentry.Hash,
-			Size: offset.OriginalSize,
-			Name: name,
-		},
-		wim:    img.wim,
-		offset: offset,
-	}
-
-	_, err = io.CopyN(ioutil.Discard, r, left)
-	if err != nil {
-		if err == io.EOF {
-			err = io.ErrUnexpectedEOF
-		}
-		return nil, 0, err
-	}
-
-	return s, length, nil
-}
-
-// Open returns an io.ReadCloser that can be used to read the stream's contents.
-func (s *Stream) Open() (io.ReadCloser, error) {
-	return s.wim.resourceReader(&s.offset)
-}
-
-// Open returns an io.ReadCloser that can be used to read the file's contents.
-func (f *File) Open() (io.ReadCloser, error) {
-	return f.img.wim.resourceReader(&f.offset)
-}
-
-// Readdir reads the directory entries.
-func (f *File) Readdir() ([]*File, error) {
-	if !f.IsDir() {
-		return nil, errors.New("not a directory")
-	}
-	return f.img.readdir(f.subdirOffset)
-}
-
-// IsDir returns whether the given file is a directory. It returns false when it
-// is a directory reparse point.
-func (f *FileHeader) IsDir() bool {
-	return f.Attributes&(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_DIRECTORY
-}

+ 0 - 1
vendor/github.com/Microsoft/hcsshim/.gitignore

@@ -1 +0,0 @@
-*.exe

+ 0 - 17
vendor/github.com/Microsoft/hcsshim/.gometalinter.json

@@ -1,17 +0,0 @@
-{
-    "Vendor": true,
-    "Deadline": "2m",
-    "Sort": [
-        "linter",
-        "severity",
-        "path",
-        "line"
-    ],
-    "Skip": [
-        "internal\\schema2"
-    ],
-    "EnableGC": true,
-    "Enable": [
-        "gofmt"
-    ]
-}

+ 0 - 41
vendor/github.com/Microsoft/hcsshim/README.md

@@ -1,41 +0,0 @@
-# hcsshim
-
-[![Build status](https://ci.appveyor.com/api/projects/status/nbcw28mnkqml0loa/branch/master?svg=true)](https://ci.appveyor.com/project/WindowsVirtualization/hcsshim/branch/master)
-
-This package contains the Golang interface for using the Windows [Host Compute Service](https://blogs.technet.microsoft.com/virtualization/2017/01/27/introducing-the-host-compute-service-hcs/) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS).
-
-It is primarily used in the [Moby Project](https://github.com/moby/moby), but it can be freely used by other projects as well.
-
-## Contributing
-
-This project welcomes contributions and suggestions.  Most contributions require you to agree to a
-Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
-the rights to use your contribution. For details, visit https://cla.microsoft.com.
-
-When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
-a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
-provided by the bot. You will only need to do this once across all repos using our CLA.
-
-This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
-For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
-contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
-
-## Dependencies
-
-This project requires Golang 1.9 or newer to build.
-
-For system requirements to run this project, see the Microsoft docs on [Windows Container requirements](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/system-requirements).
-
-## Reporting Security Issues
-
-Security issues and bugs should be reported privately, via email, to the Microsoft Security
-Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should
-receive a response within 24 hours. If for some reason you do not, please follow up via
-email to ensure we received your original message. Further information, including the
-[MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in
-the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
-
-For additional details, see [Report a Computer Security Vulnerability](https://technet.microsoft.com/en-us/security/ff852094.aspx) on Technet
-
----------------
-Copyright (c) 2018 Microsoft Corp.  All rights reserved.

+ 0 - 29
vendor/github.com/Microsoft/hcsshim/appveyor.yml

@@ -1,29 +0,0 @@
-version: 0.1.{build}
-
-image: Visual Studio 2017
-
-clone_folder: c:\gopath\src\github.com\Microsoft\hcsshim
-
-environment:
-  GOPATH: c:\gopath
-  PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%GOPATH%\bin;C:\gometalinter-2.0.12-windows-amd64;%PATH%
-
-stack: go 1.11
-
-build_script:
-  - appveyor DownloadFile https://github.com/alecthomas/gometalinter/releases/download/v2.0.12/gometalinter-2.0.12-windows-amd64.zip
-  - 7z x gometalinter-2.0.12-windows-amd64.zip -y -oC:\ > NUL
-  - gometalinter.exe --config .gometalinter.json ./...
-  - go build ./cmd/wclayer
-  - go build ./cmd/runhcs
-  - go build ./cmd/tar2ext4
-  - go test -v ./... -tags admin
-  - go test -c ./test/functional/ -tags functional
-  - go test -c ./test/runhcs/ -tags integration
-
-artifacts:
-  - path: 'wclayer.exe'
-  - path: 'runhcs.exe'
-  - path: 'tar2ext4.exe'
-  - path: 'functional.test.exe'
-  - path: 'runhcs.test.exe'

+ 0 - 191
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/LICENSE

@@ -1,191 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   Copyright 2014 Docker, Inc.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

+ 0 - 22
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/NOTICE

@@ -1,22 +0,0 @@
-runhcs is a fork of runc.
-
-The following is runc's legal notice.
-
----
-
-runc
-
-Copyright 2012-2015 Docker, Inc.
-
-This product includes software developed at Docker, Inc. (http://www.docker.com).
-
-The following is courtesy of our legal counsel:
-
-Use and transfer of Docker may be subject to certain restrictions by the
-United States and other governments.
-It is your responsibility to ensure that your use and/or transfer does not
-violate applicable laws.
-
-For more information, please see http://www.bis.doc.gov
-
-See also http://www.apache.org/dev/crypto.html and/or seek legal counsel.

+ 0 - 848
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/container.go

@@ -1,848 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"os"
-	"path/filepath"
-	"strconv"
-	"strings"
-	"time"
-
-	winio "github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim/internal/cni"
-	"github.com/Microsoft/hcsshim/internal/guid"
-	"github.com/Microsoft/hcsshim/internal/hcs"
-	"github.com/Microsoft/hcsshim/internal/hcsoci"
-	"github.com/Microsoft/hcsshim/internal/logfields"
-	"github.com/Microsoft/hcsshim/internal/regstate"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/Microsoft/hcsshim/internal/uvm"
-	"github.com/Microsoft/hcsshim/osversion"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/sirupsen/logrus"
-	"golang.org/x/sys/windows"
-)
-
-var errContainerStopped = errors.New("container is stopped")
-
-type persistedState struct {
-	// ID is the id of this container/UVM.
-	ID string `json:",omitempty"`
-	// Owner is the owner value passed into the runhcs command and may be `""`.
-	Owner string `json:",omitempty"`
-	// SandboxID is the sandbox identifer passed in via OCI specifications. This
-	// can either be the sandbox itself or the sandbox this container should run
-	// in. See `parseSandboxAnnotations`.
-	SandboxID string `json:",omitempty"`
-	// HostID will be VM ID hosting this container. If a sandbox is used it will
-	// match the `SandboxID`.
-	HostID string `json:",omitempty"`
-	// Bundle is the folder path on disk where the container state and spec files
-	// reside.
-	Bundle  string    `json:",omitempty"`
-	Created time.Time `json:",omitempty"`
-	Rootfs  string    `json:",omitempty"`
-	// Spec is the in memory deserialized values found on `Bundle\config.json`.
-	Spec           *specs.Spec `json:",omitempty"`
-	RequestedNetNS string      `json:",omitempty"`
-	// IsHost is `true` when this is a VM isolated config.
-	IsHost bool `json:",omitempty"`
-	// UniqueID is a unique ID generated per container config.
-	UniqueID guid.GUID `json:",omitempty"`
-	// HostUniqueID is the unique ID of the hosting VM if this container is
-	// hosted.
-	HostUniqueID guid.GUID `json:",omitempty"`
-}
-
-type containerStatus string
-
-const (
-	containerRunning containerStatus = "running"
-	containerStopped containerStatus = "stopped"
-	containerCreated containerStatus = "created"
-	containerPaused  containerStatus = "paused"
-	containerUnknown containerStatus = "unknown"
-
-	keyState     = "state"
-	keyResources = "resources"
-	keyShimPid   = "shim"
-	keyInitPid   = "pid"
-	keyNetNS     = "netns"
-	// keyPidMapFmt is the format to use when mapping a host OS pid to a guest
-	// pid.
-	keyPidMapFmt = "pid-%d"
-)
-
-type container struct {
-	persistedState
-	ShimPid   int
-	hc        *hcs.System
-	resources *hcsoci.Resources
-}
-
-func startProcessShim(id, pidFile, logFile string, spec *specs.Process) (_ *os.Process, err error) {
-	// Ensure the stdio handles inherit to the child process. This isn't undone
-	// after the StartProcess call because the caller never launches another
-	// process before exiting.
-	for _, f := range []*os.File{os.Stdin, os.Stdout, os.Stderr} {
-		err = windows.SetHandleInformation(windows.Handle(f.Fd()), windows.HANDLE_FLAG_INHERIT, windows.HANDLE_FLAG_INHERIT)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	args := []string{
-		"--stdin", strconv.Itoa(int(os.Stdin.Fd())),
-		"--stdout", strconv.Itoa(int(os.Stdout.Fd())),
-		"--stderr", strconv.Itoa(int(os.Stderr.Fd())),
-	}
-	if spec != nil {
-		args = append(args, "--exec")
-	}
-	if strings.HasPrefix(logFile, runhcs.SafePipePrefix) {
-		args = append(args, "--log-pipe", logFile)
-	}
-	args = append(args, id)
-	return launchShim("shim", pidFile, logFile, args, spec)
-}
-
-func launchShim(cmd, pidFile, logFile string, args []string, data interface{}) (_ *os.Process, err error) {
-	executable, err := os.Executable()
-	if err != nil {
-		return nil, err
-	}
-
-	// Create a pipe to use as stderr for the shim process. This is used to
-	// retrieve early error information, up to the point that the shim is ready
-	// to launch a process in the container.
-	rp, wp, err := os.Pipe()
-	if err != nil {
-		return nil, err
-	}
-	defer rp.Close()
-	defer wp.Close()
-
-	// Create a pipe to send the data, if one is provided.
-	var rdatap, wdatap *os.File
-	if data != nil {
-		rdatap, wdatap, err = os.Pipe()
-		if err != nil {
-			return nil, err
-		}
-		defer rdatap.Close()
-		defer wdatap.Close()
-	}
-
-	var log *os.File
-	fullargs := []string{os.Args[0]}
-	if logFile != "" {
-		if !strings.HasPrefix(logFile, runhcs.SafePipePrefix) {
-			log, err = os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_SYNC, 0666)
-			if err != nil {
-				return nil, err
-			}
-			defer log.Close()
-		}
-
-		fullargs = append(fullargs, "--log-format", logFormat)
-		if logrus.GetLevel() == logrus.DebugLevel {
-			fullargs = append(fullargs, "--debug")
-		}
-	}
-	fullargs = append(fullargs, cmd)
-	fullargs = append(fullargs, args...)
-	attr := &os.ProcAttr{
-		Files: []*os.File{rdatap, wp, log},
-	}
-	p, err := os.StartProcess(executable, fullargs, attr)
-	if err != nil {
-		return nil, err
-	}
-	defer func() {
-		if err != nil {
-			p.Kill()
-		}
-	}()
-
-	wp.Close()
-
-	// Write the data if provided.
-	if data != nil {
-		rdatap.Close()
-		dataj, err := json.Marshal(data)
-		if err != nil {
-			return nil, err
-		}
-		_, err = wdatap.Write(dataj)
-		if err != nil {
-			return nil, err
-		}
-		wdatap.Close()
-	}
-
-	err = runhcs.GetErrorFromPipe(rp, p)
-	if err != nil {
-		return nil, err
-	}
-
-	if pidFile != "" {
-		if err = createPidFile(pidFile, p.Pid); err != nil {
-			return nil, err
-		}
-	}
-
-	return p, nil
-}
-
-// parseSandboxAnnotations searches `a` for various annotations used by
-// different runtimes to represent a sandbox ID, and sandbox type.
-//
-// If found returns the tuple `(sandboxID, isSandbox)` where `isSandbox == true`
-// indicates the identifer is the sandbox itself; `isSandbox == false` indicates
-// the identifer is the sandbox in which to place this container. Otherwise
-// returns `("", false)`.
-func parseSandboxAnnotations(a map[string]string) (string, bool) {
-	var t, id string
-	if t = a["io.kubernetes.cri.container-type"]; t != "" {
-		id = a["io.kubernetes.cri.sandbox-id"]
-	} else if t = a["io.kubernetes.cri-o.ContainerType"]; t != "" {
-		id = a["io.kubernetes.cri-o.SandboxID"]
-	} else if t = a["io.kubernetes.docker.type"]; t != "" {
-		id = a["io.kubernetes.sandbox.id"]
-		if t == "podsandbox" {
-			t = "sandbox"
-		}
-	}
-	if t == "container" {
-		return id, false
-	}
-	if t == "sandbox" {
-		return id, true
-	}
-	return "", false
-}
-
-// parseAnnotationsBool searches `a` for `key` and if found verifies that the
-// value is `true` or `false` in any case. If `key` is not found returns `def`.
-func parseAnnotationsBool(a map[string]string, key string, def bool) bool {
-	if v, ok := a[key]; ok {
-		switch strings.ToLower(v) {
-		case "true":
-			return true
-		case "false":
-			return false
-		default:
-			logrus.WithFields(logrus.Fields{
-				logfields.OCIAnnotation: key,
-				logfields.Value:         v,
-				logfields.ExpectedType:  logfields.Bool,
-			}).Warning("annotation could not be parsed")
-		}
-	}
-	return def
-}
-
-// parseAnnotationsCPU searches `s.Annotations` for the CPU annotation. If
-// not found searches `s` for the Windows CPU section. If neither are found
-// returns `def`.
-func parseAnnotationsCPU(s *specs.Spec, annotation string, def int32) int32 {
-	if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 {
-		return int32(m)
-	}
-	if s.Windows != nil &&
-		s.Windows.Resources != nil &&
-		s.Windows.Resources.CPU != nil &&
-		s.Windows.Resources.CPU.Count != nil &&
-		*s.Windows.Resources.CPU.Count > 0 {
-		return int32(*s.Windows.Resources.CPU.Count)
-	}
-	return def
-}
-
-// parseAnnotationsMemory searches `s.Annotations` for the memory annotation. If
-// not found searches `s` for the Windows memory section. If neither are found
-// returns `def`.
-func parseAnnotationsMemory(s *specs.Spec, annotation string, def int32) int32 {
-	if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 {
-		return int32(m)
-	}
-	if s.Windows != nil &&
-		s.Windows.Resources != nil &&
-		s.Windows.Resources.Memory != nil &&
-		s.Windows.Resources.Memory.Limit != nil &&
-		*s.Windows.Resources.Memory.Limit > 0 {
-		return int32(*s.Windows.Resources.Memory.Limit)
-	}
-	return def
-}
-
-// parseAnnotationsPreferredRootFSType searches `a` for `key` and verifies that the
-// value is in the set of allowed values. If `key` is not found returns `def`.
-func parseAnnotationsPreferredRootFSType(a map[string]string, key string, def uvm.PreferredRootFSType) uvm.PreferredRootFSType {
-	if v, ok := a[key]; ok {
-		switch v {
-		case "initrd":
-			return uvm.PreferredRootFSTypeInitRd
-		case "vhd":
-			return uvm.PreferredRootFSTypeVHD
-		default:
-			logrus.Warningf("annotation: '%s', with value: '%s' must be 'initrd' or 'vhd'", key, v)
-		}
-	}
-	return def
-}
-
-// parseAnnotationsUint32 searches `a` for `key` and if found verifies that the
-// value is a 32 bit unsigned integer. If `key` is not found returns `def`.
-func parseAnnotationsUint32(a map[string]string, key string, def uint32) uint32 {
-	if v, ok := a[key]; ok {
-		countu, err := strconv.ParseUint(v, 10, 32)
-		if err == nil {
-			v := uint32(countu)
-			return v
-		}
-		logrus.WithFields(logrus.Fields{
-			logfields.OCIAnnotation: key,
-			logfields.Value:         v,
-			logfields.ExpectedType:  logfields.Uint32,
-			logrus.ErrorKey:         err,
-		}).Warning("annotation could not be parsed")
-	}
-	return def
-}
-
-// parseAnnotationsUint64 searches `a` for `key` and if found verifies that the
-// value is a 64 bit unsigned integer. If `key` is not found returns `def`.
-func parseAnnotationsUint64(a map[string]string, key string, def uint64) uint64 {
-	if v, ok := a[key]; ok {
-		countu, err := strconv.ParseUint(v, 10, 64)
-		if err == nil {
-			return countu
-		}
-		logrus.WithFields(logrus.Fields{
-			logfields.OCIAnnotation: key,
-			logfields.Value:         v,
-			logfields.ExpectedType:  logfields.Uint64,
-			logrus.ErrorKey:         err,
-		}).Warning("annotation could not be parsed")
-	}
-	return def
-}
-
-// startVMShim starts a vm-shim command with the specified `opts`. `opts` can be `uvm.OptionsWCOW` or `uvm.OptionsLCOW`
-func (c *container) startVMShim(logFile string, opts interface{}) (*os.Process, error) {
-	var os string
-	if _, ok := opts.(*uvm.OptionsLCOW); ok {
-		os = "linux"
-	} else {
-		os = "windows"
-	}
-	args := []string{"--os", os}
-	if strings.HasPrefix(logFile, runhcs.SafePipePrefix) {
-		args = append(args, "--log-pipe", logFile)
-	}
-	args = append(args, c.VMPipePath())
-	return launchShim("vmshim", "", logFile, args, opts)
-}
-
-type containerConfig struct {
-	ID                     string
-	Owner                  string
-	HostID                 string
-	PidFile                string
-	ShimLogFile, VMLogFile string
-	Spec                   *specs.Spec
-	VMConsolePipe          string
-}
-
-func createContainer(cfg *containerConfig) (_ *container, err error) {
-	// Store the container information in a volatile registry key.
-	cwd, err := os.Getwd()
-	if err != nil {
-		return nil, err
-	}
-
-	vmisolated := cfg.Spec.Linux != nil || (cfg.Spec.Windows != nil && cfg.Spec.Windows.HyperV != nil)
-
-	sandboxID, isSandbox := parseSandboxAnnotations(cfg.Spec.Annotations)
-	hostID := cfg.HostID
-	if isSandbox {
-		if sandboxID != cfg.ID {
-			return nil, errors.New("sandbox ID must match ID")
-		}
-	} else if sandboxID != "" {
-		// Validate that the sandbox container exists.
-		sandbox, err := getContainer(sandboxID, false)
-		if err != nil {
-			return nil, err
-		}
-		defer sandbox.Close()
-		if sandbox.SandboxID != sandboxID {
-			return nil, fmt.Errorf("container %s is not a sandbox", sandboxID)
-		}
-		if hostID == "" {
-			// Use the sandbox's host.
-			hostID = sandbox.HostID
-		} else if sandbox.HostID == "" {
-			return nil, fmt.Errorf("sandbox container %s is not running in a VM host, but host %s was specified", sandboxID, hostID)
-		} else if hostID != sandbox.HostID {
-			return nil, fmt.Errorf("sandbox container %s has a different host %s from the requested host %s", sandboxID, sandbox.HostID, hostID)
-		}
-		if vmisolated && hostID == "" {
-			return nil, fmt.Errorf("container %s is not a VM isolated sandbox", sandboxID)
-		}
-	}
-
-	uniqueID := guid.New()
-
-	newvm := false
-	var hostUniqueID guid.GUID
-	if hostID != "" {
-		host, err := getContainer(hostID, false)
-		if err != nil {
-			return nil, err
-		}
-		defer host.Close()
-		if !host.IsHost {
-			return nil, fmt.Errorf("host container %s is not a VM host", hostID)
-		}
-		hostUniqueID = host.UniqueID
-	} else if vmisolated && (isSandbox || cfg.Spec.Linux != nil || osversion.Get().Build >= osversion.RS5) {
-		// This handles all LCOW, Pod Sandbox, and (Windows Xenon V2 for RS5+)
-		hostID = cfg.ID
-		newvm = true
-		hostUniqueID = uniqueID
-	}
-
-	// Make absolute the paths in Root.Path and Windows.LayerFolders.
-	rootfs := ""
-	if cfg.Spec.Root != nil {
-		rootfs = cfg.Spec.Root.Path
-		if rootfs != "" && !filepath.IsAbs(rootfs) && !strings.HasPrefix(rootfs, `\\?\`) {
-			rootfs = filepath.Join(cwd, rootfs)
-			cfg.Spec.Root.Path = rootfs
-		}
-	}
-
-	netNS := ""
-	if cfg.Spec.Windows != nil {
-		for i, f := range cfg.Spec.Windows.LayerFolders {
-			if !filepath.IsAbs(f) && !strings.HasPrefix(rootfs, `\\?\`) {
-				cfg.Spec.Windows.LayerFolders[i] = filepath.Join(cwd, f)
-			}
-		}
-
-		// Determine the network namespace to use.
-		if cfg.Spec.Windows.Network != nil {
-			if cfg.Spec.Windows.Network.NetworkSharedContainerName != "" {
-				// RS4 case
-				err = stateKey.Get(cfg.Spec.Windows.Network.NetworkSharedContainerName, keyNetNS, &netNS)
-				if err != nil {
-					if _, ok := err.(*regstate.NoStateError); !ok {
-						return nil, err
-					}
-				}
-			} else if cfg.Spec.Windows.Network.NetworkNamespace != "" {
-				// RS5 case
-				netNS = cfg.Spec.Windows.Network.NetworkNamespace
-			}
-		}
-	}
-
-	// Store the initial container state in the registry so that the delete
-	// command can clean everything up if something goes wrong.
-	c := &container{
-		persistedState: persistedState{
-			ID:             cfg.ID,
-			Owner:          cfg.Owner,
-			Bundle:         cwd,
-			Rootfs:         rootfs,
-			Created:        time.Now(),
-			Spec:           cfg.Spec,
-			SandboxID:      sandboxID,
-			HostID:         hostID,
-			IsHost:         newvm,
-			RequestedNetNS: netNS,
-			UniqueID:       uniqueID,
-			HostUniqueID:   hostUniqueID,
-		},
-	}
-	err = stateKey.Create(cfg.ID, keyState, &c.persistedState)
-	if err != nil {
-		return nil, err
-	}
-	defer func() {
-		if err != nil {
-			c.Remove()
-		}
-	}()
-	if isSandbox && vmisolated {
-		cnicfg := cni.NewPersistedNamespaceConfig(netNS, cfg.ID, hostUniqueID)
-		err = cnicfg.Store()
-		if err != nil {
-			return nil, err
-		}
-		defer func() {
-			if err != nil {
-				cnicfg.Remove()
-			}
-		}()
-	}
-
-	// Start a VM if necessary.
-	if newvm {
-		var opts interface{}
-
-		const (
-			annotationAllowOvercommit      = "io.microsoft.virtualmachine.computetopology.memory.allowovercommit"
-			annotationEnableDeferredCommit = "io.microsoft.virtualmachine.computetopology.memory.enabledeferredcommit"
-			annotationMemorySizeInMB       = "io.microsoft.virtualmachine.computetopology.memory.sizeinmb"
-			annotationProcessorCount       = "io.microsoft.virtualmachine.computetopology.processor.count"
-			annotationVPMemCount           = "io.microsoft.virtualmachine.devices.virtualpmem.maximumcount"
-			annotationVPMemSize            = "io.microsoft.virtualmachine.devices.virtualpmem.maximumsizebytes"
-			annotationPreferredRootFSType  = "io.microsoft.virtualmachine.lcow.preferredrootfstype"
-		)
-
-		if cfg.Spec.Linux != nil {
-			lopts := uvm.NewDefaultOptionsLCOW(vmID(c.ID), cfg.Owner)
-			lopts.MemorySizeInMB = parseAnnotationsMemory(cfg.Spec, annotationMemorySizeInMB, lopts.MemorySizeInMB)
-			lopts.AllowOvercommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationAllowOvercommit, lopts.AllowOvercommit)
-			lopts.EnableDeferredCommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationEnableDeferredCommit, lopts.EnableDeferredCommit)
-			lopts.ProcessorCount = parseAnnotationsCPU(cfg.Spec, annotationProcessorCount, lopts.ProcessorCount)
-			lopts.ConsolePipe = cfg.VMConsolePipe
-			lopts.VPMemDeviceCount = parseAnnotationsUint32(cfg.Spec.Annotations, annotationVPMemCount, lopts.VPMemDeviceCount)
-			lopts.VPMemSizeBytes = parseAnnotationsUint64(cfg.Spec.Annotations, annotationVPMemSize, lopts.VPMemSizeBytes)
-			lopts.PreferredRootFSType = parseAnnotationsPreferredRootFSType(cfg.Spec.Annotations, annotationPreferredRootFSType, lopts.PreferredRootFSType)
-			switch lopts.PreferredRootFSType {
-			case uvm.PreferredRootFSTypeInitRd:
-				lopts.RootFSFile = uvm.InitrdFile
-			case uvm.PreferredRootFSTypeVHD:
-				lopts.RootFSFile = uvm.VhdFile
-			}
-			opts = lopts
-		} else {
-			wopts := uvm.NewDefaultOptionsWCOW(vmID(c.ID), cfg.Owner)
-			wopts.MemorySizeInMB = parseAnnotationsMemory(cfg.Spec, annotationMemorySizeInMB, wopts.MemorySizeInMB)
-			wopts.AllowOvercommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationAllowOvercommit, wopts.AllowOvercommit)
-			wopts.EnableDeferredCommit = parseAnnotationsBool(cfg.Spec.Annotations, annotationEnableDeferredCommit, wopts.EnableDeferredCommit)
-			wopts.ProcessorCount = parseAnnotationsCPU(cfg.Spec, annotationProcessorCount, wopts.ProcessorCount)
-
-			// In order for the UVM sandbox.vhdx not to collide with the actual
-			// nested Argon sandbox.vhdx we append the \vm folder to the last entry
-			// in the list.
-			layersLen := len(cfg.Spec.Windows.LayerFolders)
-			layers := make([]string, layersLen)
-			copy(layers, cfg.Spec.Windows.LayerFolders)
-
-			vmPath := filepath.Join(layers[layersLen-1], "vm")
-			err := os.MkdirAll(vmPath, 0)
-			if err != nil {
-				return nil, err
-			}
-			layers[layersLen-1] = vmPath
-
-			wopts.LayerFolders = layers
-			opts = wopts
-		}
-
-		shim, err := c.startVMShim(cfg.VMLogFile, opts)
-		if err != nil {
-			return nil, err
-		}
-		shim.Release()
-	}
-
-	if c.HostID != "" {
-		// Call to the VM shim process to create the container. This is done so
-		// that the VM process can keep track of the VM's virtual hardware
-		// resource use.
-		err = c.issueVMRequest(runhcs.OpCreateContainer)
-		if err != nil {
-			return nil, err
-		}
-		c.hc, err = hcs.OpenComputeSystem(cfg.ID)
-		if err != nil {
-			return nil, err
-		}
-	} else {
-		// Create the container directly from this process.
-		err = createContainerInHost(c, nil)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	// Create the shim process for the container.
-	err = startContainerShim(c, cfg.PidFile, cfg.ShimLogFile)
-	if err != nil {
-		if e := c.Kill(); e == nil {
-			c.Remove()
-		}
-		return nil, err
-	}
-
-	return c, nil
-}
-
-func (c *container) ShimPipePath() string {
-	return runhcs.SafePipePath("runhcs-shim-" + c.UniqueID.String())
-}
-
-func (c *container) VMPipePath() string {
-	return runhcs.VMPipePath(c.HostUniqueID)
-}
-
-func (c *container) VMIsolated() bool {
-	return c.HostID != ""
-}
-
-func (c *container) unmountInHost(vm *uvm.UtilityVM, all bool) error {
-	resources := &hcsoci.Resources{}
-	err := stateKey.Get(c.ID, keyResources, resources)
-	if _, ok := err.(*regstate.NoStateError); ok {
-		return nil
-	}
-	if err != nil {
-		return err
-	}
-	err = hcsoci.ReleaseResources(resources, vm, all)
-	if err != nil {
-		stateKey.Set(c.ID, keyResources, resources)
-		return err
-	}
-
-	err = stateKey.Clear(c.ID, keyResources)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-func (c *container) Unmount(all bool) error {
-	if c.VMIsolated() {
-		op := runhcs.OpUnmountContainerDiskOnly
-		if all {
-			op = runhcs.OpUnmountContainer
-		}
-		err := c.issueVMRequest(op)
-		if err != nil {
-			if _, ok := err.(*noVMError); ok {
-				logrus.WithFields(logrus.Fields{
-					logfields.ContainerID: c.ID,
-					logfields.UVMID:       c.HostID,
-					logrus.ErrorKey:       errors.New("failed to unmount container resources"),
-				}).Warning("VM shim could not be contacted")
-			} else {
-				return err
-			}
-		}
-	} else {
-		c.unmountInHost(nil, false)
-	}
-	return nil
-}
-
-func createContainerInHost(c *container, vm *uvm.UtilityVM) (err error) {
-	if c.hc != nil {
-		return errors.New("container already created")
-	}
-
-	// Create the container without starting it.
-	opts := &hcsoci.CreateOptions{
-		ID:               c.ID,
-		Owner:            c.Owner,
-		Spec:             c.Spec,
-		HostingSystem:    vm,
-		NetworkNamespace: c.RequestedNetNS,
-	}
-	vmid := ""
-	if vm != nil {
-		vmid = vm.ID()
-	}
-	logrus.WithFields(logrus.Fields{
-		logfields.ContainerID: c.ID,
-		logfields.UVMID:       vmid,
-	}).Info("creating container in UVM")
-	hc, resources, err := hcsoci.CreateContainer(opts)
-	if err != nil {
-		return err
-	}
-	defer func() {
-		if err != nil {
-			hc.Terminate()
-			hc.Wait()
-			hcsoci.ReleaseResources(resources, vm, true)
-		}
-	}()
-
-	// Record the network namespace to support namespace sharing by container ID.
-	if resources.NetNS() != "" {
-		err = stateKey.Set(c.ID, keyNetNS, resources.NetNS())
-		if err != nil {
-			return err
-		}
-	}
-
-	err = stateKey.Set(c.ID, keyResources, resources)
-	if err != nil {
-		return err
-	}
-	c.hc = hc
-	return nil
-}
-
-func startContainerShim(c *container, pidFile, logFile string) error {
-	// Launch a shim process to later execute a process in the container.
-	shim, err := startProcessShim(c.ID, pidFile, logFile, nil)
-	if err != nil {
-		return err
-	}
-	defer shim.Release()
-	defer func() {
-		if err != nil {
-			shim.Kill()
-		}
-	}()
-
-	c.ShimPid = shim.Pid
-	err = stateKey.Set(c.ID, keyShimPid, shim.Pid)
-	if err != nil {
-		return err
-	}
-
-	if pidFile != "" {
-		if err = createPidFile(pidFile, shim.Pid); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func (c *container) Close() error {
-	if c.hc == nil {
-		return nil
-	}
-	return c.hc.Close()
-}
-
-func (c *container) Exec() error {
-	err := c.hc.Start()
-	if err != nil {
-		return err
-	}
-
-	if c.Spec.Process == nil {
-		return nil
-	}
-
-	// Alert the shim that the container is ready.
-	pipe, err := winio.DialPipe(c.ShimPipePath(), nil)
-	if err != nil {
-		return err
-	}
-	defer pipe.Close()
-
-	shim, err := os.FindProcess(c.ShimPid)
-	if err != nil {
-		return err
-	}
-	defer shim.Release()
-
-	err = runhcs.GetErrorFromPipe(pipe, shim)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func getContainer(id string, notStopped bool) (*container, error) {
-	var c container
-	err := stateKey.Get(id, keyState, &c.persistedState)
-	if err != nil {
-		return nil, err
-	}
-	err = stateKey.Get(id, keyShimPid, &c.ShimPid)
-	if err != nil {
-		if _, ok := err.(*regstate.NoStateError); !ok {
-			return nil, err
-		}
-		c.ShimPid = -1
-	}
-	if notStopped && c.ShimPid == 0 {
-		return nil, errContainerStopped
-	}
-
-	hc, err := hcs.OpenComputeSystem(c.ID)
-	if err == nil {
-		c.hc = hc
-	} else if !hcs.IsNotExist(err) {
-		return nil, err
-	} else if notStopped {
-		return nil, errContainerStopped
-	}
-
-	return &c, nil
-}
-
-func (c *container) Remove() error {
-	// Unmount any layers or mapped volumes.
-	err := c.Unmount(!c.IsHost)
-	if err != nil {
-		return err
-	}
-
-	// Follow kata's example and delay tearing down the VM until the owning
-	// container is removed.
-	if c.IsHost {
-		vm, err := hcs.OpenComputeSystem(vmID(c.ID))
-		if err == nil {
-			if err := vm.Terminate(); hcs.IsPending(err) {
-				vm.Wait()
-			}
-		}
-	}
-	return stateKey.Remove(c.ID)
-}
-
-func (c *container) Kill() error {
-	if c.hc == nil {
-		return nil
-	}
-	err := c.hc.Terminate()
-	if hcs.IsPending(err) {
-		err = c.hc.Wait()
-	}
-	if hcs.IsAlreadyStopped(err) {
-		err = nil
-	}
-	return err
-}
-
-func (c *container) Status() (containerStatus, error) {
-	if c.hc == nil || c.ShimPid == 0 {
-		return containerStopped, nil
-	}
-	props, err := c.hc.Properties()
-	if err != nil {
-		if !strings.Contains(err.Error(), "operation is not valid in the current state") {
-			return "", err
-		}
-		return containerUnknown, nil
-	}
-	state := containerUnknown
-	switch props.State {
-	case "", "Created":
-		state = containerCreated
-	case "Running":
-		state = containerRunning
-	case "Paused":
-		state = containerPaused
-	case "Stopped":
-		state = containerStopped
-	}
-	return state, nil
-}

+ 0 - 71
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create-scratch.go

@@ -1,71 +0,0 @@
-package main
-
-import (
-	"os"
-	"path/filepath"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/lcow"
-	"github.com/Microsoft/hcsshim/internal/uvm"
-	"github.com/Microsoft/hcsshim/osversion"
-	gcsclient "github.com/Microsoft/opengcs/client"
-	"github.com/pkg/errors"
-	"github.com/urfave/cli"
-)
-
-var createScratchCommand = cli.Command{
-	Name:        "create-scratch",
-	Usage:       "creates a scratch vhdx at 'destpath' that is ext4 formatted",
-	Description: "Creates a scratch vhdx at 'destpath' that is ext4 formatted",
-	Flags: []cli.Flag{
-		cli.StringFlag{
-			Name:  "destpath",
-			Usage: "Required: describes the destination vhd path",
-		},
-	},
-	Before: appargs.Validate(),
-	Action: func(context *cli.Context) error {
-		dest := context.String("destpath")
-		if dest == "" {
-			return errors.New("'destpath' is required")
-		}
-
-		// If we only have v1 lcow support do it the old way.
-		if osversion.Get().Build < osversion.RS5 {
-			cfg := gcsclient.Config{
-				Options: gcsclient.Options{
-					KirdPath:   filepath.Join(os.Getenv("ProgramFiles"), "Linux Containers"),
-					KernelFile: "kernel",
-					InitrdFile: uvm.InitrdFile,
-				},
-				Name:              "createscratch-uvm",
-				UvmTimeoutSeconds: 5 * 60, // 5 Min
-			}
-
-			if err := cfg.StartUtilityVM(); err != nil {
-				return errors.Wrapf(err, "failed to start '%s'", cfg.Name)
-			}
-			defer cfg.Uvm.Terminate()
-
-			if err := cfg.CreateExt4Vhdx(dest, lcow.DefaultScratchSizeGB, ""); err != nil {
-				return errors.Wrapf(err, "failed to create ext4vhdx for '%s'", cfg.Name)
-			}
-		} else {
-			opts := uvm.NewDefaultOptionsLCOW("createscratch-uvm", context.GlobalString("owner"))
-			convertUVM, err := uvm.CreateLCOW(opts)
-			if err != nil {
-				return errors.Wrapf(err, "failed to create '%s'", opts.ID)
-			}
-			defer convertUVM.Close()
-			if err := convertUVM.Start(); err != nil {
-				return errors.Wrapf(err, "failed to start '%s'", opts.ID)
-			}
-
-			if err := lcow.CreateScratch(convertUVM, dest, lcow.DefaultScratchSizeGB, "", ""); err != nil {
-				return errors.Wrapf(err, "failed to create ext4vhdx for '%s'", opts.ID)
-			}
-		}
-
-		return nil
-	},
-}

+ 0 - 100
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/create.go

@@ -1,100 +0,0 @@
-package main
-
-import (
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var createRunFlags = []cli.Flag{
-	cli.StringFlag{
-		Name:  "bundle, b",
-		Value: "",
-		Usage: `path to the root of the bundle directory, defaults to the current directory`,
-	},
-	cli.StringFlag{
-		Name:  "pid-file",
-		Value: "",
-		Usage: "specify the file to write the process id to",
-	},
-	cli.StringFlag{
-		Name:  "shim-log",
-		Value: "",
-		Usage: `path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-shim-log) for the launched shim process`,
-	},
-	cli.StringFlag{
-		Name:  "vm-log",
-		Value: "",
-		Usage: `path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-vm-log) for the launched VM shim process`,
-	},
-	cli.StringFlag{
-		Name:  "vm-console",
-		Value: "",
-		Usage: `path to the pipe for the VM's console (e.g. \\.\pipe\debugpipe)`,
-	},
-	cli.StringFlag{
-		Name:  "host",
-		Value: "",
-		Usage: "host container whose VM this container should run in",
-	},
-}
-
-var createCommand = cli.Command{
-	Name:  "create",
-	Usage: "create a container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is your name for the instance of the container that you
-are starting. The name you provide for the container instance must be unique on
-your host.`,
-	Description: `The create command creates an instance of a container for a bundle. The bundle
-is a directory with a specification file named "` + specConfig + `" and a root
-filesystem.
-
-The specification file includes an args parameter. The args parameter is used
-to specify command(s) that get run when the container is started. To change the
-command(s) that get executed on start, edit the args parameter of the spec. See
-"runc spec --help" for more explanation.`,
-	Flags:  append(createRunFlags),
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		cfg, err := containerConfigFromContext(context)
-		if err != nil {
-			return err
-		}
-		_, err = createContainer(cfg)
-		if err != nil {
-			return err
-		}
-		return nil
-	},
-}
-
-func containerConfigFromContext(context *cli.Context) (*containerConfig, error) {
-	id := context.Args().First()
-	pidFile, err := absPathOrEmpty(context.String("pid-file"))
-	if err != nil {
-		return nil, err
-	}
-	shimLog, err := absPathOrEmpty(context.String("shim-log"))
-	if err != nil {
-		return nil, err
-	}
-	vmLog, err := absPathOrEmpty(context.String("vm-log"))
-	if err != nil {
-		return nil, err
-	}
-	spec, err := setupSpec(context)
-	if err != nil {
-		return nil, err
-	}
-	return &containerConfig{
-		ID:            id,
-		Owner:         context.GlobalString("owner"),
-		PidFile:       pidFile,
-		ShimLogFile:   shimLog,
-		VMLogFile:     vmLog,
-		VMConsolePipe: context.String("vm-console"),
-		Spec:          spec,
-		HostID:        context.String("host"),
-	}, nil
-}

+ 0 - 73
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/delete.go

@@ -1,73 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"os"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/regstate"
-	"github.com/urfave/cli"
-)
-
-var deleteCommand = cli.Command{
-	Name:  "delete",
-	Usage: "delete any resources held by the container often used with detached container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is the name for the instance of the container.
-
-EXAMPLE:
-For example, if the container id is "ubuntu01" and runhcs list currently shows the
-status of "ubuntu01" as "stopped" the following will delete resources held for
-"ubuntu01" removing "ubuntu01" from the runhcs list of containers:
-
-       # runhcs delete ubuntu01`,
-	Flags: []cli.Flag{
-		cli.BoolFlag{
-			Name:  "force, f",
-			Usage: "Forcibly deletes the container if it is still running (uses SIGKILL)",
-		},
-	},
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		force := context.Bool("force")
-		container, err := getContainer(id, false)
-		if err != nil {
-			if _, ok := err.(*regstate.NoStateError); ok {
-				if e := stateKey.Remove(id); e != nil {
-					fmt.Fprintf(os.Stderr, "remove %s: %v\n", id, e)
-				}
-				if force {
-					return nil
-				}
-			}
-			return err
-		}
-		defer container.Close()
-		s, err := container.Status()
-		if err != nil {
-			return err
-		}
-
-		kill := false
-		switch s {
-		case containerStopped:
-		case containerCreated:
-			kill = true
-		default:
-			if !force {
-				return fmt.Errorf("cannot delete container %s that is not stopped: %s\n", id, s)
-			}
-			kill = true
-		}
-
-		if kill {
-			err = container.Kill()
-			if err != nil {
-				return err
-			}
-		}
-		return container.Remove()
-	},
-}

+ 0 - 160
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/exec.go

@@ -1,160 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"os"
-	"path/filepath"
-	"strings"
-	"syscall"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/urfave/cli"
-)
-
-var execCommand = cli.Command{
-	Name:  "exec",
-	Usage: "execute new process inside the container",
-	ArgsUsage: `<container-id> <command> [command options]  || -p process.json <container-id>
-
-Where "<container-id>" is the name for the instance of the container and
-"<command>" is the command to be executed in the container.
-"<command>" can't be empty unless a "-p" flag provided.
-
-EXAMPLE:
-For example, if the container is configured to run the linux ps command the
-following will output a list of processes running in the container:
-
-    	# runhcs exec <container-id> ps`,
-	Flags: []cli.Flag{
-		cli.StringFlag{
-			Name:  "cwd",
-			Usage: "current working directory in the container",
-		},
-		cli.StringSliceFlag{
-			Name:  "env, e",
-			Usage: "set environment variables",
-		},
-		cli.BoolFlag{
-			Name:  "tty, t",
-			Usage: "allocate a pseudo-TTY",
-		},
-		cli.StringFlag{
-			Name: "user, u",
-		},
-		cli.StringFlag{
-			Name:  "process, p",
-			Usage: "path to the process.json",
-		},
-		cli.BoolFlag{
-			Name:  "detach,d",
-			Usage: "detach from the container's process",
-		},
-		cli.StringFlag{
-			Name:  "pid-file",
-			Value: "",
-			Usage: "specify the file to write the process id to",
-		},
-		cli.StringFlag{
-			Name:  "shim-log",
-			Value: "",
-			Usage: `path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-<exec-id>-log) for the launched shim process`,
-		},
-	},
-	Before: appargs.Validate(argID, appargs.Rest(appargs.String)),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		pidFile, err := absPathOrEmpty(context.String("pid-file"))
-		if err != nil {
-			return err
-		}
-		shimLog, err := absPathOrEmpty(context.String("shim-log"))
-		if err != nil {
-			return err
-		}
-		c, err := getContainer(id, false)
-		if err != nil {
-			return err
-		}
-		defer c.Close()
-		status, err := c.Status()
-		if err != nil {
-			return err
-		}
-		if status != containerRunning {
-			return errContainerStopped
-		}
-		spec, err := getProcessSpec(context, c)
-		if err != nil {
-			return err
-		}
-		p, err := startProcessShim(id, pidFile, shimLog, spec)
-		if err != nil {
-			return err
-		}
-		if !context.Bool("detach") {
-			state, err := p.Wait()
-			if err != nil {
-				return err
-			}
-			os.Exit(int(state.Sys().(syscall.WaitStatus).ExitCode))
-		}
-		return nil
-	},
-	SkipArgReorder: true,
-}
-
-func getProcessSpec(context *cli.Context, c *container) (*specs.Process, error) {
-	if path := context.String("process"); path != "" {
-		f, err := os.Open(path)
-		if err != nil {
-			return nil, err
-		}
-		defer f.Close()
-		var p specs.Process
-		if err := json.NewDecoder(f).Decode(&p); err != nil {
-			return nil, err
-		}
-		return &p, validateProcessSpec(&p)
-	}
-
-	// process via cli flags
-	p := c.Spec.Process
-
-	if len(context.Args()) == 1 {
-		return nil, fmt.Errorf("process args cannot be empty")
-	}
-	p.Args = context.Args()[1:]
-	// override the cwd, if passed
-	if context.String("cwd") != "" {
-		p.Cwd = context.String("cwd")
-	}
-	// append the passed env variables
-	p.Env = append(p.Env, context.StringSlice("env")...)
-
-	// set the tty
-	if context.IsSet("tty") {
-		p.Terminal = context.Bool("tty")
-	}
-	// override the user, if passed
-	if context.String("user") != "" {
-		p.User.Username = context.String("user")
-	}
-	return p, nil
-}
-
-func validateProcessSpec(spec *specs.Process) error {
-	if spec.Cwd == "" {
-		return fmt.Errorf("Cwd property must not be empty")
-	}
-	// IsAbs doesnt recognize Unix paths on Windows builds so handle that case
-	// here.
-	if !filepath.IsAbs(spec.Cwd) && !strings.HasPrefix(spec.Cwd, "/") {
-		return fmt.Errorf("Cwd must be an absolute path")
-	}
-	if len(spec.Args) == 0 {
-		return fmt.Errorf("args must not be empty")
-	}
-	return nil
-}

+ 0 - 193
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill.go

@@ -1,193 +0,0 @@
-package main
-
-import (
-	"strconv"
-	"strings"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/guestrequest"
-	"github.com/Microsoft/hcsshim/internal/hcs"
-	"github.com/Microsoft/hcsshim/internal/schema1"
-	"github.com/Microsoft/hcsshim/osversion"
-	"github.com/pkg/errors"
-	"github.com/urfave/cli"
-)
-
-var killCommand = cli.Command{
-	Name:  "kill",
-	Usage: "kill sends the specified signal (default: SIGTERM) to the container's init process",
-	ArgsUsage: `<container-id> [signal]
-
-Where "<container-id>" is the name for the instance of the container and
-"[signal]" is the signal to be sent to the init process.
-
-EXAMPLE:
-For example, if the container id is "ubuntu01" the following will send a "KILL"
-signal to the init process of the "ubuntu01" container:
-
-       # runhcs kill ubuntu01 KILL`,
-	Flags:  []cli.Flag{},
-	Before: appargs.Validate(argID, appargs.Optional(appargs.String)),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		c, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer c.Close()
-		status, err := c.Status()
-		if err != nil {
-			return err
-		}
-		if status != containerRunning {
-			return errContainerStopped
-		}
-
-		signalsSupported := false
-
-		// The Signal feature was added in RS5
-		if osversion.Get().Build >= osversion.RS5 {
-			if c.IsHost || c.HostID != "" {
-				var hostID string
-				if c.IsHost {
-					// This is the LCOW, Pod Sandbox, or Windows Xenon V2 for RS5+
-					hostID = vmID(c.ID)
-				} else {
-					// This is the Nth container in a Pod
-					hostID = c.HostID
-				}
-				uvm, err := hcs.OpenComputeSystem(hostID)
-				if err != nil {
-					return err
-				}
-				defer uvm.Close()
-				if props, err := uvm.Properties(schema1.PropertyTypeGuestConnection); err == nil &&
-					props.GuestConnectionInfo.GuestDefinedCapabilities.SignalProcessSupported {
-					signalsSupported = true
-				}
-			} else if c.Spec.Linux == nil && c.Spec.Windows.HyperV == nil {
-				// RS5+ Windows Argon
-				signalsSupported = true
-			}
-		}
-
-		signal := 0
-		if signalsSupported {
-			signal, err = validateSigstr(context.Args().Get(1), signalsSupported, c.Spec.Linux != nil)
-			if err != nil {
-				return err
-			}
-		}
-
-		var pid int
-		if err := stateKey.Get(id, keyInitPid, &pid); err != nil {
-			return err
-		}
-
-		p, err := c.hc.OpenProcess(pid)
-		if err != nil {
-			return err
-		}
-		defer p.Close()
-
-		if signalsSupported && (c.Spec.Linux != nil || !c.Spec.Process.Terminal) {
-			opts := guestrequest.SignalProcessOptions{
-				Signal: signal,
-			}
-			return p.Signal(opts)
-		}
-
-		// Legacy signal issue a kill
-		return p.Kill()
-	},
-}
-
-func validateSigstr(sigstr string, signalsSupported bool, isLcow bool) (int, error) {
-	errInvalidSignal := errors.Errorf("invalid signal '%s'", sigstr)
-
-	// All flavors including legacy default to SIGTERM on LCOW CtrlC on Windows
-	if sigstr == "" {
-		if isLcow {
-			return 0xf, nil
-		}
-		return 0, nil
-	}
-
-	sigstr = strings.ToUpper(sigstr)
-
-	if !signalsSupported {
-		// If signals arent supported we just validate that its a known signal.
-		// We already return 0 since we only supported a platform Kill() at that
-		// time.
-		if isLcow {
-			switch sigstr {
-			case "15":
-				fallthrough
-			case "TERM":
-				fallthrough
-			case "SIGTERM":
-				return 0, nil
-			default:
-				return 0, errInvalidSignal
-			}
-		}
-		switch sigstr {
-		// Docker sends a UNIX term in the supported Windows Signal map.
-		case "15":
-			fallthrough
-		case "TERM":
-			fallthrough
-		case "0":
-			fallthrough
-		case "CTRLC":
-			return 0, nil
-		case "9":
-			fallthrough
-		case "KILL":
-			return 0, nil
-		default:
-			return 0, errInvalidSignal
-		}
-	} else {
-		if !isLcow {
-			// Docker sends the UNIX signal name or value. Convert them to the
-			// correct Windows signals.
-			switch sigstr {
-			case "15":
-				fallthrough
-			case "TERM":
-				return 0x0, nil // Convert to CTRLC
-			case "9":
-				fallthrough
-			case "KILL":
-				return 0x6, nil // Convert to CTRLSHUTDOWN
-			}
-		}
-	}
-
-	var sigmap map[string]int
-	if isLcow {
-		sigmap = signalMapLcow
-	} else {
-		sigmap = signalMapWindows
-	}
-
-	signal, err := strconv.Atoi(sigstr)
-	if err != nil {
-		// Signal might still match the string value
-		for k, v := range sigmap {
-			if k == sigstr {
-				return v, nil
-			}
-		}
-		return 0, errInvalidSignal
-	}
-
-	// Match signal by value
-	for _, v := range sigmap {
-		if signal == v {
-			return signal, nil
-		}
-	}
-	return 0, errInvalidSignal
-}

+ 0 - 111
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/kill_test.go

@@ -1,111 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"strconv"
-	"strings"
-	"testing"
-)
-
-func runValidateSigstrTest(sigstr string, signalsSupported, isLcow bool,
-	expectedSignal int, expectedError bool, t *testing.T) {
-	signal, err := validateSigstr(sigstr, signalsSupported, isLcow)
-	if expectedError {
-		if err == nil {
-			t.Fatalf("Expected err: %v, got: nil", expectedError)
-		} else if err.Error() != fmt.Sprintf("invalid signal '%s'", sigstr) {
-			t.Fatalf("Expected err: %v, got: %v", expectedError, err)
-		}
-	}
-	if signal != expectedSignal {
-		t.Fatalf("Test - Signal: %s, Support: %v, LCOW: %v\nExpected signal: %v, got: %v",
-			sigstr, signalsSupported, isLcow,
-			expectedSignal, signal)
-	}
-}
-
-func Test_ValidateSigstr_Empty(t *testing.T) {
-	runValidateSigstrTest("", false, false, 0, false, t)
-	runValidateSigstrTest("", false, true, 0xf, false, t)
-	runValidateSigstrTest("", true, false, 0, false, t)
-	runValidateSigstrTest("", true, true, 0xf, false, t)
-}
-
-func Test_ValidateSigstr_LCOW_NoSignalSupport_Default(t *testing.T) {
-	runValidateSigstrTest("15", false, true, 0, false, t)
-	runValidateSigstrTest("TERM", false, true, 0, false, t)
-	runValidateSigstrTest("SIGTERM", false, true, 0, false, t)
-}
-
-func Test_ValidateSigstr_LCOW_NoSignalSupport_Default_Invalid(t *testing.T) {
-	runValidateSigstrTest("2", false, true, 0, true, t)
-	runValidateSigstrTest("test", false, true, 0, true, t)
-}
-
-func Test_ValidateSigstr_WCOW_NoSignalSupport_Default(t *testing.T) {
-	runValidateSigstrTest("15", false, false, 0, false, t)
-	runValidateSigstrTest("TERM", false, false, 0, false, t)
-	runValidateSigstrTest("0", false, false, 0, false, t)
-	runValidateSigstrTest("CTRLC", false, false, 0, false, t)
-	runValidateSigstrTest("9", false, false, 0, false, t)
-	runValidateSigstrTest("KILL", false, false, 0, false, t)
-}
-
-func Test_ValidateSigstr_WCOW_NoSignalSupport_Default_Invalid(t *testing.T) {
-	runValidateSigstrTest("2", false, false, 0, true, t)
-	runValidateSigstrTest("test", false, false, 0, true, t)
-}
-
-func Test_ValidateSigstr_LCOW_SignalSupport_SignalNames(t *testing.T) {
-	for k, v := range signalMapLcow {
-		runValidateSigstrTest(k, true, true, v, false, t)
-		// run it again with a case not in the map
-		lc := strings.ToLower(k)
-		if k == lc {
-			t.Fatalf("Expected lower casing - map: %v, got: %v", k, lc)
-		}
-		runValidateSigstrTest(lc, true, true, v, false, t)
-	}
-}
-
-func Test_ValidateSigstr_WCOW_SignalSupport_SignalNames(t *testing.T) {
-	for k, v := range signalMapWindows {
-		runValidateSigstrTest(k, true, false, v, false, t)
-		// run it again with a case not in the map
-		lc := strings.ToLower(k)
-		if k == lc {
-			t.Fatalf("Expected lower casing - map: %v, got: %v", k, lc)
-		}
-		runValidateSigstrTest(lc, true, false, v, false, t)
-	}
-}
-
-func Test_ValidateSigstr_LCOW_SignalSupport_SignalValues(t *testing.T) {
-	for _, v := range signalMapLcow {
-		str := strconv.Itoa(v)
-		runValidateSigstrTest(str, true, true, v, false, t)
-	}
-}
-
-func Test_ValidateSigstr_WCOW_SignalSupport_SignalValues(t *testing.T) {
-	for _, v := range signalMapWindows {
-		str := strconv.Itoa(v)
-		runValidateSigstrTest(str, true, false, v, false, t)
-	}
-}
-
-func Test_ValidateSigstr_WCOW_SignalSupport_Docker_SignalNames(t *testing.T) {
-	// Docker KILL -> CTRLSHUTDOWN when signals are supported
-	runValidateSigstrTest("KILL", true, false, 0x6, false, t)
-
-	// Docker TERM -> CTRLSHUTDOWN when signals are supported
-	runValidateSigstrTest("TERM", true, false, 0x0, false, t)
-}
-
-func Test_ValidateSigstr_WCOW_SignalSupport_Docker_SignalValues(t *testing.T) {
-	// Docker KILL -> CTRLSHUTDOWN when signals are supported
-	runValidateSigstrTest("9", true, false, 0x6, false, t)
-
-	// Docker TERM -> CTRLSHUTDOWN when signals are supported
-	runValidateSigstrTest("15", true, false, 0x0, false, t)
-}

+ 0 - 116
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/list.go

@@ -1,116 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"os"
-	"text/tabwriter"
-	"time"
-
-	"encoding/json"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/urfave/cli"
-)
-
-const formatOptions = `table or json`
-
-var listCommand = cli.Command{
-	Name:  "list",
-	Usage: "lists containers started by runhcs with the given root",
-	ArgsUsage: `
-
-Where the given root is specified via the global option "--root"
-(default: "/run/runhcs").
-
-EXAMPLE 1:
-To list containers created via the default "--root":
-       # runhcs list
-
-EXAMPLE 2:
-To list containers created using a non-default value for "--root":
-       # runhcs --root value list`,
-	Flags: []cli.Flag{
-		cli.StringFlag{
-			Name:  "format, f",
-			Value: "table",
-			Usage: `select one of: ` + formatOptions,
-		},
-		cli.BoolFlag{
-			Name:  "quiet, q",
-			Usage: "display only container IDs",
-		},
-	},
-	Before: appargs.Validate(),
-	Action: func(context *cli.Context) error {
-		s, err := getContainers(context)
-		if err != nil {
-			return err
-		}
-
-		if context.Bool("quiet") {
-			for _, item := range s {
-				fmt.Println(item.ID)
-			}
-			return nil
-		}
-
-		switch context.String("format") {
-		case "table":
-			w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
-			fmt.Fprint(w, "ID\tPID\tSTATUS\tBUNDLE\tCREATED\tOWNER\n")
-			for _, item := range s {
-				fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\n",
-					item.ID,
-					item.InitProcessPid,
-					item.Status,
-					item.Bundle,
-					item.Created.Format(time.RFC3339Nano),
-					item.Owner)
-			}
-			if err := w.Flush(); err != nil {
-				return err
-			}
-		case "json":
-			if err := json.NewEncoder(os.Stdout).Encode(s); err != nil {
-				return err
-			}
-		default:
-			return fmt.Errorf("invalid format option")
-		}
-		return nil
-	},
-}
-
-func getContainers(context *cli.Context) ([]runhcs.ContainerState, error) {
-	ids, err := stateKey.Enumerate()
-	if err != nil {
-		return nil, err
-	}
-
-	var s []runhcs.ContainerState
-	for _, id := range ids {
-		c, err := getContainer(id, false)
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "reading state for %s: %v\n", id, err)
-			continue
-		}
-		status, err := c.Status()
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "reading status for %s: %v\n", id, err)
-		}
-
-		s = append(s, runhcs.ContainerState{
-			ID:             id,
-			Version:        c.Spec.Version,
-			InitProcessPid: c.ShimPid,
-			Status:         string(status),
-			Bundle:         c.Bundle,
-			Rootfs:         c.Rootfs,
-			Created:        c.Created,
-			Annotations:    c.Spec.Annotations,
-		})
-		c.Close()
-	}
-	return s, nil
-}

+ 0 - 174
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/main.go

@@ -1,174 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"io"
-	"os"
-	"strings"
-
-	"github.com/Microsoft/go-winio"
-	"github.com/Microsoft/go-winio/pkg/etwlogrus"
-	"github.com/Microsoft/hcsshim/internal/regstate"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/sirupsen/logrus"
-	"github.com/urfave/cli"
-)
-
-// Add a manifest to get proper Windows version detection.
-//
-// goversioninfo can be installed with "go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo"
-
-//go:generate goversioninfo -platform-specific
-
-// version will be populated by the Makefile, read from
-// VERSION file of the source code.
-var version = ""
-
-// gitCommit will be the hash that the binary was built from
-// and will be populated by the Makefile
-var gitCommit = ""
-
-var stateKey *regstate.Key
-
-var logFormat string
-
-const (
-	specConfig = "config.json"
-	usage      = `Open Container Initiative runtime for Windows
-
-runhcs is a fork of runc, modified to run containers on Windows with or without Hyper-V isolation.  Like runc, it is a command line client for running applications packaged according to the Open Container Initiative (OCI) format.
-
-runhcs integrates with existing process supervisors to provide a production container runtime environment for applications. It can be used with your existing process monitoring tools and the container will be spawned as a direct child of the process supervisor.
-
-Containers are configured using bundles. A bundle for a container is a directory that includes a specification file named "` + specConfig + `".  Bundle contents will depend on the container type.
-
-To start a new instance of a container:
-
-    # runhcs run [ -b bundle ] <container-id>
-
-Where "<container-id>" is your name for the instance of the container that you are starting. The name you provide for the container instance must be unique on your host. Providing the bundle directory using "-b" is optional. The default value for "bundle" is the current directory.`
-)
-
-func main() {
-	// Provider ID: 0b52781f-b24d-5685-ddf6-69830ed40ec3
-	// Hook isn't closed explicitly, as it will exist until process exit.
-	if hook, err := etwlogrus.NewHook("Microsoft.Virtualization.RunHCS"); err == nil {
-		logrus.AddHook(hook)
-	} else {
-		logrus.Error(err)
-	}
-
-	app := cli.NewApp()
-	app.Name = "runhcs"
-	app.Usage = usage
-
-	var v []string
-	if version != "" {
-		v = append(v, version)
-	}
-	if gitCommit != "" {
-		v = append(v, fmt.Sprintf("commit: %s", gitCommit))
-	}
-	v = append(v, fmt.Sprintf("spec: %s", specs.Version))
-	app.Version = strings.Join(v, "\n")
-
-	app.Flags = []cli.Flag{
-		cli.BoolFlag{
-			Name:  "debug",
-			Usage: "enable debug output for logging",
-		},
-		cli.StringFlag{
-			Name:  "log",
-			Value: "nul",
-			Usage: `set the log file path or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-log) where internal debug information is written`,
-		},
-		cli.StringFlag{
-			Name:  "log-format",
-			Value: "text",
-			Usage: "set the format used by logs ('text' (default), or 'json')",
-		},
-		cli.StringFlag{
-			Name:  "owner",
-			Value: "runhcs",
-			Usage: "compute system owner",
-		},
-		cli.StringFlag{
-			Name:  "root",
-			Value: "default",
-			Usage: "registry key for storage of container state",
-		},
-	}
-	app.Commands = []cli.Command{
-		createCommand,
-		createScratchCommand,
-		deleteCommand,
-		// eventsCommand,
-		execCommand,
-		killCommand,
-		listCommand,
-		pauseCommand,
-		psCommand,
-		resizeTtyCommand,
-		resumeCommand,
-		runCommand,
-		shimCommand,
-		startCommand,
-		stateCommand,
-		// updateCommand,
-		vmshimCommand,
-	}
-	app.Before = func(context *cli.Context) error {
-		if context.GlobalBool("debug") {
-			logrus.SetLevel(logrus.DebugLevel)
-		}
-		if path := context.GlobalString("log"); path != "" {
-			var f io.Writer
-			var err error
-			if strings.HasPrefix(path, runhcs.SafePipePrefix) {
-				f, err = winio.DialPipe(path, nil)
-			} else {
-				f, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_SYNC, 0666)
-			}
-			if err != nil {
-				return err
-			}
-			logrus.SetOutput(f)
-		}
-		switch logFormat = context.GlobalString("log-format"); logFormat {
-		case "text":
-			// retain logrus's default.
-		case "json":
-			logrus.SetFormatter(new(logrus.JSONFormatter))
-		default:
-			return fmt.Errorf("unknown log-format %q", logFormat)
-		}
-
-		var err error
-		stateKey, err = regstate.Open(context.GlobalString("root"), false)
-		if err != nil {
-			return err
-		}
-		return nil
-	}
-	// If the command returns an error, cli takes upon itself to print
-	// the error on cli.ErrWriter and exit.
-	// Use our own writer here to ensure the log gets sent to the right location.
-	fatalWriter.Writer = cli.ErrWriter
-	cli.ErrWriter = &fatalWriter
-	if err := app.Run(os.Args); err != nil {
-		fmt.Fprintln(cli.ErrWriter, err)
-		os.Exit(1)
-	}
-}
-
-type logErrorWriter struct {
-	Writer io.Writer
-}
-
-var fatalWriter logErrorWriter
-
-func (f *logErrorWriter) Write(p []byte) (n int, err error) {
-	logrus.Error(string(p))
-	return f.Writer.Write(p)
-}

+ 0 - 58
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/pause.go

@@ -1,58 +0,0 @@
-package main
-
-import (
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var pauseCommand = cli.Command{
-	Name:  "pause",
-	Usage: "pause suspends all processes inside the container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is the name for the instance of the container to be
-paused. `,
-	Description: `The pause command suspends all processes in the instance of the container.
-
-Use runhcs list to identify instances of containers and their current status.`,
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		container, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer container.Close()
-		if err := container.hc.Pause(); err != nil {
-			return err
-		}
-
-		return nil
-	},
-}
-
-var resumeCommand = cli.Command{
-	Name:  "resume",
-	Usage: "resumes all processes that have been previously paused",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is the name for the instance of the container to be
-resumed.`,
-	Description: `The resume command resumes all processes in the instance of the container.
-
-Use runhcs list to identify instances of containers and their current status.`,
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		container, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer container.Close()
-		if err := container.hc.Resume(); err != nil {
-			return err
-		}
-
-		return nil
-	},
-}

+ 0 - 51
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/ps.go

@@ -1,51 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"os"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/schema1"
-	"github.com/urfave/cli"
-)
-
-var psCommand = cli.Command{
-	Name:      "ps",
-	Usage:     "ps displays the processes running inside a container",
-	ArgsUsage: `<container-id> [ps options]`,
-	Flags: []cli.Flag{
-		cli.StringFlag{
-			Name:  "format, f",
-			Value: "json",
-			Usage: `select one of: ` + formatOptions,
-		},
-	},
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		container, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer container.Close()
-
-		props, err := container.hc.Properties(schema1.PropertyTypeProcessList)
-		if err != nil {
-			return err
-		}
-
-		var pids []int
-		for _, p := range props.ProcessList {
-			pids = append(pids, int(p.ProcessId))
-		}
-
-		switch context.String("format") {
-		case "json":
-			return json.NewEncoder(os.Stdout).Encode(pids)
-		default:
-			return fmt.Errorf("invalid format option")
-		}
-	},
-	SkipArgReorder: true,
-}

BIN
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/resource_windows_386.syso


BIN
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/resource_windows_amd64.syso


+ 0 - 64
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/run.go

@@ -1,64 +0,0 @@
-package main
-
-import (
-	"os"
-	"syscall"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-// default action is to start a container
-var runCommand = cli.Command{
-	Name:  "run",
-	Usage: "create and run a container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is your name for the instance of the container that you
-are starting. The name you provide for the container instance must be unique on
-your host.`,
-	Description: `The run command creates an instance of a container for a bundle. The bundle
-is a directory with a specification file named "` + specConfig + `" and a root
-filesystem.
-
-The specification file includes an args parameter. The args parameter is used
-to specify command(s) that get run when the container is started. To change the
-command(s) that get executed on start, edit the args parameter of the spec.`,
-	Flags: append(createRunFlags,
-		cli.BoolFlag{
-			Name:  "detach, d",
-			Usage: "detach from the container's process",
-		},
-	),
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		cfg, err := containerConfigFromContext(context)
-		if err != nil {
-			return err
-		}
-		c, err := createContainer(cfg)
-		if err != nil {
-			return err
-		}
-		if err != nil {
-			return err
-		}
-		p, err := os.FindProcess(c.ShimPid)
-		if err != nil {
-			return err
-		}
-		err = c.Exec()
-		if err != nil {
-			return err
-		}
-		if !context.Bool("detach") {
-			state, err := p.Wait()
-			if err != nil {
-				return err
-			}
-			c.Remove()
-			os.Exit(int(state.Sys().(syscall.WaitStatus).ExitCode))
-		}
-		return nil
-	},
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/runhcs.exe.manifest

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-    <description>runhcs</description>
-    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
-        <application>
-            <!-- Windows 10 -->
-            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
-        </application>
-    </compatibility>
-</assembly>

+ 0 - 323
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/shim.go

@@ -1,323 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"net"
-	"os"
-	"strings"
-	"sync"
-	"time"
-
-	winio "github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/hcs"
-	"github.com/Microsoft/hcsshim/internal/lcow"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/Microsoft/hcsshim/internal/schema2"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/sirupsen/logrus"
-	"github.com/urfave/cli"
-	"golang.org/x/sys/windows"
-)
-
-func containerPipePath(id string) string {
-	return runhcs.SafePipePath("runhcs-shim-" + id)
-}
-
-func newFile(context *cli.Context, param string) *os.File {
-	fd := uintptr(context.Int(param))
-	if fd == 0 {
-		return nil
-	}
-	return os.NewFile(fd, "")
-}
-
-var shimCommand = cli.Command{
-	Name:   "shim",
-	Usage:  `launch the process and proxy stdio (do not call it outside of runhcs)`,
-	Hidden: true,
-	Flags: []cli.Flag{
-		&cli.IntFlag{Name: "stdin", Hidden: true},
-		&cli.IntFlag{Name: "stdout", Hidden: true},
-		&cli.IntFlag{Name: "stderr", Hidden: true},
-		&cli.BoolFlag{Name: "exec", Hidden: true},
-		cli.StringFlag{Name: "log-pipe", Hidden: true},
-	},
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		logPipe := context.String("log-pipe")
-		if logPipe != "" {
-			lpc, err := winio.DialPipe(logPipe, nil)
-			if err != nil {
-				return err
-			}
-			defer lpc.Close()
-			logrus.SetOutput(lpc)
-		} else {
-			logrus.SetOutput(os.Stderr)
-		}
-		fatalWriter.Writer = os.Stdout
-
-		id := context.Args().First()
-		c, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer c.Close()
-
-		// Asynchronously wait for the container to exit.
-		containerExitCh := make(chan error)
-		go func() {
-			containerExitCh <- c.hc.Wait()
-		}()
-
-		// Get File objects for the open stdio files passed in as arguments.
-		stdin := newFile(context, "stdin")
-		stdout := newFile(context, "stdout")
-		stderr := newFile(context, "stderr")
-
-		exec := context.Bool("exec")
-		terminateOnFailure := false
-
-		errorOut := io.WriteCloser(os.Stdout)
-
-		var spec *specs.Process
-
-		if exec {
-			// Read the process spec from stdin.
-			specj, err := ioutil.ReadAll(os.Stdin)
-			if err != nil {
-				return err
-			}
-			os.Stdin.Close()
-
-			spec = new(specs.Process)
-			err = json.Unmarshal(specj, spec)
-			if err != nil {
-				return err
-			}
-
-		} else {
-			// Stdin is not used.
-			os.Stdin.Close()
-
-			// Listen on the named pipe associated with this container.
-			l, err := winio.ListenPipe(c.ShimPipePath(), nil)
-			if err != nil {
-				return err
-			}
-
-			// Alert the parent process that initialization has completed
-			// successfully.
-			errorOut.Write(runhcs.ShimSuccess)
-			errorOut.Close()
-			fatalWriter.Writer = ioutil.Discard
-
-			// When this process exits, clear this process's pid in the registry.
-			defer func() {
-				stateKey.Set(id, keyShimPid, 0)
-			}()
-
-			defer func() {
-				if terminateOnFailure {
-					if err = c.hc.Terminate(); hcs.IsPending(err) {
-						<-containerExitCh
-					}
-				}
-			}()
-			terminateOnFailure = true
-
-			// Wait for a connection to the named pipe, exiting if the container
-			// exits before this happens.
-			var pipe net.Conn
-			pipeCh := make(chan error)
-			go func() {
-				var err error
-				pipe, err = l.Accept()
-				pipeCh <- err
-			}()
-
-			select {
-			case err = <-pipeCh:
-				if err != nil {
-					return err
-				}
-			case err = <-containerExitCh:
-				if err != nil {
-					return err
-				}
-				return cli.NewExitError("", 1)
-			}
-
-			// The next set of errors goes to the open pipe connection.
-			errorOut = pipe
-			fatalWriter.Writer = pipe
-
-			// The process spec comes from the original container spec.
-			spec = c.Spec.Process
-		}
-
-		// Create the process in the container.
-		var wpp *hcsschema.ProcessParameters // Windows Process Parameters
-		var lpp *lcow.ProcessParameters      // Linux Process Parameters
-
-		var p *hcs.Process
-
-		if c.Spec.Linux == nil {
-			environment := make(map[string]string)
-			for _, v := range spec.Env {
-				s := strings.SplitN(v, "=", 2)
-				if len(s) == 2 && len(s[1]) > 0 {
-					environment[s[0]] = s[1]
-				}
-			}
-			wpp = &hcsschema.ProcessParameters{
-				WorkingDirectory: spec.Cwd,
-				EmulateConsole:   spec.Terminal,
-				Environment:      environment,
-				User:             spec.User.Username,
-			}
-			for i, arg := range spec.Args {
-				e := windows.EscapeArg(arg)
-				if i == 0 {
-					wpp.CommandLine = e
-				} else {
-					wpp.CommandLine += " " + e
-				}
-			}
-			if spec.ConsoleSize != nil {
-				wpp.ConsoleSize = []int32{
-					int32(spec.ConsoleSize.Height),
-					int32(spec.ConsoleSize.Width),
-				}
-			}
-
-			wpp.CreateStdInPipe = stdin != nil
-			wpp.CreateStdOutPipe = stdout != nil
-			wpp.CreateStdErrPipe = stderr != nil
-
-			p, err = c.hc.CreateProcess(wpp)
-
-		} else {
-			lpp = &lcow.ProcessParameters{}
-			if exec {
-				lpp.OCIProcess = spec
-			}
-
-			lpp.CreateStdInPipe = stdin != nil
-			lpp.CreateStdOutPipe = stdout != nil
-			lpp.CreateStdErrPipe = stderr != nil
-
-			p, err = c.hc.CreateProcess(lpp)
-		}
-
-		if err != nil {
-			return err
-		}
-
-		cstdin, cstdout, cstderr, err := p.Stdio()
-		if err != nil {
-			return err
-		}
-
-		if !exec {
-			err = stateKey.Set(c.ID, keyInitPid, p.Pid())
-			if err != nil {
-				return err
-			}
-		}
-
-		// Store the Guest pid map
-		err = stateKey.Set(c.ID, fmt.Sprintf(keyPidMapFmt, os.Getpid()), p.Pid())
-		if err != nil {
-			return err
-		}
-		defer func() {
-			// Remove the Guest pid map when this process is cleaned up
-			stateKey.Clear(c.ID, fmt.Sprintf(keyPidMapFmt, os.Getpid()))
-		}()
-
-		terminateOnFailure = false
-
-		// Alert the connected process that the process was launched
-		// successfully.
-		errorOut.Write(runhcs.ShimSuccess)
-		errorOut.Close()
-		fatalWriter.Writer = ioutil.Discard
-
-		// Relay stdio.
-		var wg sync.WaitGroup
-		if cstdin != nil {
-			go func() {
-				io.Copy(cstdin, stdin)
-				cstdin.Close()
-				p.CloseStdin()
-			}()
-		}
-
-		if cstdout != nil {
-			wg.Add(1)
-			go func() {
-				io.Copy(stdout, cstdout)
-				stdout.Close()
-				cstdout.Close()
-				wg.Done()
-			}()
-		}
-
-		if cstderr != nil {
-			wg.Add(1)
-			go func() {
-				io.Copy(stderr, cstderr)
-				stderr.Close()
-				cstderr.Close()
-				wg.Done()
-			}()
-		}
-
-		err = p.Wait()
-		wg.Wait()
-
-		// Attempt to get the exit code from the process.
-		code := 1
-		if err == nil {
-			code, err = p.ExitCode()
-			if err != nil {
-				code = 1
-			}
-		}
-
-		if !exec {
-			// Shutdown the container, waiting 5 minutes before terminating is
-			// forcefully.
-			const shutdownTimeout = time.Minute * 5
-			waited := false
-			err = c.hc.Shutdown()
-			if hcs.IsPending(err) {
-				select {
-				case err = <-containerExitCh:
-					waited = true
-				case <-time.After(shutdownTimeout):
-					err = hcs.ErrTimeout
-				}
-			}
-			if hcs.IsAlreadyStopped(err) {
-				err = nil
-			}
-
-			if err != nil {
-				err = c.hc.Terminate()
-				if waited {
-					err = c.hc.Wait()
-				} else {
-					err = <-containerExitCh
-				}
-			}
-		}
-
-		return cli.NewExitError("", code)
-	},
-}

+ 0 - 46
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/signalmap.go

@@ -1,46 +0,0 @@
-package main
-
-var signalMapLcow = map[string]int{
-	"ABRT":   0x6,
-	"ALRM":   0xe,
-	"BUS":    0x7,
-	"CHLD":   0x11,
-	"CLD":    0x11,
-	"CONT":   0x12,
-	"FPE":    0x8,
-	"HUP":    0x1,
-	"ILL":    0x4,
-	"INT":    0x2,
-	"IO":     0x1d,
-	"IOT":    0x6,
-	"KILL":   0x9,
-	"PIPE":   0xd,
-	"POLL":   0x1d,
-	"PROF":   0x1b,
-	"PWR":    0x1e,
-	"QUIT":   0x3,
-	"SEGV":   0xb,
-	"STKFLT": 0x10,
-	"STOP":   0x13,
-	"SYS":    0x1f,
-	"TERM":   0xf,
-	"TRAP":   0x5,
-	"TSTP":   0x14,
-	"TTIN":   0x15,
-	"TTOU":   0x16,
-	"URG":    0x17,
-	"USR1":   0xa,
-	"USR2":   0xc,
-	"VTALRM": 0x1a,
-	"WINCH":  0x1c,
-	"XCPU":   0x18,
-	"XFSZ":   0x19,
-}
-
-var signalMapWindows = map[string]int{
-	"CTRLC":        0x0,
-	"CTRLBREAK":    0x1,
-	"CTRLCLOSE":    0x2,
-	"CTRLLOGOFF":   0x5,
-	"CTRLSHUTDOWN": 0x6,
-}

+ 0 - 42
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/spec.go

@@ -1,42 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"os"
-
-	"github.com/opencontainers/runtime-spec/specs-go"
-	"github.com/urfave/cli"
-)
-
-// loadSpec loads the specification from the provided path.
-func loadSpec(cPath string) (spec *specs.Spec, err error) {
-	cf, err := os.Open(cPath)
-	if err != nil {
-		if os.IsNotExist(err) {
-			return nil, fmt.Errorf("JSON specification file %s not found", cPath)
-		}
-		return nil, err
-	}
-	defer cf.Close()
-
-	if err = json.NewDecoder(cf).Decode(&spec); err != nil {
-		return nil, err
-	}
-	return spec, nil
-}
-
-// setupSpec performs initial setup based on the cli.Context for the container
-func setupSpec(context *cli.Context) (*specs.Spec, error) {
-	bundle := context.String("bundle")
-	if bundle != "" {
-		if err := os.Chdir(bundle); err != nil {
-			return nil, err
-		}
-	}
-	spec, err := loadSpec(specConfig)
-	if err != nil {
-		return nil, err
-	}
-	return spec, nil
-}

+ 0 - 43
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/start.go

@@ -1,43 +0,0 @@
-package main
-
-import (
-	"errors"
-	"fmt"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var startCommand = cli.Command{
-	Name:  "start",
-	Usage: "executes the user defined process in a created container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is your name for the instance of the container that you
-are starting. The name you provide for the container instance must be unique on
-your host.`,
-	Description: `The start command executes the user defined process in a created container.`,
-	Before:      appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		container, err := getContainer(id, false)
-		if err != nil {
-			return err
-		}
-		defer container.Close()
-		status, err := container.Status()
-		if err != nil {
-			return err
-		}
-		switch status {
-		case containerCreated:
-			return container.Exec()
-		case containerStopped:
-			return errors.New("cannot start a container that has stopped")
-		case containerRunning:
-			return errors.New("cannot start an already running container")
-		default:
-			return fmt.Errorf("cannot start a container in the '%s' state", status)
-		}
-	},
-}

+ 0 - 49
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/state.go

@@ -1,49 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"os"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/urfave/cli"
-)
-
-var stateCommand = cli.Command{
-	Name:  "state",
-	Usage: "output the state of a container",
-	ArgsUsage: `<container-id>
-
-Where "<container-id>" is your name for the instance of the container.`,
-	Description: `The state command outputs current state information for the
-instance of a container.`,
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		id := context.Args().First()
-		c, err := getContainer(id, false)
-		if err != nil {
-			return err
-		}
-		defer c.Close()
-		status, err := c.Status()
-		if err != nil {
-			return err
-		}
-		cs := runhcs.ContainerState{
-			Version:        c.Spec.Version,
-			ID:             c.ID,
-			InitProcessPid: c.ShimPid,
-			Status:         string(status),
-			Bundle:         c.Bundle,
-			Rootfs:         c.Rootfs,
-			Created:        c.Created,
-			Annotations:    c.Spec.Annotations,
-		}
-		data, err := json.MarshalIndent(cs, "", "  ")
-		if err != nil {
-			return err
-		}
-		os.Stdout.Write(data)
-		return nil
-	},
-}

+ 0 - 56
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/tty.go

@@ -1,56 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"strconv"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var resizeTtyCommand = cli.Command{
-	Name:      "resize-tty",
-	Usage:     "resize-tty updates the terminal size for a container process",
-	ArgsUsage: `<container-id> <width> <height>`,
-	Flags: []cli.Flag{
-		&cli.IntFlag{
-			Name:  "pid, p",
-			Usage: "the process pid (defaults to init pid)",
-		},
-	},
-	Before: appargs.Validate(
-		argID,
-		appargs.Int(10, 1, 65535),
-		appargs.Int(10, 1, 65535),
-	),
-	Action: func(context *cli.Context) error {
-		id := context.Args()[0]
-		width, _ := strconv.ParseUint(context.Args()[1], 10, 16)
-		height, _ := strconv.ParseUint(context.Args()[2], 10, 16)
-		c, err := getContainer(id, true)
-		if err != nil {
-			return err
-		}
-		defer c.Close()
-
-		pid := context.Int("pid")
-		if pid == 0 {
-			if err := stateKey.Get(id, keyInitPid, &pid); err != nil {
-				return err
-			}
-		} else {
-			// If a pid was provided map it to its hcs pid.
-			if err := stateKey.Get(id, fmt.Sprintf(keyPidMapFmt, pid), &pid); err != nil {
-				return err
-			}
-		}
-
-		p, err := c.hc.OpenProcess(pid)
-		if err != nil {
-			return err
-		}
-		defer p.Close()
-
-		return p.ResizeConsole(uint16(width), uint16(height))
-	},
-}

+ 0 - 52
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/utils.go

@@ -1,52 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"net"
-	"os"
-	"path/filepath"
-	"strings"
-
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-)
-
-var argID = appargs.NonEmptyString
-
-func absPathOrEmpty(path string) (string, error) {
-	if path == "" {
-		return "", nil
-	}
-	if strings.HasPrefix(path, runhcs.SafePipePrefix) {
-		if len(path) > len(runhcs.SafePipePrefix) {
-			return runhcs.SafePipePath(path[len(runhcs.SafePipePrefix):]), nil
-		}
-	}
-	return filepath.Abs(path)
-}
-
-// createPidFile creates a file with the processes pid inside it atomically
-// it creates a temp file with the paths filename + '.' infront of it
-// then renames the file
-func createPidFile(path string, pid int) error {
-	var (
-		tmpDir  = filepath.Dir(path)
-		tmpName = filepath.Join(tmpDir, fmt.Sprintf(".%s", filepath.Base(path)))
-	)
-	f, err := os.OpenFile(tmpName, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666)
-	if err != nil {
-		return err
-	}
-	_, err = fmt.Fprintf(f, "%d", pid)
-	f.Close()
-	if err != nil {
-		return err
-	}
-	return os.Rename(tmpName, path)
-}
-
-func closeWritePipe(pipe net.Conn) error {
-	return pipe.(interface {
-		CloseWrite() error
-	}).CloseWrite()
-}

+ 0 - 39
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/utils_test.go

@@ -1,39 +0,0 @@
-package main
-
-import (
-	"os"
-	"testing"
-
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-)
-
-func Test_AbsPathOrEmpty(t *testing.T) {
-	wd, err := os.Getwd()
-	if err != nil {
-		t.Fatalf("failed to get test wd: %v", err)
-	}
-
-	tests := []string{
-		"",
-		runhcs.SafePipePrefix + "test",
-		runhcs.SafePipePrefix + "test with spaces",
-		"test",
-		"C:\\test..\\test",
-	}
-	expected := []string{
-		"",
-		runhcs.SafePipePrefix + "test",
-		runhcs.SafePipePrefix + "test%20with%20spaces",
-		wd + "\\test",
-		"C:\\test..\\test",
-	}
-	for i, test := range tests {
-		actual, err := absPathOrEmpty(test)
-		if err != nil {
-			t.Fatalf("absPathOrEmpty: error '%v'", err)
-		}
-		if actual != expected[i] {
-			t.Fatalf("absPathOrEmpty: actual '%s' != '%s'", actual, expected[i])
-		}
-	}
-}

+ 0 - 43
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/versioninfo.json

@@ -1,43 +0,0 @@
-{
-    "FixedFileInfo": {
-        "FileVersion": {
-            "Major": 1,
-            "Minor": 0,
-            "Patch": 0,
-            "Build": 0
-        },
-        "ProductVersion": {
-            "Major": 1,
-            "Minor": 0,
-            "Patch": 0,
-            "Build": 0
-        },
-        "FileFlagsMask": "3f",
-        "FileFlags ": "00",
-        "FileOS": "040004",
-        "FileType": "01",
-        "FileSubType": "00"
-    },
-    "StringFileInfo": {
-        "Comments": "",
-        "CompanyName": "",
-        "FileDescription": "",
-        "FileVersion": "",
-        "InternalName": "",
-        "LegalCopyright": "",
-        "LegalTrademarks": "",
-        "OriginalFilename": "",
-        "PrivateBuild": "",
-        "ProductName": "",
-        "ProductVersion": "v1.0.0.0",
-        "SpecialBuild": ""
-    },
-    "VarFileInfo": {
-        "Translation": {
-            "LangID": "0409",
-            "CharsetID": "04B0"
-        }
-    },
-    "IconPath": "",
-    "ManifestPath": "runhcs.exe.manifest"
-}

+ 0 - 209
vendor/github.com/Microsoft/hcsshim/cmd/runhcs/vm.go

@@ -1,209 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"io/ioutil"
-	"net"
-	"os"
-	"syscall"
-
-	winio "github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/logfields"
-	"github.com/Microsoft/hcsshim/internal/runhcs"
-	"github.com/Microsoft/hcsshim/internal/uvm"
-	"github.com/pkg/errors"
-	"github.com/sirupsen/logrus"
-	"github.com/urfave/cli"
-)
-
-func vmID(id string) string {
-	return id + "@vm"
-}
-
-var vmshimCommand = cli.Command{
-	Name:   "vmshim",
-	Usage:  `launch a VM and containers inside it (do not call it outside of runhcs)`,
-	Hidden: true,
-	Flags: []cli.Flag{
-		cli.StringFlag{Name: "log-pipe", Hidden: true},
-		cli.StringFlag{Name: "os", Hidden: true},
-	},
-	Before: appargs.Validate(argID),
-	Action: func(context *cli.Context) error {
-		logPipe := context.String("log-pipe")
-		if logPipe != "" {
-			lpc, err := winio.DialPipe(logPipe, nil)
-			if err != nil {
-				return err
-			}
-			defer lpc.Close()
-			logrus.SetOutput(lpc)
-		} else {
-			logrus.SetOutput(os.Stderr)
-		}
-		fatalWriter.Writer = os.Stdout
-
-		pipePath := context.Args().First()
-
-		optsj, err := ioutil.ReadAll(os.Stdin)
-		if err != nil {
-			return err
-		}
-		os.Stdin.Close()
-
-		var opts interface{}
-		isLCOW := context.String("os") == "linux"
-		if isLCOW {
-			opts = &uvm.OptionsLCOW{}
-		} else {
-			opts = &uvm.OptionsWCOW{}
-		}
-
-		err = json.Unmarshal(optsj, opts)
-		if err != nil {
-			return err
-		}
-
-		// Listen on the named pipe associated with this VM.
-		l, err := winio.ListenPipe(pipePath, &winio.PipeConfig{MessageMode: true})
-		if err != nil {
-			return err
-		}
-
-		var vm *uvm.UtilityVM
-		if isLCOW {
-			vm, err = uvm.CreateLCOW(opts.(*uvm.OptionsLCOW))
-		} else {
-			vm, err = uvm.CreateWCOW(opts.(*uvm.OptionsWCOW))
-		}
-		if err != nil {
-			return err
-		}
-		defer vm.Close()
-		if err = vm.Start(); err != nil {
-			return err
-		}
-
-		// Asynchronously wait for the VM to exit.
-		exitCh := make(chan error)
-		go func() {
-			exitCh <- vm.Wait()
-		}()
-
-		defer vm.Terminate()
-
-		// Alert the parent process that initialization has completed
-		// successfully.
-		os.Stdout.Write(runhcs.ShimSuccess)
-		os.Stdout.Close()
-		fatalWriter.Writer = ioutil.Discard
-
-		pipeCh := make(chan net.Conn)
-		go func() {
-			for {
-				conn, err := l.Accept()
-				if err != nil {
-					logrus.Error(err)
-					continue
-				}
-				pipeCh <- conn
-			}
-		}()
-
-		for {
-			select {
-			case <-exitCh:
-				return nil
-			case pipe := <-pipeCh:
-				err = processRequest(vm, pipe)
-				if err == nil {
-					_, err = pipe.Write(runhcs.ShimSuccess)
-					// Wait until the pipe is closed before closing the
-					// container so that it is properly handed off to the other
-					// process.
-					if err == nil {
-						err = closeWritePipe(pipe)
-					}
-					if err == nil {
-						ioutil.ReadAll(pipe)
-					}
-				} else {
-					logrus.WithError(err).
-						Error("failed creating container in VM")
-					fmt.Fprintf(pipe, "%v", err)
-				}
-				pipe.Close()
-			}
-		}
-	},
-}
-
-func processRequest(vm *uvm.UtilityVM, pipe net.Conn) error {
-	var req runhcs.VMRequest
-	err := json.NewDecoder(pipe).Decode(&req)
-	if err != nil {
-		return err
-	}
-	logrus.WithFields(logrus.Fields{
-		logfields.ContainerID:     req.ID,
-		logfields.VMShimOperation: req.Op,
-	}).Debug("process request")
-	c, err := getContainer(req.ID, false)
-	if err != nil {
-		return err
-	}
-	defer func() {
-		if c != nil {
-			c.Close()
-		}
-	}()
-	switch req.Op {
-	case runhcs.OpCreateContainer:
-		err = createContainerInHost(c, vm)
-		if err != nil {
-			return err
-		}
-		c2 := c
-		c = nil
-		go func() {
-			c2.hc.Wait()
-			c2.Close()
-		}()
-
-	case runhcs.OpUnmountContainer, runhcs.OpUnmountContainerDiskOnly:
-		err = c.unmountInHost(vm, req.Op == runhcs.OpUnmountContainer)
-		if err != nil {
-			return err
-		}
-
-	case runhcs.OpSyncNamespace:
-		return errors.New("Not implemented")
-	default:
-		panic("unknown operation")
-	}
-	return nil
-}
-
-type noVMError struct {
-	ID string
-}
-
-func (err *noVMError) Error() string {
-	return "VM " + err.ID + " cannot be contacted"
-}
-
-func (c *container) issueVMRequest(op runhcs.VMRequestOp) error {
-	req := runhcs.VMRequest{
-		ID: c.ID,
-		Op: op,
-	}
-	if err := runhcs.IssueVMRequest(c.VMPipePath(), &req); err != nil {
-		if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND {
-			return &noVMError{c.HostID}
-		}
-		return err
-	}
-	return nil
-}

+ 0 - 64
vendor/github.com/Microsoft/hcsshim/cmd/tar2ext4/tar2ext4.go

@@ -1,64 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"os"
-
-	"github.com/Microsoft/hcsshim/ext4/tar2ext4"
-)
-
-var (
-	input      = flag.String("i", "", "input file")
-	output     = flag.String("o", "", "output file")
-	overlay    = flag.Bool("overlay", false, "produce overlayfs-compatible layer image")
-	vhd        = flag.Bool("vhd", false, "add a VHD footer to the end of the image")
-	inlineData = flag.Bool("inline", false, "write small file data into the inode; not compatible with DAX")
-)
-
-func main() {
-	flag.Parse()
-	if flag.NArg() != 0 || len(*output) == 0 {
-		flag.Usage()
-		os.Exit(1)
-	}
-
-	err := func() (err error) {
-		in := os.Stdin
-		if *input != "" {
-			in, err = os.Open(*input)
-			if err != nil {
-				return err
-			}
-		}
-		out, err := os.Create(*output)
-		if err != nil {
-			return err
-		}
-
-		var opts []tar2ext4.Option
-		if *overlay {
-			opts = append(opts, tar2ext4.ConvertWhiteout)
-		}
-		if *vhd {
-			opts = append(opts, tar2ext4.AppendVhdFooter)
-		}
-		if *inlineData {
-			opts = append(opts, tar2ext4.InlineData)
-		}
-		err = tar2ext4.Convert(in, out, opts...)
-		if err != nil {
-			return err
-		}
-
-		// Exhaust the tar stream.
-		io.Copy(ioutil.Discard, in)
-		return nil
-	}()
-	if err != nil {
-		fmt.Fprintln(os.Stderr, err)
-		os.Exit(1)
-	}
-}

+ 0 - 36
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/create.go

@@ -1,36 +0,0 @@
-package main
-
-import (
-	"path/filepath"
-
-	"github.com/Microsoft/hcsshim"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var createCommand = cli.Command{
-	Name:  "create",
-	Usage: "creates a new writable container layer",
-	Flags: []cli.Flag{
-		cli.StringSliceFlag{
-			Name:  "layer, l",
-			Usage: "paths to the read-only parent layers",
-		},
-	},
-	ArgsUsage: "<layer path>",
-	Before:    appargs.Validate(appargs.NonEmptyString),
-	Action: func(context *cli.Context) error {
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		layers, err := normalizeLayers(context.StringSlice("layer"), true)
-		if err != nil {
-			return err
-		}
-
-		di := driverInfo
-		return hcsshim.CreateScratchLayer(di, path, layers[len(layers)-1], layers)
-	},
-}

+ 0 - 66
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/export.go

@@ -1,66 +0,0 @@
-package main
-
-import (
-	"compress/gzip"
-	"io"
-	"os"
-	"path/filepath"
-
-	winio "github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/ociwclayer"
-	"github.com/urfave/cli"
-)
-
-var exportCommand = cli.Command{
-	Name:  "export",
-	Usage: "exports a layer to a tar file",
-	Flags: []cli.Flag{
-		cli.StringSliceFlag{
-			Name:  "layer, l",
-			Usage: "paths to the read-only parent layers",
-		},
-		cli.StringFlag{
-			Name:  "output, o",
-			Usage: "output layer tar (defaults to stdout)",
-		},
-		cli.BoolFlag{
-			Name:  "gzip, z",
-			Usage: "compress output with gzip compression",
-		},
-	},
-	ArgsUsage: "<layer path>",
-	Before:    appargs.Validate(appargs.NonEmptyString),
-	Action: func(context *cli.Context) (err error) {
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		layers, err := normalizeLayers(context.StringSlice("layer"), true)
-		if err != nil {
-			return err
-		}
-
-		err = winio.EnableProcessPrivileges([]string{winio.SeBackupPrivilege})
-		if err != nil {
-			return err
-		}
-
-		fp := context.String("output")
-		f := os.Stdout
-		if fp != "" {
-			f, err = os.Create(fp)
-			if err != nil {
-				return err
-			}
-			defer f.Close()
-		}
-		w := io.Writer(f)
-		if context.Bool("gzip") {
-			w = gzip.NewWriter(w)
-		}
-
-		return ociwclayer.ExportLayer(w, path, layers)
-	},
-}

+ 0 - 74
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/import.go

@@ -1,74 +0,0 @@
-package main
-
-import (
-	"bufio"
-	"compress/gzip"
-	"io"
-	"os"
-	"path/filepath"
-
-	"github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/Microsoft/hcsshim/internal/ociwclayer"
-	"github.com/urfave/cli"
-)
-
-var importCommand = cli.Command{
-	Name:  "import",
-	Usage: "imports a layer from a tar file",
-	Flags: []cli.Flag{
-		cli.StringSliceFlag{
-			Name:  "layer, l",
-			Usage: "paths to the read-only parent layers",
-		},
-		cli.StringFlag{
-			Name:  "input, i",
-			Usage: "input layer tar (defaults to stdin)",
-		},
-	},
-	ArgsUsage: "<layer path>",
-	Before:    appargs.Validate(appargs.NonEmptyString),
-	Action: func(context *cli.Context) (err error) {
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		layers, err := normalizeLayers(context.StringSlice("layer"), false)
-		if err != nil {
-			return err
-		}
-
-		fp := context.String("input")
-		f := os.Stdin
-		if fp != "" {
-			f, err = os.Open(fp)
-			if err != nil {
-				return err
-			}
-			defer f.Close()
-		}
-		r, err := addDecompressor(f)
-		if err != nil {
-			return err
-		}
-		err = winio.EnableProcessPrivileges([]string{winio.SeBackupPrivilege, winio.SeRestorePrivilege})
-		if err != nil {
-			return err
-		}
-		_, err = ociwclayer.ImportLayer(r, path, layers)
-		return err
-	},
-}
-
-func addDecompressor(r io.Reader) (io.Reader, error) {
-	b := bufio.NewReader(r)
-	hdr, err := b.Peek(3)
-	if err != nil {
-		return nil, err
-	}
-	if hdr[0] == 0x1f && hdr[1] == 0x8b && hdr[2] == 8 {
-		return gzip.NewReader(b)
-	}
-	return b, nil
-}

+ 0 - 88
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/mount.go

@@ -1,88 +0,0 @@
-package main
-
-import (
-	"errors"
-	"fmt"
-	"os"
-	"path/filepath"
-
-	"github.com/Microsoft/hcsshim"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-	"github.com/urfave/cli"
-)
-
-var mountCommand = cli.Command{
-	Name:      "mount",
-	Usage:     "mounts a scratch",
-	ArgsUsage: "<scratch path>",
-	Flags: []cli.Flag{
-		cli.StringSliceFlag{
-			Name:  "layer, l",
-			Usage: "paths to the parent layers for this layer",
-		},
-	},
-	Action: func(context *cli.Context) (err error) {
-		if context.NArg() != 1 {
-			return errors.New("invalid usage")
-		}
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		layers, err := normalizeLayers(context.StringSlice("layer"), true)
-		if err != nil {
-			return err
-		}
-
-		err = hcsshim.ActivateLayer(driverInfo, path)
-		if err != nil {
-			return err
-		}
-		defer func() {
-			if err != nil {
-				hcsshim.DeactivateLayer(driverInfo, path)
-			}
-		}()
-
-		err = hcsshim.PrepareLayer(driverInfo, path, layers)
-		if err != nil {
-			return err
-		}
-		defer func() {
-			if err != nil {
-				hcsshim.UnprepareLayer(driverInfo, path)
-			}
-		}()
-
-		mountPath, err := hcsshim.GetLayerMountPath(driverInfo, path)
-		if err != nil {
-			return err
-		}
-		_, err = fmt.Println(mountPath)
-		return err
-	},
-}
-
-var unmountCommand = cli.Command{
-	Name:      "unmount",
-	Usage:     "unmounts a scratch",
-	ArgsUsage: "<layer path>",
-	Before:    appargs.Validate(appargs.NonEmptyString),
-	Action: func(context *cli.Context) (err error) {
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		err = hcsshim.UnprepareLayer(driverInfo, path)
-		if err != nil {
-			fmt.Fprintln(os.Stderr, err)
-		}
-		err = hcsshim.DeactivateLayer(driverInfo, path)
-		if err != nil {
-			return err
-		}
-		return nil
-	},
-}

+ 0 - 31
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/remove.go

@@ -1,31 +0,0 @@
-package main
-
-import (
-	"path/filepath"
-
-	winio "github.com/Microsoft/go-winio"
-	"github.com/Microsoft/hcsshim"
-	"github.com/Microsoft/hcsshim/internal/appargs"
-
-	"github.com/urfave/cli"
-)
-
-var removeCommand = cli.Command{
-	Name:      "remove",
-	Usage:     "permanently removes a layer directory in its entirety",
-	ArgsUsage: "<layer path>",
-	Before:    appargs.Validate(appargs.NonEmptyString),
-	Action: func(context *cli.Context) (err error) {
-		path, err := filepath.Abs(context.Args().First())
-		if err != nil {
-			return err
-		}
-
-		err = winio.EnableProcessPrivileges([]string{winio.SeBackupPrivilege, winio.SeRestorePrivilege})
-		if err != nil {
-			return err
-		}
-
-		return hcsshim.DestroyLayer(driverInfo, path)
-	},
-}

BIN
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/resource_windows_386.syso


BIN
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/resource_windows_amd64.syso


+ 0 - 43
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/versioninfo.json

@@ -1,43 +0,0 @@
-{
-    "FixedFileInfo": {
-        "FileVersion": {
-            "Major": 1,
-            "Minor": 0,
-            "Patch": 0,
-            "Build": 0
-        },
-        "ProductVersion": {
-            "Major": 1,
-            "Minor": 0,
-            "Patch": 0,
-            "Build": 0
-        },
-        "FileFlagsMask": "3f",
-        "FileFlags ": "00",
-        "FileOS": "040004",
-        "FileType": "01",
-        "FileSubType": "00"
-    },
-    "StringFileInfo": {
-        "Comments": "",
-        "CompanyName": "",
-        "FileDescription": "",
-        "FileVersion": "",
-        "InternalName": "",
-        "LegalCopyright": "",
-        "LegalTrademarks": "",
-        "OriginalFilename": "",
-        "PrivateBuild": "",
-        "ProductName": "",
-        "ProductVersion": "v1.0.0.0",
-        "SpecialBuild": ""
-    },
-    "VarFileInfo": {
-        "Translation": {
-            "LangID": "0409",
-            "CharsetID": "04B0"
-        }
-    },
-    "IconPath": "",
-    "ManifestPath": "wclayer.exe.manifest"
-}

+ 0 - 10
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/wclayer.exe.manifest

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-    <description>wclayer</description>
-    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
-        <application>
-            <!-- Windows 10 -->
-            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
-        </application>
-    </compatibility>
-</assembly>

+ 0 - 60
vendor/github.com/Microsoft/hcsshim/cmd/wclayer/wclayer.go

@@ -1,60 +0,0 @@
-package main
-
-import (
-	"errors"
-	"fmt"
-	"os"
-	"path/filepath"
-
-	"github.com/Microsoft/hcsshim"
-	"github.com/urfave/cli"
-)
-
-// Add a manifest to get proper Windows version detection.
-//
-// goversioninfo can be installed with "go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo"
-
-//go:generate goversioninfo -platform-specific
-
-var usage = `Windows Container layer utility
-
-wclayer is a command line tool for manipulating Windows Container
-storage layers. It can import and export layers from and to OCI format
-layer tar files, create new writable layers, and mount and unmount
-container images.`
-
-var driverInfo = hcsshim.DriverInfo{}
-
-func main() {
-	app := cli.NewApp()
-	app.Name = "wclayer"
-	app.Commands = []cli.Command{
-		createCommand,
-		exportCommand,
-		importCommand,
-		mountCommand,
-		removeCommand,
-		unmountCommand,
-	}
-	app.Usage = usage
-
-	if err := app.Run(os.Args); err != nil {
-		fmt.Fprintln(os.Stderr, err)
-		os.Exit(1)
-	}
-}
-
-func normalizeLayers(il []string, needOne bool) ([]string, error) {
-	if needOne && len(il) == 0 {
-		return nil, errors.New("at least one read-only layer must be specified")
-	}
-	ol := make([]string, len(il))
-	for i := range il {
-		var err error
-		ol[i], err = filepath.Abs(il[i])
-		if err != nil {
-			return nil, err
-		}
-	}
-	return ol, nil
-}

+ 0 - 1263
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact.go

@@ -1,1263 +0,0 @@
-package compactext4
-
-import (
-	"bufio"
-	"bytes"
-	"encoding/binary"
-	"errors"
-	"fmt"
-	"io"
-	"path"
-	"sort"
-	"strings"
-	"time"
-
-	"github.com/Microsoft/hcsshim/ext4/internal/format"
-)
-
-// Writer writes a compact ext4 file system.
-type Writer struct {
-	f                    io.ReadWriteSeeker
-	bw                   *bufio.Writer
-	inodes               []*inode
-	curName              string
-	curInode             *inode
-	pos                  int64
-	dataWritten, dataMax int64
-	err                  error
-	initialized          bool
-	supportInlineData    bool
-	maxDiskSize          int64
-	gdBlocks             uint32
-}
-
-// Mode flags for Linux files.
-const (
-	S_IXOTH  = format.S_IXOTH
-	S_IWOTH  = format.S_IWOTH
-	S_IROTH  = format.S_IROTH
-	S_IXGRP  = format.S_IXGRP
-	S_IWGRP  = format.S_IWGRP
-	S_IRGRP  = format.S_IRGRP
-	S_IXUSR  = format.S_IXUSR
-	S_IWUSR  = format.S_IWUSR
-	S_IRUSR  = format.S_IRUSR
-	S_ISVTX  = format.S_ISVTX
-	S_ISGID  = format.S_ISGID
-	S_ISUID  = format.S_ISUID
-	S_IFIFO  = format.S_IFIFO
-	S_IFCHR  = format.S_IFCHR
-	S_IFDIR  = format.S_IFDIR
-	S_IFBLK  = format.S_IFBLK
-	S_IFREG  = format.S_IFREG
-	S_IFLNK  = format.S_IFLNK
-	S_IFSOCK = format.S_IFSOCK
-
-	TypeMask = format.TypeMask
-)
-
-type inode struct {
-	Size                        int64
-	Atime, Ctime, Mtime, Crtime uint64
-	Number                      format.InodeNumber
-	Mode                        uint16
-	Uid, Gid                    uint32
-	LinkCount                   uint32
-	XattrBlock                  uint32
-	BlockCount                  uint32
-	Devmajor, Devminor          uint32
-	Flags                       format.InodeFlag
-	Data                        []byte
-	XattrInline                 []byte
-	Children                    directory
-}
-
-func (node *inode) FileType() uint16 {
-	return node.Mode & format.TypeMask
-}
-
-func (node *inode) IsDir() bool {
-	return node.FileType() == S_IFDIR
-}
-
-// A File represents a file to be added to an ext4 file system.
-type File struct {
-	Linkname                    string
-	Size                        int64
-	Mode                        uint16
-	Uid, Gid                    uint32
-	Atime, Ctime, Mtime, Crtime time.Time
-	Devmajor, Devminor          uint32
-	Xattrs                      map[string][]byte
-}
-
-const (
-	inodeFirst        = 11
-	inodeLostAndFound = inodeFirst
-
-	blockSize               = 4096
-	blocksPerGroup          = blockSize * 8
-	inodeSize               = 256
-	maxInodesPerGroup       = blockSize * 8 // Limited by the inode bitmap
-	inodesPerGroupIncrement = blockSize / inodeSize
-
-	defaultMaxDiskSize = 16 * 1024 * 1024 * 1024        // 16GB
-	maxMaxDiskSize     = 16 * 1024 * 1024 * 1024 * 1024 // 16TB
-
-	groupDescriptorSize      = 32 // Use the small group descriptor
-	groupsPerDescriptorBlock = blockSize / groupDescriptorSize
-
-	maxFileSize             = 128 * 1024 * 1024 * 1024 // 128GB file size maximum for now
-	smallSymlinkSize        = 59                       // max symlink size that goes directly in the inode
-	maxBlocksPerExtent      = 0x8000                   // maximum number of blocks in an extent
-	inodeDataSize           = 60
-	inodeUsedSize           = 152 // fields through CrtimeExtra
-	inodeExtraSize          = inodeSize - inodeUsedSize
-	xattrInodeOverhead      = 4 + 4                       // magic number + empty next entry value
-	xattrBlockOverhead      = 32 + 4                      // header + empty next entry value
-	inlineDataXattrOverhead = xattrInodeOverhead + 16 + 4 // entry + "data"
-	inlineDataSize          = inodeDataSize + inodeExtraSize - inlineDataXattrOverhead
-)
-
-type exceededMaxSizeError struct {
-	Size int64
-}
-
-func (err exceededMaxSizeError) Error() string {
-	return fmt.Sprintf("disk exceeded maximum size of %d bytes", err.Size)
-}
-
-var directoryEntrySize = binary.Size(format.DirectoryEntry{})
-var extraIsize = uint16(inodeUsedSize - 128)
-
-type directory map[string]*inode
-
-func splitFirst(p string) (string, string) {
-	n := strings.IndexByte(p, '/')
-	if n >= 0 {
-		return p[:n], p[n+1:]
-	}
-	return p, ""
-}
-
-func (w *Writer) findPath(root *inode, p string) *inode {
-	inode := root
-	for inode != nil && len(p) != 0 {
-		name, rest := splitFirst(p)
-		p = rest
-		inode = inode.Children[name]
-	}
-	return inode
-}
-
-func timeToFsTime(t time.Time) uint64 {
-	if t.IsZero() {
-		return 0
-	}
-	s := t.Unix()
-	if s < -0x80000000 {
-		return 0x80000000
-	}
-	if s > 0x37fffffff {
-		return 0x37fffffff
-	}
-	return uint64(s) | uint64(t.Nanosecond())<<34
-}
-
-func fsTimeToTime(t uint64) time.Time {
-	if t == 0 {
-		return time.Time{}
-	}
-	s := int64(t & 0x3ffffffff)
-	if s > 0x7fffffff && s < 0x100000000 {
-		s = int64(int32(uint32(s)))
-	}
-	return time.Unix(s, int64(t>>34))
-}
-
-func (w *Writer) getInode(i format.InodeNumber) *inode {
-	if i == 0 || int(i) > len(w.inodes) {
-		return nil
-	}
-	return w.inodes[i-1]
-}
-
-var xattrPrefixes = []struct {
-	Index  uint8
-	Prefix string
-}{
-	{2, "system.posix_acl_access"},
-	{3, "system.posix_acl_default"},
-	{8, "system.richacl"},
-	{7, "system."},
-	{1, "user."},
-	{4, "trusted."},
-	{6, "security."},
-}
-
-func compressXattrName(name string) (uint8, string) {
-	for _, p := range xattrPrefixes {
-		if strings.HasPrefix(name, p.Prefix) {
-			return p.Index, name[len(p.Prefix):]
-		}
-	}
-	return 0, name
-}
-
-func decompressXattrName(index uint8, name string) string {
-	for _, p := range xattrPrefixes {
-		if index == p.Index {
-			return p.Prefix + name
-		}
-	}
-	return name
-}
-
-func hashXattrEntry(name string, value []byte) uint32 {
-	var hash uint32
-	for i := 0; i < len(name); i++ {
-		hash = (hash << 5) ^ (hash >> 27) ^ uint32(name[i])
-	}
-
-	for i := 0; i+3 < len(value); i += 4 {
-		hash = (hash << 16) ^ (hash >> 16) ^ binary.LittleEndian.Uint32(value[i:i+4])
-	}
-
-	if len(value)%4 != 0 {
-		var last [4]byte
-		copy(last[:], value[len(value)&^3:])
-		hash = (hash << 16) ^ (hash >> 16) ^ binary.LittleEndian.Uint32(last[:])
-	}
-	return hash
-}
-
-type xattr struct {
-	Name  string
-	Index uint8
-	Value []byte
-}
-
-func (x *xattr) EntryLen() int {
-	return (len(x.Name)+3)&^3 + 16
-}
-
-func (x *xattr) ValueLen() int {
-	return (len(x.Value) + 3) &^ 3
-}
-
-type xattrState struct {
-	inode, block         []xattr
-	inodeLeft, blockLeft int
-}
-
-func (s *xattrState) init() {
-	s.inodeLeft = inodeExtraSize - xattrInodeOverhead
-	s.blockLeft = blockSize - xattrBlockOverhead
-}
-
-func (s *xattrState) addXattr(name string, value []byte) bool {
-	index, name := compressXattrName(name)
-	x := xattr{
-		Index: index,
-		Name:  name,
-		Value: value,
-	}
-	length := x.EntryLen() + x.ValueLen()
-	if s.inodeLeft >= length {
-		s.inode = append(s.inode, x)
-		s.inodeLeft -= length
-	} else if s.blockLeft >= length {
-		s.block = append(s.block, x)
-		s.blockLeft -= length
-	} else {
-		return false
-	}
-	return true
-}
-
-func putXattrs(xattrs []xattr, b []byte, offsetDelta uint16) {
-	offset := uint16(len(b)) + offsetDelta
-	eb := b
-	db := b
-	for _, xattr := range xattrs {
-		vl := xattr.ValueLen()
-		offset -= uint16(vl)
-		eb[0] = uint8(len(xattr.Name))
-		eb[1] = xattr.Index
-		binary.LittleEndian.PutUint16(eb[2:], offset)
-		binary.LittleEndian.PutUint32(eb[8:], uint32(len(xattr.Value)))
-		binary.LittleEndian.PutUint32(eb[12:], hashXattrEntry(xattr.Name, xattr.Value))
-		copy(eb[16:], xattr.Name)
-		eb = eb[xattr.EntryLen():]
-		copy(db[len(db)-vl:], xattr.Value)
-		db = db[:len(db)-vl]
-	}
-}
-
-func getXattrs(b []byte, xattrs map[string][]byte, offsetDelta uint16) {
-	eb := b
-	for len(eb) != 0 {
-		nameLen := eb[0]
-		if nameLen == 0 {
-			break
-		}
-		index := eb[1]
-		offset := binary.LittleEndian.Uint16(eb[2:]) - offsetDelta
-		valueLen := binary.LittleEndian.Uint32(eb[8:])
-		attr := xattr{
-			Index: index,
-			Name:  string(eb[16 : 16+nameLen]),
-			Value: b[offset : uint32(offset)+valueLen],
-		}
-		xattrs[decompressXattrName(index, attr.Name)] = attr.Value
-		eb = eb[attr.EntryLen():]
-	}
-}
-
-func (w *Writer) writeXattrs(inode *inode, state *xattrState) error {
-	// Write the inline attributes.
-	if len(state.inode) != 0 {
-		inode.XattrInline = make([]byte, inodeExtraSize)
-		binary.LittleEndian.PutUint32(inode.XattrInline[0:], format.XAttrHeaderMagic) // Magic
-		putXattrs(state.inode, inode.XattrInline[4:], 0)
-	}
-
-	// Write the block attributes. If there was previously an xattr block, then
-	// rewrite it even if it is now empty.
-	if len(state.block) != 0 || inode.XattrBlock != 0 {
-		sort.Slice(state.block, func(i, j int) bool {
-			return state.block[i].Index < state.block[j].Index ||
-				len(state.block[i].Name) < len(state.block[j].Name) ||
-				state.block[i].Name < state.block[j].Name
-		})
-
-		var b [blockSize]byte
-		binary.LittleEndian.PutUint32(b[0:], format.XAttrHeaderMagic) // Magic
-		binary.LittleEndian.PutUint32(b[4:], 1)                       // ReferenceCount
-		binary.LittleEndian.PutUint32(b[8:], 1)                       // Blocks
-		putXattrs(state.block, b[32:], 32)
-
-		orig := w.block()
-		if inode.XattrBlock == 0 {
-			inode.XattrBlock = orig
-			inode.BlockCount++
-		} else {
-			// Reuse the original block.
-			w.seekBlock(inode.XattrBlock)
-			defer w.seekBlock(orig)
-		}
-
-		if _, err := w.write(b[:]); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func (w *Writer) write(b []byte) (int, error) {
-	if w.err != nil {
-		return 0, w.err
-	}
-	if w.pos+int64(len(b)) > w.maxDiskSize {
-		w.err = exceededMaxSizeError{w.maxDiskSize}
-		return 0, w.err
-	}
-	n, err := w.bw.Write(b)
-	w.pos += int64(n)
-	w.err = err
-	return n, err
-}
-
-func (w *Writer) zero(n int64) (int64, error) {
-	if w.err != nil {
-		return 0, w.err
-	}
-	if w.pos+int64(n) > w.maxDiskSize {
-		w.err = exceededMaxSizeError{w.maxDiskSize}
-		return 0, w.err
-	}
-	n, err := io.CopyN(w.bw, zero, n)
-	w.pos += n
-	w.err = err
-	return n, err
-}
-
-func (w *Writer) makeInode(f *File, node *inode) (*inode, error) {
-	mode := f.Mode
-	if mode&format.TypeMask == 0 {
-		mode |= format.S_IFREG
-	}
-	typ := mode & format.TypeMask
-	ino := format.InodeNumber(len(w.inodes) + 1)
-	if node == nil {
-		node = &inode{
-			Number: ino,
-		}
-		if typ == S_IFDIR {
-			node.Children = make(directory)
-			node.LinkCount = 1 // A directory is linked to itself.
-		}
-	} else if node.Flags&format.InodeFlagExtents != 0 {
-		// Since we cannot deallocate or reuse blocks, don't allow updates that
-		// would invalidate data that has already been written.
-		return nil, errors.New("cannot overwrite file with non-inline data")
-	}
-	node.Mode = mode
-	node.Uid = f.Uid
-	node.Gid = f.Gid
-	node.Flags = format.InodeFlagHugeFile
-	node.Atime = timeToFsTime(f.Atime)
-	node.Ctime = timeToFsTime(f.Ctime)
-	node.Mtime = timeToFsTime(f.Mtime)
-	node.Crtime = timeToFsTime(f.Crtime)
-	node.Devmajor = f.Devmajor
-	node.Devminor = f.Devminor
-	node.Data = nil
-	node.XattrInline = nil
-
-	var xstate xattrState
-	xstate.init()
-
-	var size int64
-	switch typ {
-	case format.S_IFREG:
-		size = f.Size
-		if f.Size > maxFileSize {
-			return nil, fmt.Errorf("file too big: %d > %d", f.Size, int64(maxFileSize))
-		}
-		if f.Size <= inlineDataSize && w.supportInlineData {
-			node.Data = make([]byte, f.Size)
-			extra := 0
-			if f.Size > inodeDataSize {
-				extra = int(f.Size - inodeDataSize)
-			}
-			// Add a dummy entry for now.
-			if !xstate.addXattr("system.data", node.Data[:extra]) {
-				panic("not enough room for inline data")
-			}
-			node.Flags |= format.InodeFlagInlineData
-		}
-	case format.S_IFLNK:
-		node.Mode |= 0777 // Symlinks should appear as ugw rwx
-		size = int64(len(f.Linkname))
-		if size <= smallSymlinkSize {
-			// Special case: small symlinks go directly in Block without setting
-			// an inline data flag.
-			node.Data = make([]byte, len(f.Linkname))
-			copy(node.Data, f.Linkname)
-		}
-	case format.S_IFDIR, format.S_IFIFO, format.S_IFSOCK, format.S_IFCHR, format.S_IFBLK:
-	default:
-		return nil, fmt.Errorf("invalid mode %o", mode)
-	}
-
-	// Accumulate the extended attributes.
-	if len(f.Xattrs) != 0 {
-		// Sort the xattrs to avoid non-determinism in map iteration.
-		var xattrs []string
-		for name := range f.Xattrs {
-			xattrs = append(xattrs, name)
-		}
-		sort.Strings(xattrs)
-		for _, name := range xattrs {
-			if !xstate.addXattr(name, f.Xattrs[name]) {
-				return nil, fmt.Errorf("could not fit xattr %s", name)
-			}
-		}
-	}
-
-	if err := w.writeXattrs(node, &xstate); err != nil {
-		return nil, err
-	}
-
-	node.Size = size
-	if typ == format.S_IFLNK && size > smallSymlinkSize {
-		// Write the link name as data.
-		w.startInode("", node, size)
-		if _, err := w.Write([]byte(f.Linkname)); err != nil {
-			return nil, err
-		}
-		if err := w.finishInode(); err != nil {
-			return nil, err
-		}
-	}
-
-	if int(node.Number-1) >= len(w.inodes) {
-		w.inodes = append(w.inodes, node)
-	}
-	return node, nil
-}
-
-func (w *Writer) root() *inode {
-	return w.getInode(format.InodeRoot)
-}
-
-func (w *Writer) lookup(name string, mustExist bool) (*inode, *inode, string, error) {
-	root := w.root()
-	cleanname := path.Clean("/" + name)[1:]
-	if len(cleanname) == 0 {
-		return root, root, "", nil
-	}
-	dirname, childname := path.Split(cleanname)
-	if len(childname) == 0 || len(childname) > 0xff {
-		return nil, nil, "", fmt.Errorf("%s: invalid name", name)
-	}
-	dir := w.findPath(root, dirname)
-	if dir == nil || !dir.IsDir() {
-		return nil, nil, "", fmt.Errorf("%s: path not found", name)
-	}
-	child := dir.Children[childname]
-	if child == nil && mustExist {
-		return nil, nil, "", fmt.Errorf("%s: file not found", name)
-	}
-	return dir, child, childname, nil
-}
-
-// Create adds a file to the file system.
-func (w *Writer) Create(name string, f *File) error {
-	if err := w.finishInode(); err != nil {
-		return err
-	}
-	dir, existing, childname, err := w.lookup(name, false)
-	if err != nil {
-		return err
-	}
-	var reuse *inode
-	if existing != nil {
-		if existing.IsDir() {
-			if f.Mode&TypeMask != S_IFDIR {
-				return fmt.Errorf("%s: cannot replace a directory with a file", name)
-			}
-			reuse = existing
-		} else if f.Mode&TypeMask == S_IFDIR {
-			return fmt.Errorf("%s: cannot replace a file with a directory", name)
-		} else if existing.LinkCount < 2 {
-			reuse = existing
-		}
-	} else {
-		if f.Mode&TypeMask == S_IFDIR && dir.LinkCount >= format.MaxLinks {
-			return fmt.Errorf("%s: exceeded parent directory maximum link count", name)
-		}
-	}
-	child, err := w.makeInode(f, reuse)
-	if err != nil {
-		return fmt.Errorf("%s: %s", name, err)
-	}
-	if existing != child {
-		if existing != nil {
-			existing.LinkCount--
-		}
-		dir.Children[childname] = child
-		child.LinkCount++
-		if child.IsDir() {
-			dir.LinkCount++
-		}
-	}
-	if child.Mode&format.TypeMask == format.S_IFREG {
-		w.startInode(name, child, f.Size)
-	}
-	return nil
-}
-
-// Link adds a hard link to the file system.
-func (w *Writer) Link(oldname, newname string) error {
-	if err := w.finishInode(); err != nil {
-		return err
-	}
-	newdir, existing, newchildname, err := w.lookup(newname, false)
-	if err != nil {
-		return err
-	}
-	if existing != nil && (existing.IsDir() || existing.LinkCount < 2) {
-		return fmt.Errorf("%s: cannot orphan existing file or directory", newname)
-	}
-
-	_, oldfile, _, err := w.lookup(oldname, true)
-	if err != nil {
-		return err
-	}
-	switch oldfile.Mode & format.TypeMask {
-	case format.S_IFDIR, format.S_IFLNK:
-		return fmt.Errorf("%s: link target cannot be a directory or symlink: %s", newname, oldname)
-	}
-
-	if existing != oldfile && oldfile.LinkCount >= format.MaxLinks {
-		return fmt.Errorf("%s: link target would exceed maximum link count: %s", newname, oldname)
-	}
-
-	if existing != nil {
-		existing.LinkCount--
-	}
-	oldfile.LinkCount++
-	newdir.Children[newchildname] = oldfile
-	return nil
-}
-
-// Stat returns information about a file that has been written.
-func (w *Writer) Stat(name string) (*File, error) {
-	if err := w.finishInode(); err != nil {
-		return nil, err
-	}
-	_, node, _, err := w.lookup(name, true)
-	if err != nil {
-		return nil, err
-	}
-	f := &File{
-		Size:     node.Size,
-		Mode:     node.Mode,
-		Uid:      node.Uid,
-		Gid:      node.Gid,
-		Atime:    fsTimeToTime(node.Atime),
-		Ctime:    fsTimeToTime(node.Ctime),
-		Mtime:    fsTimeToTime(node.Mtime),
-		Crtime:   fsTimeToTime(node.Crtime),
-		Devmajor: node.Devmajor,
-		Devminor: node.Devminor,
-	}
-	f.Xattrs = make(map[string][]byte)
-	if node.XattrBlock != 0 || len(node.XattrInline) != 0 {
-		if node.XattrBlock != 0 {
-			orig := w.block()
-			w.seekBlock(node.XattrBlock)
-			if w.err != nil {
-				return nil, w.err
-			}
-			var b [blockSize]byte
-			_, err := w.f.Read(b[:])
-			w.seekBlock(orig)
-			if err != nil {
-				return nil, err
-			}
-			getXattrs(b[32:], f.Xattrs, 32)
-		}
-		if len(node.XattrInline) != 0 {
-			getXattrs(node.XattrInline[4:], f.Xattrs, 0)
-			delete(f.Xattrs, "system.data")
-		}
-	}
-	if node.FileType() == S_IFLNK {
-		if node.Size > smallSymlinkSize {
-			return nil, fmt.Errorf("%s: cannot retrieve link information", name)
-		}
-		f.Linkname = string(node.Data)
-	}
-	return f, nil
-}
-
-func (w *Writer) Write(b []byte) (int, error) {
-	if len(b) == 0 {
-		return 0, nil
-	}
-	if w.dataWritten+int64(len(b)) > w.dataMax {
-		return 0, fmt.Errorf("%s: wrote too much: %d > %d", w.curName, w.dataWritten+int64(len(b)), w.dataMax)
-	}
-
-	if w.curInode.Flags&format.InodeFlagInlineData != 0 {
-		copy(w.curInode.Data[w.dataWritten:], b)
-		w.dataWritten += int64(len(b))
-		return len(b), nil
-	}
-
-	n, err := w.write(b)
-	w.dataWritten += int64(n)
-	return n, err
-}
-
-func (w *Writer) startInode(name string, inode *inode, size int64) {
-	if w.curInode != nil {
-		panic("inode already in progress")
-	}
-	w.curName = name
-	w.curInode = inode
-	w.dataWritten = 0
-	w.dataMax = size
-}
-
-func (w *Writer) block() uint32 {
-	return uint32(w.pos / blockSize)
-}
-
-func (w *Writer) seekBlock(block uint32) {
-	w.pos = int64(block) * blockSize
-	if w.err != nil {
-		return
-	}
-	w.err = w.bw.Flush()
-	if w.err != nil {
-		return
-	}
-	_, w.err = w.f.Seek(w.pos, io.SeekStart)
-}
-
-func (w *Writer) nextBlock() {
-	if w.pos%blockSize != 0 {
-		// Simplify callers; w.err is updated on failure.
-		w.zero(blockSize - w.pos%blockSize)
-	}
-}
-
-func fillExtents(hdr *format.ExtentHeader, extents []format.ExtentLeafNode, startBlock, offset, inodeSize uint32) {
-	*hdr = format.ExtentHeader{
-		Magic:   format.ExtentHeaderMagic,
-		Entries: uint16(len(extents)),
-		Max:     uint16(cap(extents)),
-		Depth:   0,
-	}
-	for i := range extents {
-		block := offset + uint32(i)*maxBlocksPerExtent
-		length := inodeSize - block
-		if length > maxBlocksPerExtent {
-			length = maxBlocksPerExtent
-		}
-		start := startBlock + block
-		extents[i] = format.ExtentLeafNode{
-			Block:    block,
-			Length:   uint16(length),
-			StartLow: start,
-		}
-	}
-}
-
-func (w *Writer) writeExtents(inode *inode) error {
-	start := w.pos - w.dataWritten
-	if start%blockSize != 0 {
-		panic("unaligned")
-	}
-	w.nextBlock()
-
-	startBlock := uint32(start / blockSize)
-	blocks := w.block() - startBlock
-	usedBlocks := blocks
-
-	const extentNodeSize = 12
-	const extentsPerBlock = blockSize/extentNodeSize - 1
-
-	extents := (blocks + maxBlocksPerExtent - 1) / maxBlocksPerExtent
-	var b bytes.Buffer
-	if extents == 0 {
-		// Nothing to do.
-	} else if extents <= 4 {
-		var root struct {
-			hdr     format.ExtentHeader
-			extents [4]format.ExtentLeafNode
-		}
-		fillExtents(&root.hdr, root.extents[:extents], startBlock, 0, blocks)
-		binary.Write(&b, binary.LittleEndian, root)
-	} else if extents <= 4*extentsPerBlock {
-		const extentsPerBlock = blockSize/extentNodeSize - 1
-		extentBlocks := extents/extentsPerBlock + 1
-		usedBlocks += extentBlocks
-		var b2 bytes.Buffer
-
-		var root struct {
-			hdr   format.ExtentHeader
-			nodes [4]format.ExtentIndexNode
-		}
-		root.hdr = format.ExtentHeader{
-			Magic:   format.ExtentHeaderMagic,
-			Entries: uint16(extentBlocks),
-			Max:     4,
-			Depth:   1,
-		}
-		for i := uint32(0); i < extentBlocks; i++ {
-			root.nodes[i] = format.ExtentIndexNode{
-				Block:   i * extentsPerBlock * maxBlocksPerExtent,
-				LeafLow: w.block(),
-			}
-			extentsInBlock := extents - i*extentBlocks
-			if extentsInBlock > extentsPerBlock {
-				extentsInBlock = extentsPerBlock
-			}
-
-			var node struct {
-				hdr     format.ExtentHeader
-				extents [extentsPerBlock]format.ExtentLeafNode
-				_       [blockSize - (extentsPerBlock+1)*extentNodeSize]byte
-			}
-
-			offset := i * extentsPerBlock * maxBlocksPerExtent
-			fillExtents(&node.hdr, node.extents[:extentsInBlock], startBlock+offset, offset, blocks)
-			binary.Write(&b2, binary.LittleEndian, node)
-			if _, err := w.write(b2.Next(blockSize)); err != nil {
-				return err
-			}
-		}
-		binary.Write(&b, binary.LittleEndian, root)
-	} else {
-		panic("file too big")
-	}
-
-	inode.Data = b.Bytes()
-	inode.Flags |= format.InodeFlagExtents
-	inode.BlockCount += usedBlocks
-	return w.err
-}
-
-func (w *Writer) finishInode() error {
-	if !w.initialized {
-		if err := w.init(); err != nil {
-			return err
-		}
-	}
-	if w.curInode == nil {
-		return nil
-	}
-	if w.dataWritten != w.dataMax {
-		return fmt.Errorf("did not write the right amount: %d != %d", w.dataWritten, w.dataMax)
-	}
-
-	if w.dataMax != 0 && w.curInode.Flags&format.InodeFlagInlineData == 0 {
-		if err := w.writeExtents(w.curInode); err != nil {
-			return err
-		}
-	}
-
-	w.dataWritten = 0
-	w.dataMax = 0
-	w.curInode = nil
-	return w.err
-}
-
-func modeToFileType(mode uint16) format.FileType {
-	switch mode & format.TypeMask {
-	default:
-		return format.FileTypeUnknown
-	case format.S_IFREG:
-		return format.FileTypeRegular
-	case format.S_IFDIR:
-		return format.FileTypeDirectory
-	case format.S_IFCHR:
-		return format.FileTypeCharacter
-	case format.S_IFBLK:
-		return format.FileTypeBlock
-	case format.S_IFIFO:
-		return format.FileTypeFIFO
-	case format.S_IFSOCK:
-		return format.FileTypeSocket
-	case format.S_IFLNK:
-		return format.FileTypeSymbolicLink
-	}
-}
-
-type constReader byte
-
-var zero = constReader(0)
-
-func (r constReader) Read(b []byte) (int, error) {
-	for i := range b {
-		b[i] = byte(r)
-	}
-	return len(b), nil
-}
-
-func (w *Writer) writeDirectory(dir, parent *inode) error {
-	if err := w.finishInode(); err != nil {
-		return err
-	}
-
-	// The size of the directory is not known yet.
-	w.startInode("", dir, 0x7fffffffffffffff)
-	left := blockSize
-	finishBlock := func() error {
-		if left > 0 {
-			e := format.DirectoryEntry{
-				RecordLength: uint16(left),
-			}
-			err := binary.Write(w, binary.LittleEndian, e)
-			if err != nil {
-				return err
-			}
-			left -= directoryEntrySize
-			if left < 4 {
-				panic("not enough space for trailing entry")
-			}
-			_, err = io.CopyN(w, zero, int64(left))
-			if err != nil {
-				return err
-			}
-		}
-		left = blockSize
-		return nil
-	}
-
-	writeEntry := func(ino format.InodeNumber, name string) error {
-		rlb := directoryEntrySize + len(name)
-		rl := (rlb + 3) & ^3
-		if left < rl+12 {
-			if err := finishBlock(); err != nil {
-				return err
-			}
-		}
-		e := format.DirectoryEntry{
-			Inode:        ino,
-			RecordLength: uint16(rl),
-			NameLength:   uint8(len(name)),
-			FileType:     modeToFileType(w.getInode(ino).Mode),
-		}
-		err := binary.Write(w, binary.LittleEndian, e)
-		if err != nil {
-			return err
-		}
-		_, err = w.Write([]byte(name))
-		if err != nil {
-			return err
-		}
-		var zero [4]byte
-		_, err = w.Write(zero[:rl-rlb])
-		if err != nil {
-			return err
-		}
-		left -= rl
-		return nil
-	}
-	if err := writeEntry(dir.Number, "."); err != nil {
-		return err
-	}
-	if err := writeEntry(parent.Number, ".."); err != nil {
-		return err
-	}
-
-	// Follow e2fsck's convention and sort the children by inode number.
-	var children []string
-	for name := range dir.Children {
-		children = append(children, name)
-	}
-	sort.Slice(children, func(i, j int) bool {
-		return dir.Children[children[i]].Number < dir.Children[children[j]].Number
-	})
-
-	for _, name := range children {
-		child := dir.Children[name]
-		if err := writeEntry(child.Number, name); err != nil {
-			return err
-		}
-	}
-	if err := finishBlock(); err != nil {
-		return err
-	}
-	w.curInode.Size = w.dataWritten
-	w.dataMax = w.dataWritten
-	return nil
-}
-
-func (w *Writer) writeDirectoryRecursive(dir, parent *inode) error {
-	if err := w.writeDirectory(dir, parent); err != nil {
-		return err
-	}
-	for _, child := range dir.Children {
-		if child.IsDir() {
-			if err := w.writeDirectoryRecursive(child, dir); err != nil {
-				return err
-			}
-		}
-	}
-	return nil
-}
-
-func (w *Writer) writeInodeTable(tableSize uint32) error {
-	var b bytes.Buffer
-	for _, inode := range w.inodes {
-		if inode != nil {
-			binode := format.Inode{
-				Mode:          inode.Mode,
-				Uid:           uint16(inode.Uid & 0xffff),
-				Gid:           uint16(inode.Gid & 0xffff),
-				SizeLow:       uint32(inode.Size & 0xffffffff),
-				SizeHigh:      uint32(inode.Size >> 32),
-				LinksCount:    uint16(inode.LinkCount),
-				BlocksLow:     inode.BlockCount,
-				Flags:         inode.Flags,
-				XattrBlockLow: inode.XattrBlock,
-				UidHigh:       uint16(inode.Uid >> 16),
-				GidHigh:       uint16(inode.Gid >> 16),
-				ExtraIsize:    uint16(inodeUsedSize - 128),
-				Atime:         uint32(inode.Atime),
-				AtimeExtra:    uint32(inode.Atime >> 32),
-				Ctime:         uint32(inode.Ctime),
-				CtimeExtra:    uint32(inode.Ctime >> 32),
-				Mtime:         uint32(inode.Mtime),
-				MtimeExtra:    uint32(inode.Mtime >> 32),
-				Crtime:        uint32(inode.Crtime),
-				CrtimeExtra:   uint32(inode.Crtime >> 32),
-			}
-			switch inode.Mode & format.TypeMask {
-			case format.S_IFDIR, format.S_IFREG, format.S_IFLNK:
-				n := copy(binode.Block[:], inode.Data)
-				if n < len(inode.Data) {
-					// Rewrite the first xattr with the data.
-					xattr := [1]xattr{{
-						Name:  "data",
-						Index: 7, // "system."
-						Value: inode.Data[n:],
-					}}
-					putXattrs(xattr[:], inode.XattrInline[4:], 0)
-				}
-			case format.S_IFBLK, format.S_IFCHR:
-				dev := inode.Devminor&0xff | inode.Devmajor<<8 | (inode.Devminor&0xffffff00)<<12
-				binary.LittleEndian.PutUint32(binode.Block[4:], dev)
-			}
-
-			binary.Write(&b, binary.LittleEndian, binode)
-			b.Truncate(inodeUsedSize)
-			n, _ := b.Write(inode.XattrInline)
-			io.CopyN(&b, zero, int64(inodeExtraSize-n))
-		} else {
-			io.CopyN(&b, zero, inodeSize)
-		}
-		if _, err := w.write(b.Next(inodeSize)); err != nil {
-			return err
-		}
-	}
-	rest := tableSize - uint32(len(w.inodes)*inodeSize)
-	if _, err := w.zero(int64(rest)); err != nil {
-		return err
-	}
-	return nil
-}
-
-// NewWriter returns a Writer that writes an ext4 file system to the provided
-// WriteSeeker.
-func NewWriter(f io.ReadWriteSeeker, opts ...Option) *Writer {
-	w := &Writer{
-		f:           f,
-		bw:          bufio.NewWriterSize(f, 65536*8),
-		maxDiskSize: defaultMaxDiskSize,
-	}
-	for _, opt := range opts {
-		opt(w)
-	}
-	return w
-}
-
-// An Option provides extra options to NewWriter.
-type Option func(*Writer)
-
-// InlineData instructs the Writer to write small files into the inode
-// structures directly. This creates smaller images but currently is not
-// compatible with DAX.
-func InlineData(w *Writer) {
-	w.supportInlineData = true
-}
-
-// MaximumDiskSize instructs the writer to reserve enough metadata space for the
-// specified disk size. If not provided, then 16GB is the default.
-func MaximumDiskSize(size int64) Option {
-	return func(w *Writer) {
-		if size < 0 || size > maxMaxDiskSize {
-			w.maxDiskSize = maxMaxDiskSize
-		} else if size == 0 {
-			w.maxDiskSize = defaultMaxDiskSize
-		} else {
-			w.maxDiskSize = (size + blockSize - 1) &^ (blockSize - 1)
-		}
-	}
-}
-
-func (w *Writer) init() error {
-	// Skip the defective block inode.
-	w.inodes = make([]*inode, 1, 32)
-	// Create the root directory.
-	root, _ := w.makeInode(&File{
-		Mode: format.S_IFDIR | 0755,
-	}, nil)
-	root.LinkCount++ // The root is linked to itself.
-	// Skip until the first non-reserved inode.
-	w.inodes = append(w.inodes, make([]*inode, inodeFirst-len(w.inodes)-1)...)
-	maxBlocks := (w.maxDiskSize-1)/blockSize + 1
-	maxGroups := (maxBlocks-1)/blocksPerGroup + 1
-	w.gdBlocks = uint32((maxGroups-1)/groupsPerDescriptorBlock + 1)
-
-	// Skip past the superblock and block descriptor table.
-	w.seekBlock(1 + w.gdBlocks)
-	w.initialized = true
-
-	// The lost+found directory is required to exist for e2fsck to pass.
-	if err := w.Create("lost+found", &File{Mode: format.S_IFDIR | 0700}); err != nil {
-		return err
-	}
-	return w.err
-}
-
-func groupCount(blocks uint32, inodes uint32, inodesPerGroup uint32) uint32 {
-	inodeBlocksPerGroup := inodesPerGroup * inodeSize / blockSize
-	dataBlocksPerGroup := blocksPerGroup - inodeBlocksPerGroup - 2 // save room for the bitmaps
-
-	// Increase the block count to ensure there are enough groups for all the
-	// inodes.
-	minBlocks := (inodes-1)/inodesPerGroup*dataBlocksPerGroup + 1
-	if blocks < minBlocks {
-		blocks = minBlocks
-	}
-
-	return (blocks + dataBlocksPerGroup - 1) / dataBlocksPerGroup
-}
-
-func bestGroupCount(blocks uint32, inodes uint32) (groups uint32, inodesPerGroup uint32) {
-	groups = 0xffffffff
-	for ipg := uint32(inodesPerGroupIncrement); ipg <= maxInodesPerGroup; ipg += inodesPerGroupIncrement {
-		g := groupCount(blocks, inodes, ipg)
-		if g < groups {
-			groups = g
-			inodesPerGroup = ipg
-		}
-	}
-	return
-}
-
-func (w *Writer) Close() error {
-	if err := w.finishInode(); err != nil {
-		return err
-	}
-	root := w.root()
-	if err := w.writeDirectoryRecursive(root, root); err != nil {
-		return err
-	}
-	// Finish the last inode (probably a directory).
-	if err := w.finishInode(); err != nil {
-		return err
-	}
-
-	// Write the inode table
-	inodeTableOffset := w.block()
-	groups, inodesPerGroup := bestGroupCount(inodeTableOffset, uint32(len(w.inodes)))
-	err := w.writeInodeTable(groups * inodesPerGroup * inodeSize)
-	if err != nil {
-		return err
-	}
-
-	// Write the bitmaps.
-	bitmapOffset := w.block()
-	bitmapSize := groups * 2
-	validDataSize := bitmapOffset + bitmapSize
-	diskSize := validDataSize
-	minSize := (groups-1)*blocksPerGroup + 1
-	if diskSize < minSize {
-		diskSize = minSize
-	}
-
-	usedGdBlocks := (groups-1)/groupDescriptorSize + 1
-	if usedGdBlocks > w.gdBlocks {
-		return exceededMaxSizeError{w.maxDiskSize}
-	}
-
-	gds := make([]format.GroupDescriptor, w.gdBlocks*groupsPerDescriptorBlock)
-	inodeTableSizePerGroup := inodesPerGroup * inodeSize / blockSize
-	var totalUsedBlocks, totalUsedInodes uint32
-	for g := uint32(0); g < groups; g++ {
-		var b [blockSize * 2]byte
-		var dirCount, usedInodeCount, usedBlockCount uint16
-
-		// Block bitmap
-		if (g+1)*blocksPerGroup <= validDataSize {
-			// This group is fully allocated.
-			for j := range b[:blockSize] {
-				b[j] = 0xff
-			}
-			usedBlockCount = blocksPerGroup
-		} else if g*blocksPerGroup < validDataSize {
-			for j := uint32(0); j < validDataSize-g*blocksPerGroup; j++ {
-				b[j/8] |= 1 << (j % 8)
-				usedBlockCount++
-			}
-		}
-		if g == 0 {
-			// Unused group descriptor blocks should be cleared.
-			for j := 1 + usedGdBlocks; j < 1+w.gdBlocks; j++ {
-				b[j/8] &^= 1 << (j % 8)
-				usedBlockCount--
-			}
-		}
-		if g == groups-1 && diskSize%blocksPerGroup != 0 {
-			// Blocks that aren't present in the disk should be marked as
-			// allocated.
-			for j := diskSize % blocksPerGroup; j < blocksPerGroup; j++ {
-				b[j/8] |= 1 << (j % 8)
-				usedBlockCount++
-			}
-		}
-		// Inode bitmap
-		for j := uint32(0); j < inodesPerGroup; j++ {
-			ino := format.InodeNumber(1 + g*inodesPerGroup + j)
-			inode := w.getInode(ino)
-			if ino < inodeFirst || inode != nil {
-				b[blockSize+j/8] |= 1 << (j % 8)
-				usedInodeCount++
-			}
-			if inode != nil && inode.Mode&format.TypeMask == format.S_IFDIR {
-				dirCount++
-			}
-		}
-		_, err := w.write(b[:])
-		if err != nil {
-			return err
-		}
-		gds[g] = format.GroupDescriptor{
-			BlockBitmapLow:     bitmapOffset + 2*g,
-			InodeBitmapLow:     bitmapOffset + 2*g + 1,
-			InodeTableLow:      inodeTableOffset + g*inodeTableSizePerGroup,
-			UsedDirsCountLow:   dirCount,
-			FreeInodesCountLow: uint16(inodesPerGroup) - usedInodeCount,
-			FreeBlocksCountLow: blocksPerGroup - usedBlockCount,
-		}
-
-		totalUsedBlocks += uint32(usedBlockCount)
-		totalUsedInodes += uint32(usedInodeCount)
-	}
-
-	// Zero up to the disk size.
-	_, err = w.zero(int64(diskSize-bitmapOffset-bitmapSize) * blockSize)
-	if err != nil {
-		return err
-	}
-
-	// Write the block descriptors
-	w.seekBlock(1)
-	if w.err != nil {
-		return w.err
-	}
-	err = binary.Write(w.bw, binary.LittleEndian, gds)
-	if err != nil {
-		return err
-	}
-
-	// Write the super block
-	var blk [blockSize]byte
-	b := bytes.NewBuffer(blk[:1024])
-	sb := &format.SuperBlock{
-		InodesCount:        inodesPerGroup * groups,
-		BlocksCountLow:     diskSize,
-		FreeBlocksCountLow: blocksPerGroup*groups - totalUsedBlocks,
-		FreeInodesCount:    inodesPerGroup*groups - totalUsedInodes,
-		FirstDataBlock:     0,
-		LogBlockSize:       2, // 2^(10 + 2)
-		LogClusterSize:     2,
-		BlocksPerGroup:     blocksPerGroup,
-		ClustersPerGroup:   blocksPerGroup,
-		InodesPerGroup:     inodesPerGroup,
-		Magic:              format.SuperBlockMagic,
-		State:              1, // cleanly unmounted
-		Errors:             1, // continue on error?
-		CreatorOS:          0, // Linux
-		RevisionLevel:      1, // dynamic inode sizes
-		FirstInode:         inodeFirst,
-		LpfInode:           inodeLostAndFound,
-		InodeSize:          inodeSize,
-		FeatureCompat:      format.CompatSparseSuper2 | format.CompatExtAttr,
-		FeatureIncompat:    format.IncompatFiletype | format.IncompatExtents | format.IncompatFlexBg,
-		FeatureRoCompat:    format.RoCompatLargeFile | format.RoCompatHugeFile | format.RoCompatExtraIsize | format.RoCompatReadonly,
-		MinExtraIsize:      extraIsize,
-		WantExtraIsize:     extraIsize,
-		LogGroupsPerFlex:   31,
-	}
-	if w.supportInlineData {
-		sb.FeatureIncompat |= format.IncompatInlineData
-	}
-	binary.Write(b, binary.LittleEndian, sb)
-	w.seekBlock(0)
-	if _, err := w.write(blk[:]); err != nil {
-		return err
-	}
-	w.seekBlock(diskSize)
-	return w.err
-}

+ 0 - 355
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact_test.go

@@ -1,355 +0,0 @@
-package compactext4
-
-import (
-	"bytes"
-	"encoding/binary"
-	"fmt"
-	"io"
-	"os"
-	"strings"
-	"testing"
-	"time"
-
-	"github.com/Microsoft/hcsshim/ext4/internal/format"
-)
-
-type testFile struct {
-	Path        string
-	File        *File
-	Data        []byte
-	DataSize    int64
-	Link        string
-	ExpectError bool
-}
-
-var (
-	data []byte
-	name string
-)
-
-func init() {
-	data = make([]byte, blockSize*2)
-	for i := range data {
-		data[i] = uint8(i)
-	}
-
-	nameb := make([]byte, 300)
-	for i := range nameb {
-		nameb[i] = byte('0' + i%10)
-	}
-	name = string(nameb)
-}
-
-type largeData struct {
-	pos int64
-}
-
-func (d *largeData) Read(b []byte) (int, error) {
-	p := d.pos
-	var pb [8]byte
-	for i := range b {
-		binary.LittleEndian.PutUint64(pb[:], uint64(p+int64(i)))
-		b[i] = pb[i%8]
-	}
-	p += int64(len(b))
-	return len(b), nil
-}
-
-func (tf *testFile) Reader() io.Reader {
-	if tf.DataSize != 0 {
-		return io.LimitReader(&largeData{}, tf.DataSize)
-	}
-	return bytes.NewReader(tf.Data)
-}
-
-func createTestFile(t *testing.T, w *Writer, tf testFile) {
-	var err error
-	if tf.File != nil {
-		tf.File.Size = int64(len(tf.Data))
-		if tf.File.Size == 0 {
-			tf.File.Size = tf.DataSize
-		}
-		err = w.Create(tf.Path, tf.File)
-	} else {
-		err = w.Link(tf.Link, tf.Path)
-	}
-	if tf.ExpectError && err == nil {
-		t.Errorf("%s: expected error", tf.Path)
-	} else if !tf.ExpectError && err != nil {
-		t.Error(err)
-	} else {
-		_, err := io.Copy(w, tf.Reader())
-		if err != nil {
-			t.Error(err)
-		}
-	}
-}
-
-func expectedMode(f *File) uint16 {
-	switch f.Mode & format.TypeMask {
-	case 0:
-		return f.Mode | S_IFREG
-	case S_IFLNK:
-		return f.Mode | 0777
-	default:
-		return f.Mode
-	}
-}
-
-func expectedSize(f *File) int64 {
-	switch f.Mode & format.TypeMask {
-	case 0, S_IFREG:
-		return f.Size
-	case S_IFLNK:
-		return int64(len(f.Linkname))
-	default:
-		return 0
-	}
-}
-
-func xattrsEqual(x1, x2 map[string][]byte) bool {
-	if len(x1) != len(x2) {
-		return false
-	}
-	for name, value := range x1 {
-		if !bytes.Equal(x2[name], value) {
-			return false
-		}
-	}
-	return true
-}
-
-func fileEqual(f1, f2 *File) bool {
-	return f1.Linkname == f2.Linkname &&
-		expectedSize(f1) == expectedSize(f2) &&
-		expectedMode(f1) == expectedMode(f2) &&
-		f1.Uid == f2.Uid &&
-		f1.Gid == f2.Gid &&
-		f1.Atime.Equal(f2.Atime) &&
-		f1.Ctime.Equal(f2.Ctime) &&
-		f1.Mtime.Equal(f2.Mtime) &&
-		f1.Crtime.Equal(f2.Crtime) &&
-		f1.Devmajor == f2.Devmajor &&
-		f1.Devminor == f2.Devminor &&
-		xattrsEqual(f1.Xattrs, f2.Xattrs)
-}
-
-func runTestsOnFiles(t *testing.T, testFiles []testFile, opts ...Option) {
-	image := "testfs.img"
-	imagef, err := os.Create(image)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer os.Remove(image)
-	defer imagef.Close()
-
-	w := NewWriter(imagef, opts...)
-	for _, tf := range testFiles {
-		createTestFile(t, w, tf)
-		if !tf.ExpectError && tf.File != nil {
-			f, err := w.Stat(tf.Path)
-			if err != nil {
-				if !strings.Contains(err.Error(), "cannot retrieve") {
-					t.Error(err)
-				}
-			} else if !fileEqual(f, tf.File) {
-				t.Errorf("%s: stat mismatch: %#v %#v", tf.Path, tf.File, f)
-			}
-		}
-	}
-
-	if t.Failed() {
-		return
-	}
-
-	if err := w.Close(); err != nil {
-		t.Fatal(err)
-	}
-
-	fsck(t, image)
-
-	mountPath := "testmnt"
-
-	if mountImage(t, image, mountPath) {
-		defer unmountImage(t, mountPath)
-		validated := make(map[string]*testFile)
-		for i := range testFiles {
-			tf := testFiles[len(testFiles)-i-1]
-			if validated[tf.Link] != nil {
-				// The link target was subsequently replaced. Find the
-				// earlier instance.
-				for j := range testFiles[:len(testFiles)-i-1] {
-					otf := testFiles[j]
-					if otf.Path == tf.Link && !otf.ExpectError {
-						tf = otf
-						break
-					}
-				}
-			}
-			if !tf.ExpectError && validated[tf.Path] == nil {
-				verifyTestFile(t, mountPath, tf)
-				validated[tf.Path] = &tf
-			}
-		}
-	}
-}
-
-func TestBasic(t *testing.T) {
-	now := time.Now()
-	testFiles := []testFile{
-		{Path: "empty", File: &File{Mode: 0644}},
-		{Path: "small", File: &File{Mode: 0644}, Data: data[:40]},
-		{Path: "time", File: &File{Atime: now, Ctime: now.Add(time.Second), Mtime: now.Add(time.Hour)}},
-		{Path: "block_1", File: &File{Mode: 0644}, Data: data[:blockSize]},
-		{Path: "block_2", File: &File{Mode: 0644}, Data: data[:blockSize*2]},
-		{Path: "symlink", File: &File{Linkname: "block_1", Mode: format.S_IFLNK}},
-		{Path: "symlink_59", File: &File{Linkname: name[:59], Mode: format.S_IFLNK}},
-		{Path: "symlink_60", File: &File{Linkname: name[:60], Mode: format.S_IFLNK}},
-		{Path: "symlink_120", File: &File{Linkname: name[:120], Mode: format.S_IFLNK}},
-		{Path: "symlink_300", File: &File{Linkname: name[:300], Mode: format.S_IFLNK}},
-		{Path: "dir", File: &File{Mode: format.S_IFDIR | 0755}},
-		{Path: "dir/fifo", File: &File{Mode: format.S_IFIFO}},
-		{Path: "dir/sock", File: &File{Mode: format.S_IFSOCK}},
-		{Path: "dir/blk", File: &File{Mode: format.S_IFBLK, Devmajor: 0x5678, Devminor: 0x1234}},
-		{Path: "dir/chr", File: &File{Mode: format.S_IFCHR, Devmajor: 0x5678, Devminor: 0x1234}},
-		{Path: "dir/hard_link", Link: "small"},
-	}
-
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestLargeDirectory(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "bigdir", File: &File{Mode: format.S_IFDIR | 0755}},
-	}
-	for i := 0; i < 50000; i++ {
-		testFiles = append(testFiles, testFile{
-			Path: fmt.Sprintf("bigdir/%d", i), File: &File{Mode: 0644},
-		})
-	}
-
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestInlineData(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "inline_30", File: &File{Mode: 0644}, Data: data[:30]},
-		{Path: "inline_60", File: &File{Mode: 0644}, Data: data[:60]},
-		{Path: "inline_120", File: &File{Mode: 0644}, Data: data[:120]},
-		{Path: "inline_full", File: &File{Mode: 0644}, Data: data[:inlineDataSize]},
-		{Path: "block_min", File: &File{Mode: 0644}, Data: data[:inlineDataSize+1]},
-	}
-
-	runTestsOnFiles(t, testFiles, InlineData)
-}
-
-func TestXattrs(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "withsmallxattrs",
-			File: &File{
-				Mode: format.S_IFREG | 0644,
-				Xattrs: map[string][]byte{
-					"user.foo": []byte("test"),
-					"user.bar": []byte("test2"),
-				},
-			},
-		},
-		{Path: "withlargexattrs",
-			File: &File{
-				Mode: format.S_IFREG | 0644,
-				Xattrs: map[string][]byte{
-					"user.foo": data[:100],
-					"user.bar": data[:50],
-				},
-			},
-		},
-	}
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestReplace(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "lost+found", ExpectError: true, File: &File{}}, // can't change type
-		{Path: "lost+found", File: &File{Mode: format.S_IFDIR | 0777}},
-
-		{Path: "dir", File: &File{Mode: format.S_IFDIR | 0777}},
-		{Path: "dir/file", File: &File{}},
-		{Path: "dir", File: &File{Mode: format.S_IFDIR | 0700}},
-
-		{Path: "file", File: &File{}},
-		{Path: "file", File: &File{Mode: 0600}},
-		{Path: "file2", File: &File{}},
-		{Path: "link", Link: "file2"},
-		{Path: "file2", File: &File{Mode: 0600}},
-
-		{Path: "nolinks", File: &File{}},
-		{Path: "nolinks", ExpectError: true, Link: "file"}, // would orphan nolinks
-
-		{Path: "onelink", File: &File{}},
-		{Path: "onelink2", Link: "onelink"},
-		{Path: "onelink", Link: "file"},
-
-		{Path: "", ExpectError: true, File: &File{}},
-		{Path: "", ExpectError: true, Link: "file"},
-		{Path: "", File: &File{Mode: format.S_IFDIR | 0777}},
-
-		{Path: "smallxattr", File: &File{Xattrs: map[string][]byte{"user.foo": data[:4]}}},
-		{Path: "smallxattr", File: &File{Xattrs: map[string][]byte{"user.foo": data[:8]}}},
-
-		{Path: "smallxattr_delete", File: &File{Xattrs: map[string][]byte{"user.foo": data[:4]}}},
-		{Path: "smallxattr_delete", File: &File{}},
-
-		{Path: "largexattr", File: &File{Xattrs: map[string][]byte{"user.small": data[:8], "user.foo": data[:200]}}},
-		{Path: "largexattr", File: &File{Xattrs: map[string][]byte{"user.small": data[:12], "user.foo": data[:400]}}},
-
-		{Path: "largexattr", File: &File{Xattrs: map[string][]byte{"user.foo": data[:200]}}},
-		{Path: "largexattr_delete", File: &File{}},
-	}
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestTime(t *testing.T) {
-	now := time.Now()
-	now2 := fsTimeToTime(timeToFsTime(now))
-	if now.UnixNano() != now2.UnixNano() {
-		t.Fatalf("%s != %s", now, now2)
-	}
-}
-
-func TestLargeFile(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "small", File: &File{}, DataSize: 1024 * 1024},        // can't change type
-		{Path: "medium", File: &File{}, DataSize: 200 * 1024 * 1024}, // can't change type
-		{Path: "large", File: &File{}, DataSize: 600 * 1024 * 1024},  // can't change type
-	}
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestFileLinkLimit(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "file", File: &File{}},
-	}
-	for i := 0; i < format.MaxLinks; i++ {
-		testFiles = append(testFiles, testFile{Path: fmt.Sprintf("link%d", i), Link: "file"})
-	}
-	testFiles[len(testFiles)-1].ExpectError = true
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestDirLinkLimit(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "dir", File: &File{Mode: S_IFDIR}},
-	}
-	for i := 0; i < format.MaxLinks-1; i++ {
-		testFiles = append(testFiles, testFile{Path: fmt.Sprintf("dir/%d", i), File: &File{Mode: S_IFDIR}})
-	}
-	testFiles[len(testFiles)-1].ExpectError = true
-	runTestsOnFiles(t, testFiles)
-}
-
-func TestLargeDisk(t *testing.T) {
-	testFiles := []testFile{
-		{Path: "file", File: &File{}},
-	}
-	runTestsOnFiles(t, testFiles, MaximumDiskSize(maxMaxDiskSize))
-}

+ 0 - 248
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/verify_linux_test.go

@@ -1,248 +0,0 @@
-package compactext4
-
-import (
-	"bytes"
-	"fmt"
-	"io"
-	"os"
-	"os/exec"
-	"path"
-	"syscall"
-	"testing"
-	"time"
-	"unsafe"
-
-	"github.com/Microsoft/hcsshim/ext4/internal/format"
-)
-
-func timeEqual(ts syscall.Timespec, t time.Time) bool {
-	sec, nsec := t.Unix(), t.Nanosecond()
-	if t.IsZero() {
-		sec, nsec = 0, 0
-	}
-	return ts.Sec == sec && int(ts.Nsec) == nsec
-}
-
-func expectedDevice(f *File) uint64 {
-	return uint64(f.Devminor&0xff | f.Devmajor<<8 | (f.Devminor&0xffffff00)<<12)
-}
-
-func llistxattr(path string, b []byte) (int, error) {
-	pathp := syscall.StringBytePtr(path)
-	var p unsafe.Pointer
-	if len(b) > 0 {
-		p = unsafe.Pointer(&b[0])
-	}
-	r, _, e := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(pathp)), uintptr(p), uintptr(len(b)))
-	if e != 0 {
-		return 0, &os.PathError{Path: path, Op: "llistxattr", Err: syscall.Errno(e)}
-	}
-	return int(r), nil
-}
-
-func lgetxattr(path string, name string, b []byte) (int, error) {
-	pathp := syscall.StringBytePtr(path)
-	namep := syscall.StringBytePtr(name)
-	var p unsafe.Pointer
-	if len(b) > 0 {
-		p = unsafe.Pointer(&b[0])
-	}
-	r, _, e := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathp)), uintptr(unsafe.Pointer(namep)), uintptr(p), uintptr(len(b)), 0, 0)
-	if e != 0 {
-		return 0, &os.PathError{Path: path, Op: "lgetxattr", Err: syscall.Errno(e)}
-	}
-	return int(r), nil
-}
-
-func readXattrs(path string) (map[string][]byte, error) {
-	xattrs := make(map[string][]byte)
-	var buf [4096]byte
-	var buf2 [4096]byte
-	b := buf[:]
-	n, err := llistxattr(path, b)
-	if err != nil {
-		return nil, err
-	}
-	b = b[:n]
-	for len(b) != 0 {
-		nn := bytes.IndexByte(b, 0)
-		name := string(b[:nn])
-		b = b[nn+1:]
-		vn, err := lgetxattr(path, name, buf2[:])
-		if err != nil {
-			return nil, err
-		}
-		value := buf2[:vn]
-		xattrs[name] = value
-	}
-	return xattrs, nil
-}
-
-func streamEqual(r1, r2 io.Reader) (bool, error) {
-	var b [4096]byte
-	var b2 [4096]byte
-	for {
-		n, err := r1.Read(b[:])
-		if n == 0 {
-			if err == io.EOF {
-				break
-			}
-			if err == nil {
-				continue
-			}
-			return false, err
-		}
-		_, err = io.ReadFull(r2, b2[:n])
-		if err == io.EOF || err == io.ErrUnexpectedEOF {
-			return false, nil
-		}
-		if err != nil {
-			return false, err
-		}
-		if !bytes.Equal(b[n:], b2[n:]) {
-			return false, nil
-		}
-	}
-	// Check the tail of r2
-	_, err := r2.Read(b[:1])
-	if err == nil {
-		return false, nil
-	}
-	if err != io.EOF {
-		return false, err
-	}
-	return true, nil
-}
-
-func verifyTestFile(t *testing.T, mountPath string, tf testFile) {
-	name := path.Join(mountPath, tf.Path)
-	fi, err := os.Lstat(name)
-	if err != nil {
-		t.Error(err)
-		return
-	}
-	st := fi.Sys().(*syscall.Stat_t)
-	if tf.File != nil {
-		if st.Mode != uint32(expectedMode(tf.File)) ||
-			st.Uid != tf.File.Uid ||
-			st.Gid != tf.File.Gid ||
-			(!fi.IsDir() && st.Size != expectedSize(tf.File)) ||
-			st.Rdev != expectedDevice(tf.File) ||
-			!timeEqual(st.Atim, tf.File.Atime) ||
-			!timeEqual(st.Mtim, tf.File.Mtime) ||
-			!timeEqual(st.Ctim, tf.File.Ctime) {
-
-			t.Errorf("%s: stat mismatch, expected: %#v got: %#v", tf.Path, tf.File, st)
-		}
-
-		xattrs, err := readXattrs(name)
-		if err != nil {
-			t.Error(err)
-		} else if !xattrsEqual(xattrs, tf.File.Xattrs) {
-			t.Errorf("%s: xattr mismatch, expected: %#v got: %#v", tf.Path, tf.File.Xattrs, xattrs)
-		}
-
-		switch tf.File.Mode & format.TypeMask {
-		case S_IFREG:
-			if f, err := os.Open(name); err != nil {
-				t.Error(err)
-			} else {
-				same, err := streamEqual(f, tf.Reader())
-				if err != nil {
-					t.Error(err)
-				} else if !same {
-					t.Errorf("%s: data mismatch", tf.Path)
-				}
-				f.Close()
-			}
-		case S_IFLNK:
-			if link, err := os.Readlink(name); err != nil {
-				t.Error(err)
-			} else if link != tf.File.Linkname {
-				t.Errorf("%s: link mismatch, expected: %s got: %s", tf.Path, tf.File.Linkname, link)
-			}
-		}
-	} else {
-		lfi, err := os.Lstat(path.Join(mountPath, tf.Link))
-		if err != nil {
-			t.Error(err)
-			return
-		}
-
-		lst := lfi.Sys().(*syscall.Stat_t)
-		if lst.Ino != st.Ino {
-			t.Errorf("%s: hard link mismatch with %s, expected inode: %d got inode: %d", tf.Path, tf.Link, lst.Ino, st.Ino)
-		}
-	}
-}
-
-type capHeader struct {
-	version uint32
-	pid     int
-}
-
-type capData struct {
-	effective   uint32
-	permitted   uint32
-	inheritable uint32
-}
-
-const CAP_SYS_ADMIN = 21
-
-type caps struct {
-	hdr  capHeader
-	data [2]capData
-}
-
-func getCaps() (caps, error) {
-	var c caps
-
-	// Get capability version
-	if _, _, errno := syscall.Syscall(syscall.SYS_CAPGET, uintptr(unsafe.Pointer(&c.hdr)), uintptr(unsafe.Pointer(nil)), 0); errno != 0 {
-		return c, fmt.Errorf("SYS_CAPGET: %v", errno)
-	}
-
-	// Get current capabilities
-	if _, _, errno := syscall.Syscall(syscall.SYS_CAPGET, uintptr(unsafe.Pointer(&c.hdr)), uintptr(unsafe.Pointer(&c.data[0])), 0); errno != 0 {
-		return c, fmt.Errorf("SYS_CAPGET: %v", errno)
-	}
-
-	return c, nil
-}
-
-func mountImage(t *testing.T, image string, mountPath string) bool {
-	caps, err := getCaps()
-	if err != nil || caps.data[0].effective&(1<<uint(CAP_SYS_ADMIN)) == 0 {
-		t.Log("cannot mount to run verification tests without CAP_SYS_ADMIN")
-		return false
-	}
-
-	err = os.MkdirAll(mountPath, 0777)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	out, err := exec.Command("mount", "-o", "loop,ro", "-t", "ext4", image, mountPath).CombinedOutput()
-	t.Logf("%s", out)
-	if err != nil {
-		t.Fatal(err)
-	}
-	return true
-}
-
-func unmountImage(t *testing.T, mountPath string) {
-	out, err := exec.Command("umount", mountPath).CombinedOutput()
-	t.Logf("%s", out)
-	if err != nil {
-		t.Log(err)
-	}
-}
-
-func fsck(t *testing.T, image string) {
-	cmd := exec.Command("e2fsck", "-v", "-f", "-n", image)
-	out, err := cmd.CombinedOutput()
-	t.Logf("%s", out)
-	if err != nil {
-		t.Fatal(err)
-	}
-}

+ 0 - 18
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/verify_test.go

@@ -1,18 +0,0 @@
-// +build !linux
-
-package compactext4
-
-import "testing"
-
-func verifyTestFile(t *testing.T, mountPath string, tf testFile) {
-}
-
-func mountImage(t *testing.T, image string, mountPath string) bool {
-	return false
-}
-
-func unmountImage(t *testing.T, mountPath string) {
-}
-
-func fsck(t *testing.T, image string) {
-}

+ 0 - 411
vendor/github.com/Microsoft/hcsshim/ext4/internal/format/format.go

@@ -1,411 +0,0 @@
-package format
-
-type SuperBlock struct {
-	InodesCount          uint32
-	BlocksCountLow       uint32
-	RootBlocksCountLow   uint32
-	FreeBlocksCountLow   uint32
-	FreeInodesCount      uint32
-	FirstDataBlock       uint32
-	LogBlockSize         uint32
-	LogClusterSize       uint32
-	BlocksPerGroup       uint32
-	ClustersPerGroup     uint32
-	InodesPerGroup       uint32
-	Mtime                uint32
-	Wtime                uint32
-	MountCount           uint16
-	MaxMountCount        uint16
-	Magic                uint16
-	State                uint16
-	Errors               uint16
-	MinorRevisionLevel   uint16
-	LastCheck            uint32
-	CheckInterval        uint32
-	CreatorOS            uint32
-	RevisionLevel        uint32
-	DefaultReservedUid   uint16
-	DefaultReservedGid   uint16
-	FirstInode           uint32
-	InodeSize            uint16
-	BlockGroupNr         uint16
-	FeatureCompat        CompatFeature
-	FeatureIncompat      IncompatFeature
-	FeatureRoCompat      RoCompatFeature
-	UUID                 [16]uint8
-	VolumeName           [16]byte
-	LastMounted          [64]byte
-	AlgorithmUsageBitmap uint32
-	PreallocBlocks       uint8
-	PreallocDirBlocks    uint8
-	ReservedGdtBlocks    uint16
-	JournalUUID          [16]uint8
-	JournalInum          uint32
-	JournalDev           uint32
-	LastOrphan           uint32
-	HashSeed             [4]uint32
-	DefHashVersion       uint8
-	JournalBackupType    uint8
-	DescSize             uint16
-	DefaultMountOpts     uint32
-	FirstMetaBg          uint32
-	MkfsTime             uint32
-	JournalBlocks        [17]uint32
-	BlocksCountHigh      uint32
-	RBlocksCountHigh     uint32
-	FreeBlocksCountHigh  uint32
-	MinExtraIsize        uint16
-	WantExtraIsize       uint16
-	Flags                uint32
-	RaidStride           uint16
-	MmpInterval          uint16
-	MmpBlock             uint64
-	RaidStripeWidth      uint32
-	LogGroupsPerFlex     uint8
-	ChecksumType         uint8
-	ReservedPad          uint16
-	KbytesWritten        uint64
-	SnapshotInum         uint32
-	SnapshotID           uint32
-	SnapshotRBlocksCount uint64
-	SnapshotList         uint32
-	ErrorCount           uint32
-	FirstErrorTime       uint32
-	FirstErrorInode      uint32
-	FirstErrorBlock      uint64
-	FirstErrorFunc       [32]uint8
-	FirstErrorLine       uint32
-	LastErrorTime        uint32
-	LastErrorInode       uint32
-	LastErrorLine        uint32
-	LastErrorBlock       uint64
-	LastErrorFunc        [32]uint8
-	MountOpts            [64]uint8
-	UserQuotaInum        uint32
-	GroupQuotaInum       uint32
-	OverheadBlocks       uint32
-	BackupBgs            [2]uint32
-	EncryptAlgos         [4]uint8
-	EncryptPwSalt        [16]uint8
-	LpfInode             uint32
-	ProjectQuotaInum     uint32
-	ChecksumSeed         uint32
-	WtimeHigh            uint8
-	MtimeHigh            uint8
-	MkfsTimeHigh         uint8
-	LastcheckHigh        uint8
-	FirstErrorTimeHigh   uint8
-	LastErrorTimeHigh    uint8
-	Pad                  [2]uint8
-	Reserved             [96]uint32
-	Checksum             uint32
-}
-
-const SuperBlockMagic uint16 = 0xef53
-
-type CompatFeature uint32
-type IncompatFeature uint32
-type RoCompatFeature uint32
-
-const (
-	CompatDirPrealloc   CompatFeature = 0x1
-	CompatImagicInodes  CompatFeature = 0x2
-	CompatHasJournal    CompatFeature = 0x4
-	CompatExtAttr       CompatFeature = 0x8
-	CompatResizeInode   CompatFeature = 0x10
-	CompatDirIndex      CompatFeature = 0x20
-	CompatLazyBg        CompatFeature = 0x40
-	CompatExcludeInode  CompatFeature = 0x80
-	CompatExcludeBitmap CompatFeature = 0x100
-	CompatSparseSuper2  CompatFeature = 0x200
-
-	IncompatCompression IncompatFeature = 0x1
-	IncompatFiletype    IncompatFeature = 0x2
-	IncompatRecover     IncompatFeature = 0x4
-	IncompatJournalDev  IncompatFeature = 0x8
-	IncompatMetaBg      IncompatFeature = 0x10
-	IncompatExtents     IncompatFeature = 0x40
-	Incompat_64Bit      IncompatFeature = 0x80
-	IncompatMmp         IncompatFeature = 0x100
-	IncompatFlexBg      IncompatFeature = 0x200
-	IncompatEaInode     IncompatFeature = 0x400
-	IncompatDirdata     IncompatFeature = 0x1000
-	IncompatCsumSeed    IncompatFeature = 0x2000
-	IncompatLargedir    IncompatFeature = 0x4000
-	IncompatInlineData  IncompatFeature = 0x8000
-	IncompatEncrypt     IncompatFeature = 0x10000
-
-	RoCompatSparseSuper  RoCompatFeature = 0x1
-	RoCompatLargeFile    RoCompatFeature = 0x2
-	RoCompatBtreeDir     RoCompatFeature = 0x4
-	RoCompatHugeFile     RoCompatFeature = 0x8
-	RoCompatGdtCsum      RoCompatFeature = 0x10
-	RoCompatDirNlink     RoCompatFeature = 0x20
-	RoCompatExtraIsize   RoCompatFeature = 0x40
-	RoCompatHasSnapshot  RoCompatFeature = 0x80
-	RoCompatQuota        RoCompatFeature = 0x100
-	RoCompatBigalloc     RoCompatFeature = 0x200
-	RoCompatMetadataCsum RoCompatFeature = 0x400
-	RoCompatReplica      RoCompatFeature = 0x800
-	RoCompatReadonly     RoCompatFeature = 0x1000
-	RoCompatProject      RoCompatFeature = 0x2000
-)
-
-type BlockGroupFlag uint16
-
-const (
-	BlockGroupInodeUninit BlockGroupFlag = 0x1
-	BlockGroupBlockUninit BlockGroupFlag = 0x2
-	BlockGroupInodeZeroed BlockGroupFlag = 0x4
-)
-
-type GroupDescriptor struct {
-	BlockBitmapLow     uint32
-	InodeBitmapLow     uint32
-	InodeTableLow      uint32
-	FreeBlocksCountLow uint16
-	FreeInodesCountLow uint16
-	UsedDirsCountLow   uint16
-	Flags              BlockGroupFlag
-	ExcludeBitmapLow   uint32
-	BlockBitmapCsumLow uint16
-	InodeBitmapCsumLow uint16
-	ItableUnusedLow    uint16
-	Checksum           uint16
-}
-
-type GroupDescriptor64 struct {
-	GroupDescriptor
-	BlockBitmapHigh     uint32
-	InodeBitmapHigh     uint32
-	InodeTableHigh      uint32
-	FreeBlocksCountHigh uint16
-	FreeInodesCountHigh uint16
-	UsedDirsCountHigh   uint16
-	ItableUnusedHigh    uint16
-	ExcludeBitmapHigh   uint32
-	BlockBitmapCsumHigh uint16
-	InodeBitmapCsumHigh uint16
-	Reserved            uint32
-}
-
-const (
-	S_IXOTH  = 0x1
-	S_IWOTH  = 0x2
-	S_IROTH  = 0x4
-	S_IXGRP  = 0x8
-	S_IWGRP  = 0x10
-	S_IRGRP  = 0x20
-	S_IXUSR  = 0x40
-	S_IWUSR  = 0x80
-	S_IRUSR  = 0x100
-	S_ISVTX  = 0x200
-	S_ISGID  = 0x400
-	S_ISUID  = 0x800
-	S_IFIFO  = 0x1000
-	S_IFCHR  = 0x2000
-	S_IFDIR  = 0x4000
-	S_IFBLK  = 0x6000
-	S_IFREG  = 0x8000
-	S_IFLNK  = 0xA000
-	S_IFSOCK = 0xC000
-
-	TypeMask uint16 = 0xF000
-)
-
-type InodeNumber uint32
-
-const (
-	InodeRoot = 2
-)
-
-type Inode struct {
-	Mode                 uint16
-	Uid                  uint16
-	SizeLow              uint32
-	Atime                uint32
-	Ctime                uint32
-	Mtime                uint32
-	Dtime                uint32
-	Gid                  uint16
-	LinksCount           uint16
-	BlocksLow            uint32
-	Flags                InodeFlag
-	Version              uint32
-	Block                [60]byte
-	Generation           uint32
-	XattrBlockLow        uint32
-	SizeHigh             uint32
-	ObsoleteFragmentAddr uint32
-	BlocksHigh           uint16
-	XattrBlockHigh       uint16
-	UidHigh              uint16
-	GidHigh              uint16
-	ChecksumLow          uint16
-	Reserved             uint16
-	ExtraIsize           uint16
-	ChecksumHigh         uint16
-	CtimeExtra           uint32
-	MtimeExtra           uint32
-	AtimeExtra           uint32
-	Crtime               uint32
-	CrtimeExtra          uint32
-	VersionHigh          uint32
-	Projid               uint32
-}
-
-type InodeFlag uint32
-
-const (
-	InodeFlagSecRm              InodeFlag = 0x1
-	InodeFlagUnRm               InodeFlag = 0x2
-	InodeFlagCompressed         InodeFlag = 0x4
-	InodeFlagSync               InodeFlag = 0x8
-	InodeFlagImmutable          InodeFlag = 0x10
-	InodeFlagAppend             InodeFlag = 0x20
-	InodeFlagNoDump             InodeFlag = 0x40
-	InodeFlagNoAtime            InodeFlag = 0x80
-	InodeFlagDirtyCompressed    InodeFlag = 0x100
-	InodeFlagCompressedClusters InodeFlag = 0x200
-	InodeFlagNoCompress         InodeFlag = 0x400
-	InodeFlagEncrypted          InodeFlag = 0x800
-	InodeFlagHashedIndex        InodeFlag = 0x1000
-	InodeFlagMagic              InodeFlag = 0x2000
-	InodeFlagJournalData        InodeFlag = 0x4000
-	InodeFlagNoTail             InodeFlag = 0x8000
-	InodeFlagDirSync            InodeFlag = 0x10000
-	InodeFlagTopDir             InodeFlag = 0x20000
-	InodeFlagHugeFile           InodeFlag = 0x40000
-	InodeFlagExtents            InodeFlag = 0x80000
-	InodeFlagEaInode            InodeFlag = 0x200000
-	InodeFlagEOFBlocks          InodeFlag = 0x400000
-	InodeFlagSnapfile           InodeFlag = 0x01000000
-	InodeFlagSnapfileDeleted    InodeFlag = 0x04000000
-	InodeFlagSnapfileShrunk     InodeFlag = 0x08000000
-	InodeFlagInlineData         InodeFlag = 0x10000000
-	InodeFlagProjectIDInherit   InodeFlag = 0x20000000
-	InodeFlagReserved           InodeFlag = 0x80000000
-)
-
-const (
-	MaxLinks = 65000
-)
-
-type ExtentHeader struct {
-	Magic      uint16
-	Entries    uint16
-	Max        uint16
-	Depth      uint16
-	Generation uint32
-}
-
-const ExtentHeaderMagic uint16 = 0xf30a
-
-type ExtentIndexNode struct {
-	Block    uint32
-	LeafLow  uint32
-	LeafHigh uint16
-	Unused   uint16
-}
-
-type ExtentLeafNode struct {
-	Block     uint32
-	Length    uint16
-	StartHigh uint16
-	StartLow  uint32
-}
-
-type ExtentTail struct {
-	Checksum uint32
-}
-
-type DirectoryEntry struct {
-	Inode        InodeNumber
-	RecordLength uint16
-	NameLength   uint8
-	FileType     FileType
-	//Name         []byte
-}
-
-type FileType uint8
-
-const (
-	FileTypeUnknown      FileType = 0x0
-	FileTypeRegular      FileType = 0x1
-	FileTypeDirectory    FileType = 0x2
-	FileTypeCharacter    FileType = 0x3
-	FileTypeBlock        FileType = 0x4
-	FileTypeFIFO         FileType = 0x5
-	FileTypeSocket       FileType = 0x6
-	FileTypeSymbolicLink FileType = 0x7
-)
-
-type DirectoryEntryTail struct {
-	ReservedZero1 uint32
-	RecordLength  uint16
-	ReservedZero2 uint8
-	FileType      uint8
-	Checksum      uint32
-}
-
-type DirectoryTreeRoot struct {
-	Dot            DirectoryEntry
-	DotName        [4]byte
-	DotDot         DirectoryEntry
-	DotDotName     [4]byte
-	ReservedZero   uint32
-	HashVersion    uint8
-	InfoLength     uint8
-	IndirectLevels uint8
-	UnusedFlags    uint8
-	Limit          uint16
-	Count          uint16
-	Block          uint32
-	//Entries        []DirectoryTreeEntry
-}
-
-type DirectoryTreeNode struct {
-	FakeInode        uint32
-	FakeRecordLength uint16
-	NameLength       uint8
-	FileType         uint8
-	Limit            uint16
-	Count            uint16
-	Block            uint32
-	//Entries          []DirectoryTreeEntry
-}
-
-type DirectoryTreeEntry struct {
-	Hash  uint32
-	Block uint32
-}
-
-type DirectoryTreeTail struct {
-	Reserved uint32
-	Checksum uint32
-}
-
-type XAttrInodeBodyHeader struct {
-	Magic uint32
-}
-
-type XAttrHeader struct {
-	Magic          uint32
-	ReferenceCount uint32
-	Blocks         uint32
-	Hash           uint32
-	Checksum       uint32
-	Reserved       [3]uint32
-}
-
-const XAttrHeaderMagic uint32 = 0xea020000
-
-type XAttrEntry struct {
-	NameLength  uint8
-	NameIndex   uint8
-	ValueOffset uint16
-	ValueInum   uint32
-	ValueSize   uint32
-	Hash        uint32
-	//Name        []byte
-}

Some files were not shown because too many files changed in this diff