github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/pkg/chrootarchive/diff_unix.go (about) 1 //go:build !windows 2 3 package chrootarchive // import "github.com/Prakhar-Agarwal-byte/moby/pkg/chrootarchive" 4 5 import ( 6 "io" 7 "path/filepath" 8 9 "github.com/Prakhar-Agarwal-byte/moby/pkg/archive" 10 "github.com/containerd/containerd/pkg/userns" 11 ) 12 13 // applyLayerHandler parses a diff in the standard layer format from `layer`, and 14 // applies it to the directory `dest`. Returns the size in bytes of the 15 // contents of the layer. 16 func applyLayerHandler(dest string, layer io.Reader, options *archive.TarOptions, decompress bool) (size int64, err error) { 17 dest = filepath.Clean(dest) 18 if decompress { 19 decompressed, err := archive.DecompressStream(layer) 20 if err != nil { 21 return 0, err 22 } 23 defer decompressed.Close() 24 25 layer = decompressed 26 } 27 if options == nil { 28 options = &archive.TarOptions{} 29 } 30 if userns.RunningInUserNS() { 31 options.InUserNS = true 32 } 33 if options.ExcludePatterns == nil { 34 options.ExcludePatterns = []string{} 35 } 36 return doUnpackLayer(dest, layer, options) 37 }