squashfs

package
v0.0.0-...-ef90cfb Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package squashfs implements writing SquashFS file system images using zlib compression for data blocks (inodes and directory entries are written uncompressed for simplicity).

Note that SquashFS requires directory entries to be sorted, i.e. files and directories need to be added in the correct order.

This package intentionally only implements a subset of SquashFS. Notably, block devices, character devices, FIFOs, sockets and xattrs are not supported.

Index

Constants

View Source
const (
	XattrTypeUser = iota
	XattrTypeTrusted
	XattrTypeSecurity
)

xattr types

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

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

Directory represents a SquashFS directory.

func (*Directory) Directory

func (d *Directory) Directory(name string, modTime time.Time) *Directory

Directory creates a new directory with the specified name and modTime.

func (*Directory) File

func (d *Directory) File(name string, modTime time.Time, mode uint16, xattrs []Xattr) (io.WriteCloser, error)

File creates a file with the specified name, modTime and mode. The returned io.WriterCloser must be closed after writing the file.

func (*Directory) Flush

func (d *Directory) Flush() error

Flush writes directory entries and creates inodes for the directory.

func (d *Directory) Symlink(oldname, newname string, modTime time.Time, mode os.FileMode) error

Symlink creates a symbolic link from newname to oldname with the specified modTime and mode.

type FileInfo

type FileInfo struct {
	Inode Inode
	// contains filtered or unexported fields
}

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (fi *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (fi *FileInfo) Name() string

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

func (*FileInfo) Sys

func (fi *FileInfo) Sys() interface{}

type FileNotFoundError

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

func (*FileNotFoundError) Error

func (e *FileNotFoundError) Error() string

type Inode

type Inode int64

inode contains a block number + offset within that block.

type Reader

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

func NewReader

func NewReader(r io.ReaderAt) (*Reader, error)

func (*Reader) FileReader

func (r *Reader) FileReader(inode Inode) (*io.SectionReader, error)

func (*Reader) LlookupPath

func (r *Reader) LlookupPath(path string) (Inode, error)

LlookupPath is like LookupPath, but does not follow symbolic links, i.e. will instead return the inode of the link itself.

func (*Reader) LookupPath

func (r *Reader) LookupPath(path string) (Inode, error)
func (r *Reader) ReadLink(i Inode) (string, error)

func (*Reader) ReadXattrs

func (r *Reader) ReadXattrs(inode Inode) ([]Xattr, error)

func (*Reader) Readdir

func (r *Reader) Readdir(dirInode Inode) ([]os.FileInfo, error)

func (*Reader) ReaddirNoStat

func (r *Reader) ReaddirNoStat(dirInode Inode) ([]os.FileInfo, error)

Like Readdir, but does not call Stat on each file. The returned FileInfo structs will still have a filled in Name, partly filled in Mode, and filled in Inode.

func (*Reader) RootInode

func (r *Reader) RootInode() Inode

func (*Reader) Stat

func (r *Reader) Stat(name string, i Inode) (os.FileInfo, error)

type Writer

type Writer struct {
	// Root represents the file system root. Like all directories, Flush must be
	// called precisely once.
	Root *Directory
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.WriteSeeker, mkfsTime time.Time) (*Writer, error)

NewWriter returns a Writer which will write a SquashFS file system image to w once Flush is called.

Create new files and directories with the corresponding methods on the Root directory of the Writer.

File data is written to w even before Flush is called.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush writes the SquashFS file system. The Writer must not be used after calling Flush.

type Xattr

type Xattr struct {
	// Type is a prefix id for the key name. If the value that follows is stored
	// out-of-line, the flag 0x0100 is ORed to the type id.
	//
	// TODO: define a custom uint16 type
	Type uint16

	FullName string
	Value    []byte
}

func XattrFromAttr

func XattrFromAttr(attr string, val []byte) Xattr

Jump to

Keyboard shortcuts

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