Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterDecompressor(method Compression, dcomp Decompressor)
- type Compression
- type Decompressor
- type Dir
- func (d *Dir) Close() error
- func (ni Dir) IsDir() bool
- func (ni Dir) ModTime() time.Time
- func (ni Dir) Mode() fs.FileMode
- func (ni Dir) Name() string
- func (d *Dir) Read([]byte) (int, error)
- func (d *Dir) ReadDir(n int) ([]fs.DirEntry, error)
- func (ni Dir) ReadLink() (string, error)
- func (ni Dir) Size() int64
- func (ni Dir) Stat() (fs.FileInfo, error)
- func (ni Dir) Sys() any
- type FS
- func (sq *FS) Lstat(name string) (fs.FileInfo, error)
- func (sq *FS) Open(name string) (fs.File, error)
- func (sq *FS) ReadDir(name string) ([]fs.DirEntry, error)
- func (sq *FS) ReadLink(name string) (string, error)
- func (sq *FS) Stat(name string) (fs.FileInfo, error)
- func (sq *FS) UnmarshalBinary(data []byte) error
- type File
- type Flags
- type SysStat
- type Unhandled
- func (ni Unhandled) Close() error
- func (ni Unhandled) IsDir() bool
- func (ni Unhandled) ModTime() time.Time
- func (ni Unhandled) Mode() fs.FileMode
- func (ni Unhandled) Name() string
- func (s Unhandled) Read([]byte) (int, error)
- func (ni Unhandled) ReadLink() (string, error)
- func (ni Unhandled) Size() int64
- func (ni Unhandled) Stat() (fs.FileInfo, error)
- func (ni Unhandled) Sys() any
Constants ¶
const ( DirType inoType = iota + 1 FileType SymlinkType BlockDevType CharDevType FifoType SocketType XDirType XFileType XSymlinkType XBlockDevType XCharDevType XFifoType XSocketType )
Variables ¶
var ( ErrInvalidFile = errors.New("invalid file, squashfs signature not found") ErrInvalidSuper = errors.New("invalid squashfs superblock") ErrInvalidVersion = errors.New("invalid file version, expected squashfs 4.0") ErrNotDirectory = errors.New("Not a directory") ErrTooManySymlinks = errors.New("Too many levels of symbolic links") )
Functions ¶
func RegisterDecompressor ¶
func RegisterDecompressor(method Compression, dcomp Decompressor)
RegisterDecompressor can be used to register a Decompressor for squashfs. GZip and ZSTD are supported by default. You can register additional decompressor types before opening squashfs archives that use them. Once registered, decompressors cannot be deregistered, only replaced.
Types ¶
type Compression ¶
type Compression uint16
Compression tracks what type of compression a squashfs is using. Out of the box, we support GZip and ZSTD using github.com/klauspost/compress. Additional types may be suported by default later, and you can always register your own.
const ( GZip Compression = iota + 1 LZMA LZO XZ LZ4 ZSTD )
func (Compression) String ¶
func (s Compression) String() string
type Decompressor ¶
Decompressor takes an input buffer and a destination buffer and returns the destination buffer filled with data and an error It matches the function signature of github.com/klauspost/compress/zstd Reader.DecodeAll. The library internals will eventually leverage it to optimize buffer reuse and caching.
func MakeDecompressor ¶
func MakeDecompressor(dec func(r io.Reader) io.ReadCloser) Decompressor
MakeDecompressor allows using a decompressor made for archive/zip with SquashFs. It has some overhead as instead of simply dealing with buffer this uses the reader/writer API, but should allow to easily handle some formats.
Example use: * squashfs.RegisterDecompressor(squashfs.ZSTD, squashfs.MakeDecompressor(zstd.ZipDecompressor())) * squashfs.RegisterDecompressor(squashfs.LZ4, squashfs.MakeDecompressor(lz4.NewReader)))
func MakeDecompressorErr ¶
func MakeDecompressorErr(dec func(r io.Reader) (io.ReadCloser, error)) Decompressor
MakeDecompressorErr is similar to MakeDecompressor but the factory method also returns an error.
Example use: * squashfs.RegisterDecompressor(squashfs.LZMA, squashfs.MakeDecompressorErr(lzma.NewReader)) * squashfs.RegisterDecompressor(squashfs.XZ, squashfs.MakeDecompressorErr(xz.NewReader))
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is an fs.File that supports fs.ReadDirFile
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS implements squashfs support.
func Open ¶
Open returns a new instance of FS for a given io.ReaderAt that can be used to access files inside squashfs.
func (*FS) Lstat ¶
Lstat will return stats for a given path inside the squashfs archive. If the target is a symbolic link, data on the link itself will be returned.
func (*FS) ReadDir ¶
ReadDir implements fs.ReadDirFS and allows listing any directory inside the archive
func (*FS) UnmarshalBinary ¶
UnmarshalBinary reads a binary header values into FS
type File ¶
type File struct { *io.SectionReader // contains filtered or unexported fields }
File is an fs.File + io.ReaderAt and friends.
type Unhandled ¶
type Unhandled struct {
// contains filtered or unexported fields
}
Unhandled is an fs.File for file types supported by squashfs that this library does not handle. Think devices, FIFOs, and the like.