Documentation ¶
Overview ¶
Package squashfs provides support for reading and creating squashfs filesystems references:
https://www.kernel.org/doc/Documentation/filesystems/squashfs.txt https://dr-emann.github.io/squashfs/ https://elinux.org/images/3/32/Squashfs-elce.pdf
Index ¶
- Constants
- type Compressor
- type CompressorGzip
- type CompressorLz4
- type CompressorLzma
- type CompressorXz
- type CompressorZstd
- type File
- type FileStat
- type FileSystem
- func (fs *FileSystem) Equal(a *FileSystem) bool
- func (fs *FileSystem) Finalize(options FinalizeOptions) error
- func (fs *FileSystem) Label() string
- func (fs *FileSystem) Mkdir(p string) error
- func (fs *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
- func (fs *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
- func (fs *FileSystem) Type() filesystem.Type
- func (fs *FileSystem) Workspace() string
- type FinalizeOptions
- type GzipStrategy
- type XzFilter
Constants ¶
const ( GzipDefault GzipStrategy = 0x1 GzipFiltered = 0x2 GzipHuffman = 0x4 GzipRunLengthEncoded = 0x8 GzipFixed = 0x10 )
gzip strategy options
const ( XzFilterX86 XzFilter = 0x1 XzFilterPowerPC = 0x2 XzFilterIA64 = 0x4 XzFilterArm = 0x8 XzFilterArmThumb = 0x10 XzFilterSparc = 0x20 )
xz filter options
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor interface {
// contains filtered or unexported methods
}
Compressor defines a compressor. Fulfilled by various implementations in this package
type CompressorGzip ¶
type CompressorGzip struct { CompressionLevel uint32 WindowSize uint16 Strategies map[GzipStrategy]bool }
CompressorGzip gzip compression
type CompressorLz4 ¶
type CompressorLz4 struct {
// contains filtered or unexported fields
}
CompressorLz4 lz4 compression
type CompressorXz ¶
CompressorXz xz compression
type CompressorZstd ¶
type CompressorZstd struct {
// contains filtered or unexported fields
}
CompressorZstd zstd compression
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a single file in a squashfs filesystem
it is NOT used when working in a workspace, where we just use the underlying OS note that the inode for a file can be the basicFile or extendedFile. We just use extendedFile to include all of the data
func (*File) Read ¶
Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF reads from the last known offset in the file from last read or write use Seek() to set at a particular point
type FileStat ¶
type FileStat struct {
// contains filtered or unexported fields
}
FileStat is the extended data underlying a single file, similar to https://golang.org/pkg/syscall/#Stat_t
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem implements the FileSystem interface
func Create ¶
Create creates a squashfs filesystem in a given directory
requires the util.File where to create the filesystem, size is the size of the filesystem in bytes, start is how far in bytes from the beginning of the util.File to create the filesystem, and blocksize is is the logical blocksize to use for creating the filesystem
note that you are *not* required to create the filesystem on the entire disk. You could have a disk of size 20GB, and create a small filesystem of size 50MB that begins 2GB into the disk. This is extremely useful for creating filesystems on disk partitions.
Note, however, that it is much easier to do this using the higher-level APIs at github.com/cusspvz/go-diskfs which allow you to work directly with partitions, rather than having to calculate (and hopefully not make any errors) where a partition starts and ends.
If the provided blocksize is 0, it will use the default of 128 KB.
func Read ¶
Read reads a filesystem from a given disk.
requires the util.File where to read the filesystem, size is the size of the filesystem in bytes, start is how far in bytes from the beginning of the util.File the filesystem is expected to begin, and blocksize is is the logical blocksize to use for creating the filesystem
note that you are *not* required to read a filesystem on the entire disk. You could have a disk of size 20GB, and a small filesystem of size 50MB that begins 2GB into the disk. This is extremely useful for working with filesystems on disk partitions.
Note, however, that it is much easier to do this using the higher-level APIs at github.com/cusspvz/go-diskfs which allow you to work directly with partitions, rather than having to calculate (and hopefully not make any errors) where a partition starts and ends.
If the provided blocksize is 0, it will use the default of 2K bytes
func (*FileSystem) Equal ¶
func (fs *FileSystem) Equal(a *FileSystem) bool
Equal compare if two filesystems are equal
func (*FileSystem) Finalize ¶
func (fs *FileSystem) Finalize(options FinalizeOptions) error
Finalize finalize a read-only filesystem by writing it out to a read-only format
func (*FileSystem) Mkdir ¶
func (fs *FileSystem) Mkdir(p string) error
Mkdir make a directory at the given path. It is equivalent to `mkdir -p`, i.e. idempotent, in that:
* It will make the entire tree path if it does not exist * It will not return an error if the path already exists
if readonly and not in workspace, will return an error
func (*FileSystem) OpenFile ¶
func (fs *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
OpenFile returns an io.ReadWriter from which you can read the contents of a file or write contents to the file
accepts normal os.OpenFile flags
returns an error if the file does not exist
func (*FileSystem) ReadDir ¶
func (fs *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
ReadDir return the contents of a given directory in a given filesystem.
Returns a slice of os.FileInfo with all of the entries in the directory.
Will return an error if the directory does not exist or is a regular file and not a directory
func (*FileSystem) Type ¶
func (fs *FileSystem) Type() filesystem.Type
Type returns the type code for the filesystem. Always returns filesystem.TypeFat32
func (*FileSystem) Workspace ¶
func (fs *FileSystem) Workspace() string
Workspace get the workspace path
type FinalizeOptions ¶
type FinalizeOptions struct { // Compressor which compressor to use, including, where relevant, options. Defaults ot CompressorGzip Compression Compressor // NonExportable prevent making filesystem NFS exportable. Defaults to false, i.e. make it exportable NonExportable bool // NonSparse prevent detecting sparse files. Defaults to false, i.e. detect sparse files NonSparse bool // Xattrs whether or not to store extended attributes. Defaults to false Xattrs bool // NoCompressInodes whether or not to compress inodes. Defaults to false, i.e. compress inodes NoCompressInodes bool // NoCompressData whether or not to compress data blocks. Defaults to false, i.e. compress data NoCompressData bool // NoCompressFragments whether or not to compress fragments. Defaults to false, i.e. compress fragments NoCompressFragments bool // NoCompressXattrs whether or not to compress extended attrbutes. Defaults to false, i.e. compress xattrs NoCompressXattrs bool // NoFragments do not use fragments, but rather dedicated data blocks for all files. Defaults to false, i.e. use fragments NoFragments bool // NoPad do not pad filesystem so it is a multiple of 4K. Defaults to false, i.e. pad it NoPad bool // FileUID set all files to be owned by the UID provided, default is to leave as in filesystem FileUID *uint32 // FileGID set all files to be owned by the GID provided, default is to leave as in filesystem FileGID *uint32 }
FinalizeOptions options to pass to finalize
type GzipStrategy ¶
type GzipStrategy uint16