cpio

package
v0.0.0-...-7eb602e Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Trailer = "TRAILER!!!"

Variables

View Source
var (
	Debug = func(string, ...interface{}) {}
)
View Source
var TrailerRecord = StaticRecord(nil, Info{Name: Trailer})

Functions

func AddFormat

func AddFormat(name string, f RecordFormat)

func CreateFile

func CreateFile(f Record) error

func MakeAllReproducible

func MakeAllReproducible(files []Record)

func NewBytesReadCloser

func NewBytesReadCloser(contents []byte) io.ReadCloser

func NewDeferReadCloser

func NewDeferReadCloser(name string) io.ReadCloser

func NewReadCloser

func NewReadCloser(r io.Reader) io.ReadCloser

Types

type Archiver

type Archiver struct {
	RecordFormat
}

func Format

func Format(name string) (Archiver, error)

func (Archiver) Reader

func (a Archiver) Reader(r io.ReaderAt) Reader

func (Archiver) Writer

func (a Archiver) Writer(w io.Writer) Writer

type Info

type Info struct {
	Ino      uint64
	Mode     uint64
	UID      uint64
	GID      uint64
	NLink    uint64
	MTime    uint64
	FileSize uint64
	Dev      uint64
	Major    uint64
	Minor    uint64
	Rmajor   uint64
	Rminor   uint64
	Name     string
}

Info holds metadata about files.

func (Info) String

func (i Info) String() string

type LazyOpen

type LazyOpen struct {
	Name string
	File *os.File
}

func (*LazyOpen) Close

func (r *LazyOpen) Close() error

func (*LazyOpen) Read

func (r *LazyOpen) Read(p []byte) (int, error)

type Reader

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

func (Reader) ReadRecord

func (r Reader) ReadRecord() (Record, error)

func (Reader) ReadRecords

func (r Reader) ReadRecords() ([]Record, error)

type Record

type Record struct {
	io.ReadCloser
	Info
}

func GetRecord

func GetRecord(path string) (Record, error)

func MakeReproducible

func MakeReproducible(file Record) Record

MakeReproducible changes any fields in a Record such that if we run cpio again, with the same files presented to it in the same order, and those files have unchanged contents, the cpio file it produces will be bit-for-bit identical. This is an essential property for firmware-embedded payloads.

func StaticRecord

func StaticRecord(contents []byte, info Info) Record
func Symlink(path string, target string) Record

Symlink returns a symlink record at path pointing to target.

type RecordFormat

type RecordFormat interface {
	Reader(r io.ReaderAt) RecordReader
	Writer(w io.Writer) RecordWriter
}

type RecordReader

type RecordReader interface {
	ReadRecord() (Record, error)
}

type RecordWriter

type RecordWriter interface {
	WriteRecord(Record) error
}

type Writer

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

func (Writer) Concat

func (w Writer) Concat(r Reader, transform func(Record) Record) error

Concat reads files from r one at a time, and writes them to w.

func (Writer) WriteRecord

func (w Writer) WriteRecord(rec Record) error

func (Writer) WriteRecords

func (w Writer) WriteRecords(files []Record) error

WriteRecords writes multiple records.

func (Writer) WriteTrailer

func (w Writer) WriteTrailer() error

WriteTrailer writes the trailer record.

Directories

Path Synopsis
newc implements the new ASCII cpio file format.
newc implements the new ASCII cpio file format.

Jump to

Keyboard shortcuts

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