squashfs

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 9 Imported by: 4

README

GoSquashfs

PkgGoDev

A PURE Go library to read and write squashfs.

Currently, you can read a squashfs and extract files (only files at the moment). Many things are public that shouldn't be, but you can use it by using NewSquashfsReader and subsequent ReadFile.

Special thanks to https://dr-emann.github.io/squashfs/ for some VERY important information in an easy to understand format. Thanks also to distri's squashfs library as I referenced it to figure some things out (and double check others).

Working

  • Extracting files from string paths
  • Reading the header
  • Reading metadata blocks (whether encrypted or not)
  • Reading inodes
  • Reading directories
  • Basic gzip compression (Shouldn't be too hard to implement other, but for right now, this works)
  • Listing all files via a string slice

Not Working (Yet). Not necessarily in order.

  • Rename repo so it's easier to import
  • Provide an easy interface to find and list files and their properties
    • Maybe squashfs.File
  • Extracting files
    • from inodes.
    • from file info.
  • Give a list of files
    • In io.FileStat (?) form
  • Reading the UID, GUID, Xatt, Compression Options, and Export tables.
  • Implement other compression types (Should be relatively easy)
  • Squashing
  • Threading processes to speed them up
  • Reasonable tests

TODO

  • Go over all documentation again (especially for exported structs and functions) to make sure it's easy to understand.

Where I'm at

  • v0.1 is the first working version!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrInodeNotFile is given when giving an inode, but the function requires a file inode.
	ErrInodeNotFile = errors.New("Given inode is NOT a file type")
	//ErrInodeOnlyFragment is given when trying to make a DataReader from an inode, but the inode only had data in a fragment
	ErrInodeOnlyFragment = errors.New("Given inode ONLY has fragment data")
)
View Source
var (
	//ErrNoMagic is returned if the magic number in the superblock isn't correct.
	ErrNoMagic = errors.New("Magic number doesn't match. Either isn't a squashfs or corrupted")
	//ErrIncompatibleCompression is returned if the compression type in the superblock doesn't work.
	ErrIncompatibleCompression = errors.New("Compression type unsupported")
	//ErrCompressorOptions is returned if compressor options is present. It's not currently supported.
	ErrCompressorOptions = errors.New("Compressor options is not currently supported")
	//ErrFragmentTableIssues is returned if there's trouble reading the fragment table when creating a reader.
	//When this is returned, the reader is still returned.
	ErrFragmentTableIssues = errors.New("Trouble while reading the fragment table")
)
View Source
var (
	//ErrNotFound means that the given path is NOT present in the archive
	ErrNotFound = errors.New("Path not found")
)
View Source
var (
	//ErrPathIsNotFile returns when trying to read from a file, but the given path is NOT a file.
	ErrPathIsNotFile = errors.New("The given path is not a file")
)

Functions

This section is empty.

Types

type FileReader

type FileReader struct {
	FileSize int //FileSize is the total size of the given file
	// contains filtered or unexported fields
}

FileReader provides a io.Reader interface for files within a squashfs archive

func (*FileReader) Read

func (f *FileReader) Read(p []byte) (int, error)

type Reader

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

Reader processes and reads a squashfs archive. TODO: Give a way to actually read files :P

func NewSquashfsReader

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

NewSquashfsReader returns a new squashfs.Reader from an io.ReaderAt

func (*Reader) GetFilesList

func (r *Reader) GetFilesList() ([]string, error)

GetFilesList returns a list of ALL files in the squashfs, going down every folder. Folders end in /

func (*Reader) ReadFile

func (r *Reader) ReadFile(location string) (*FileReader, error)

ReadFile provides a squashfs.FileReader for the file at the given location.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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