squashfs

package module
v0.0.0-...-cc4dc6e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2024 License: ISC Imports: 15 Imported by: 0

README

squashfs

-- import "vimagination.zapto.org/squashfs"

Package squashfs is a SquashFS reader and writer using fs.FS

Usage

var (
	ErrInvalidCompressor            = errors.New("invalid or unknown compressor")
	ErrInvalidCompressionLevel      = errors.New("invalid compression level")
	ErrInvalidWindowSize            = errors.New("invalid window size")
	ErrInvalidCompressionStrategies = errors.New("invalid compression strategies")
	ErrNoCompressorOptions          = errors.New("no compressor options should be supplied")
	ErrInvalidCompressionAlgorithm  = errors.New("invalid compression algorithm")
	ErrInvalidDictionarySize        = errors.New("invalid dictionary size")
	ErrInvalidFilters               = errors.New("invalid filters")
	ErrInvalidCompressorVersion     = errors.New("invalid compressor version")
	ErrInvalidCompressorFlags       = errors.New("invalid compressor flags")
	ErrUnsupportedCompressor        = errors.New("unsupported compressor")

	ErrInvalidPointer     = errors.New("invalid pointer")
	ErrInvalidBlockHeader = errors.New("invalid block header")

	ErrInvalidMagicNumber = errors.New("invalid magic number")
	ErrInvalidBlockSize   = errors.New("invalid block size")
	ErrInvalidVersion     = errors.New("invalid version")
)
type Compressor
type Compressor uint16
const (
	CompressorGZIP Compressor = 1
	CompressorLZMA Compressor = 2
	CompressorLZO  Compressor = 3
	CompressorXZ   Compressor = 4
	CompressorLZ4  Compressor = 5
	CompressorZSTD Compressor = 6
)
func (Compressor) String
func (c Compressor) String() string
type CompressorOptions
type CompressorOptions interface {
	// contains filtered or unexported methods
}
type GZipOptions
type GZipOptions struct {
	CompressionLevel uint32
	WindowSize       uint16
	Strategies       uint16
}
func DefaultGzipOptions
func DefaultGzipOptions() *GZipOptions
type LZ4Options
type LZ4Options struct {
	Version uint32
	Flags   uint32
}
type LZMAOptions
type LZMAOptions struct{}
func DefaultLZMAOptions
func DefaultLZMAOptions() LZMAOptions
type LZOOptions
type LZOOptions struct {
	Algorithm        uint32
	CompressionLevel uint32
}
func DefaultLZOOptions
func DefaultLZOOptions() *LZOOptions
type SquashFS
type SquashFS struct {
}

The SquashFS type implements many of the FS interfaces, such as: fs.FS fs.ReadFileFS fs.ReadDirFS fs.StatFS

and has additional methods for dealing with symlinks.

func Open
func Open(r io.ReaderAt) (*SquashFS, error)

Open reads the passed io.ReaderAt as a SquashFS image, returning a fs.FS implementation.

The returned fs.FS, and any files opened from it will cease to work if the io.ReaderAt is closed.

func OpenWithCacheSize
func OpenWithCacheSize(r io.ReaderAt, cacheSize int) (*SquashFS, error)

OpenWithCacheSize acts like Open, but allows a custom cache size, which normally defaults to 16MB.

func (*SquashFS) LStat
func (s *SquashFS) LStat(path string) (fs.FileInfo, error)

Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link.

func (*SquashFS) Open
func (s *SquashFS) Open(path string) (fs.File, error)

Open opens the named file for reading.

func (*SquashFS) ReadDir
func (s *SquashFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir returns a sorted list of directory entries for the named directory.

func (*SquashFS) ReadFile
func (s *SquashFS) ReadFile(name string) ([]byte, error)

ReadFile return the byte contents of the named file.

func (s *SquashFS) Readlink(path string) (string, error)

Readlink returns the destination of the named symbolic link.

func (*SquashFS) Stat
func (s *SquashFS) Stat(path string) (fs.FileInfo, error)

Stat returns a FileInfo describing the name file.

type Stats
type Stats struct {
	Inodes     uint32
	ModTime    time.Time
	BlockSize  uint32
	FragCount  uint32
	Compressor Compressor
	Flags      uint16
	BytesUsed  uint64
}

Type Stats contains basic data about the SquashFS file, read from the superblock.

func ReadStats
func ReadStats(r io.Reader) (*Stats, error)

ReadStats reads the superblock from the passed reader and returns useful stats.

type XZOptions
type XZOptions struct {
	DictionarySize uint32
	Filters        uint32
}
func DefaultXZOptions
func DefaultXZOptions() *XZOptions
type ZStdOptions
type ZStdOptions struct {
	CompressionLevel uint32
}
func DefaultZStdOptions
func DefaultZStdOptions() *ZStdOptions

Documentation

Overview

Package squashfs is a SquashFS reader and writer using fs.FS

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCompressor            = errors.New("invalid or unknown compressor")
	ErrInvalidCompressionLevel      = errors.New("invalid compression level")
	ErrInvalidWindowSize            = errors.New("invalid window size")
	ErrInvalidCompressionStrategies = errors.New("invalid compression strategies")
	ErrNoCompressorOptions          = errors.New("no compressor options should be supplied")
	ErrInvalidCompressionAlgorithm  = errors.New("invalid compression algorithm")
	ErrInvalidDictionarySize        = errors.New("invalid dictionary size")
	ErrInvalidFilters               = errors.New("invalid filters")
	ErrInvalidCompressorVersion     = errors.New("invalid compressor version")
	ErrInvalidCompressorFlags       = errors.New("invalid compressor flags")
	ErrUnsupportedCompressor        = errors.New("unsupported compressor")

	ErrInvalidPointer     = errors.New("invalid pointer")
	ErrInvalidBlockHeader = errors.New("invalid block header")

	ErrInvalidMagicNumber = errors.New("invalid magic number")
	ErrInvalidBlockSize   = errors.New("invalid block size")
	ErrInvalidVersion     = errors.New("invalid version")
)
View Source
var (
	BlockSize4K   = BlockSize(minBlockSize)
	BlockSize16K  = BlockSize(1 << 14)
	BlockSize128K = BlockSize(defaultBlockSize)
	BlockSize1M   = BlockSize(maxBlockSize)
)

Functions

This section is empty.

Types

type BuildOption

type BuildOption func(*Builder) error

func BlockSize

func BlockSize(blockSize uint32) BuildOption

func Compression

func Compression(c CompressorOptions) BuildOption

func DefaultModTime

func DefaultModTime(t time.Time) BuildOption

func DefaultMode

func DefaultMode(m fs.FileMode) BuildOption

func DefaultOwner

func DefaultOwner(owner, group uint32) BuildOption

func ExportTable

func ExportTable() BuildOption

func SqfsModTime

func SqfsModTime(t uint32) BuildOption

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func Create

func Create(w io.WriterAt, options ...BuildOption) (*Builder, error)

func (*Builder) Block

func (b *Builder) Block(p string, deviceNumber uint32, options ...InodeOption) error

func (*Builder) Char

func (b *Builder) Char(p string, deviceNumber uint32, options ...InodeOption) error

func (*Builder) Close

func (b *Builder) Close() error

func (*Builder) Dir

func (b *Builder) Dir(p string, options ...InodeOption) error

func (*Builder) FIFO

func (b *Builder) FIFO(p string, options ...InodeOption) error

func (*Builder) File

func (b *Builder) File(p string, r io.Reader, options ...InodeOption) error

func (*Builder) Socket

func (b *Builder) Socket(p string, options ...InodeOption) error
func (b *Builder) Symlink(p, dest string, options ...InodeOption) error

type Compressor

type Compressor uint16
const (
	CompressorGZIP Compressor = 1
	CompressorLZMA Compressor = 2
	CompressorLZO  Compressor = 3
	CompressorXZ   Compressor = 4
	CompressorLZ4  Compressor = 5
	CompressorZSTD Compressor = 6
)

func (Compressor) String

func (c Compressor) String() string

type CompressorOptions

type CompressorOptions interface {
	// contains filtered or unexported methods
}

type GZipOptions

type GZipOptions struct {
	CompressionLevel uint32
	WindowSize       uint16
	Strategies       uint16
}

func DefaultGzipOptions

func DefaultGzipOptions() *GZipOptions

type InodeOption

type InodeOption func(*commonStat)

func ModTime

func ModTime(t time.Time) InodeOption

func Mode

func Mode(m fs.FileMode) InodeOption

func Owner

func Owner(owner, group uint32) InodeOption

type LZ4Options

type LZ4Options struct {
	Version uint32
	Flags   uint32
}

type LZMAOptions

type LZMAOptions struct{}

func DefaultLZMAOptions

func DefaultLZMAOptions() LZMAOptions

type LZOOptions

type LZOOptions struct {
	Algorithm        uint32
	CompressionLevel uint32
}

func DefaultLZOOptions

func DefaultLZOOptions() *LZOOptions

type SquashFS

type SquashFS struct {
	// contains filtered or unexported fields
}

The SquashFS type implements many of the FS interfaces, such as: fs.FS fs.ReadFileFS fs.ReadDirFS fs.StatFS

and has additional methods for dealing with symlinks.

func Open

func Open(r io.ReaderAt) (*SquashFS, error)

Open reads the passed io.ReaderAt as a SquashFS image, returning a fs.FS implementation.

The returned fs.FS, and any files opened from it will cease to work if the io.ReaderAt is closed.

func OpenWithCacheSize

func OpenWithCacheSize(r io.ReaderAt, cacheSize int) (*SquashFS, error)

OpenWithCacheSize acts like Open, but allows a custom cache size, which normally defaults to 16MB.

func (*SquashFS) LStat

func (s *SquashFS) LStat(path string) (fs.FileInfo, error)

Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link.

func (*SquashFS) Open

func (s *SquashFS) Open(path string) (fs.File, error)

Open opens the named file for reading.

func (*SquashFS) ReadDir

func (s *SquashFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir returns a sorted list of directory entries for the named directory.

func (*SquashFS) ReadFile

func (s *SquashFS) ReadFile(name string) ([]byte, error)

ReadFile return the byte contents of the named file.

func (s *SquashFS) ReadLink(name string) (string, error)
func (s *SquashFS) Readlink(path string) (string, error)

Readlink returns the destination of the named symbolic link.

func (*SquashFS) Stat

func (s *SquashFS) Stat(path string) (fs.FileInfo, error)

Stat returns a FileInfo describing the name file.

type Stats

type Stats struct {
	Inodes     uint32
	ModTime    time.Time
	BlockSize  uint32
	FragCount  uint32
	Compressor Compressor
	Flags      uint16
	BytesUsed  uint64
}

Type Stats contains basic data about the SquashFS file, read from the superblock.

func ReadStats

func ReadStats(r io.Reader) (*Stats, error)

ReadStats reads the superblock from the passed reader and returns useful stats.

type XZOptions

type XZOptions struct {
	DictionarySize uint32
	Filters        uint32
}

func DefaultXZOptions

func DefaultXZOptions() *XZOptions

type ZStdOptions

type ZStdOptions struct {
	CompressionLevel uint32
}

func DefaultZStdOptions

func DefaultZStdOptions() *ZStdOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL