gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/boot/multiboot/reader.go (about) 1 // Copyright 2019 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package multiboot 6 7 import ( 8 "bytes" 9 "compress/gzip" 10 "io" 11 "io/ioutil" 12 13 "github.com/u-root/u-root/pkg/uio" 14 ) 15 16 func readGzip(r io.Reader) ([]byte, error) { 17 z, err := gzip.NewReader(r) 18 if err != nil { 19 return nil, err 20 } 21 defer z.Close() 22 return ioutil.ReadAll(z) 23 } 24 25 // TODO: could be tryCompressionFilters, grub support gz,xz and lzop 26 // TODO: do we want to keep the filter inside multiboot? This could be the responsibility of the caller... 27 func tryGzipFilter(r io.ReaderAt) io.ReaderAt { 28 b, err := readGzip(uio.Reader(r)) 29 if err == nil { 30 return bytes.NewReader(b) 31 } 32 return r 33 }