From b0c0a9a71b32b68f3ce5be261da2e8c4c6b39d40 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Wed, 17 Nov 2021 02:14:16 +0000 Subject: [PATCH] squashfs: passthrough squashfs compressed layers squashfs blobs are internally compressed, so bypass compression/decompression Signed-off-by: Ramkumar Chinchani --- pkg/compression/compression.go | 9 +++++++++ pkg/compression/types/types.go | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/pkg/compression/compression.go b/pkg/compression/compression.go index c28e817929..21c6309116 100644 --- a/pkg/compression/compression.go +++ b/pkg/compression/compression.go @@ -35,6 +35,9 @@ var ( // Zstd:chunked compression. ZstdChunked = internal.NewAlgorithm(types.ZstdChunkedAlgorithmName, types.ZstdAlgorithmName, /* Note: InternalUnstableUndocumentedMIMEQuestionMark is not ZstdChunkedAlgorithmName */ nil, ZstdDecompressor, compressor.ZstdCompressor) + // Squashfs compression. + Squashfs = internal.NewAlgorithm(types.SquashfsAlgorithmName, types.SquashfsAlgorithmName, + []byte{0x68, 0x73, 0x71, 0x73}, SquashfsDecompressor, nil) compressionAlgorithms = map[string]Algorithm{ Gzip.Name(): Gzip, @@ -42,6 +45,7 @@ var ( Xz.Name(): Xz, Zstd.Name(): Zstd, ZstdChunked.Name(): ZstdChunked, + Squashfs.Name(): Squashfs, } ) @@ -77,6 +81,11 @@ func XzDecompressor(r io.Reader) (io.ReadCloser, error) { return ioutil.NopCloser(r), nil } +// SquashfsDecompressor is a DecompressorFunc for the squashfs compression algorithm. +func SquashfsDecompressor(r io.Reader) (io.ReadCloser, error) { + return ioutil.NopCloser(r), nil +} + // gzipCompressor is a CompressorFunc for the gzip compression algorithm. func gzipCompressor(r io.Writer, metadata map[string]string, level *int) (io.WriteCloser, error) { if level != nil { diff --git a/pkg/compression/types/types.go b/pkg/compression/types/types.go index 43d03b601c..5403c1cb0e 100644 --- a/pkg/compression/types/types.go +++ b/pkg/compression/types/types.go @@ -38,4 +38,9 @@ const ( // will actually be available. (In fact it is intended for this types package not to depend // on any of the implementations.) ZstdChunkedAlgorithmName = "zstd:chunked" + // SquashfsAlgorithName is the name used by pkg/compression.Squashfs + // NOTE: Importing only this /types package does not inherently guarantee a Squashfs algorithm + // will actually be available. (In fact it is intended for this types package not to depend + // on any of the implementations.) + SquashfsAlgorithmName = "squashfs" )