Skip to content

Commit

Permalink
squashfs: passthrough squashfs compressed layers
Browse files Browse the repository at this point in the history
squashfs blobs are internally compressed, so bypass
compression/decompression

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha committed Nov 17, 2021
1 parent fb356f8 commit f012225
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/compression/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ 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,
Bzip2.Name(): Bzip2,
Xz.Name(): Xz,
Zstd.Name(): Zstd,
ZstdChunked.Name(): ZstdChunked,
Squashfs.Name(): Squashfs,
}
)

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/compression/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit f012225

Please sign in to comment.