moby/pkg/chrootarchive/diff_unix.go
Artem Khramov 8b843732b3 pkg/chrootarchive: fix FreeBSD build
For unix targets, `goInChroot()` is only implemented for `Linux`,
hence FreeBSD build fails.

This change

- Adds FreeBSD-specific chrooted tar/untar implementation
- Fixes statUnix() to accomodate to FreeBSD devminor/devmajor
- quirk. See also: https://github.com/containerd/containerd/pull/5991

Signed-off-by: Artem Khramov <akhramov@pm.me>
Co-authored-by: Cory Snider <corhere@gmail.com>
2023-07-18 18:42:08 +02:00

37 lines
966 B
Go

//go:build !windows
package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive"
import (
"io"
"path/filepath"
"github.com/containerd/containerd/pkg/userns"
"github.com/docker/docker/pkg/archive"
)
// applyLayerHandler parses a diff in the standard layer format from `layer`, and
// applies it to the directory `dest`. Returns the size in bytes of the
// contents of the layer.
func applyLayerHandler(dest string, layer io.Reader, options *archive.TarOptions, decompress bool) (size int64, err error) {
dest = filepath.Clean(dest)
if decompress {
decompressed, err := archive.DecompressStream(layer)
if err != nil {
return 0, err
}
defer decompressed.Close()
layer = decompressed
}
if options == nil {
options = &archive.TarOptions{}
}
if userns.RunningInUserNS() {
options.InUserNS = true
}
if options.ExcludePatterns == nil {
options.ExcludePatterns = []string{}
}
return doUnpackLayer(dest, layer, options)
}