Documentation ¶
Overview ¶
Package initramfs can write archives out to CPIO or directories.
Index ¶
- Variables
- func Write(opts *Opts) error
- type Archive
- type CPIOFile
- type Dir
- type Files
- func (af *Files) AddFile(src string, dest string) error
- func (af *Files) AddFileNoFollow(src string, dest string) error
- func (af *Files) AddRecord(r cpio.Record) error
- func (af *Files) Contains(dest string) bool
- func (af *Files) Rename(name string, newname string)
- func (af *Files) WriteTo(w Writer) error
- type Opts
- type ReadOpener
- type WriteOpener
- type Writer
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoPath = errors.New("invalid argument: must specify path")
)
Possible errors.
Functions ¶
Types ¶
type Archive ¶
Archive opens a Reader that reads files from an in-memory archive.
func (*Archive) OpenReader ¶
func (a *Archive) OpenReader() (cpio.RecordReader, error)
OpenReader opens the archive for reading.
func (*Archive) OpenWriter ¶
OpenWriter writes to the archive.
type CPIOFile ¶
type CPIOFile struct {
Path string
}
CPIOFile opens a Reader or Writer that reads/writes files from/to a CPIO archive at the given path.
func (*CPIOFile) OpenReader ¶
func (c *CPIOFile) OpenReader() (cpio.RecordReader, error)
OpenReader opens c.Path for reading.
func (*CPIOFile) OpenWriter ¶
OpenWriter opens c.Path for writing.
type Dir ¶
type Dir struct {
Path string
}
Dir opens a Writer that writes all archive files to the given directory.
func (*Dir) OpenWriter ¶
OpenWriter implements Archiver.OpenWriter.
type Files ¶
type Files struct { // Files is a map of relative archive path -> absolute host file path. Files map[string]string // Records is a map of relative archive path -> Record to use. // // TODO: While the only archive mode is cpio, this will be a // cpio.Record. If or when there is another archival mode, we can add a // similar uroot.Record type. Records map[string]cpio.Record }
Files are host files and records to add to the resulting initramfs.
func (*Files) AddFile ¶
AddFile adds a host file at src into the archive at dest. It follows symlinks.
If src is a directory, it and its children will be added to the archive relative to dest.
Duplicate files with identical content will be silently ignored.
func (*Files) AddFileNoFollow ¶
AddFileNoFollow adds a host file at src into the archive at dest. It does not follow symlinks.
If src is a directory, it and its children will be added to the archive relative to dest.
Duplicate files with identical content will be silently ignored.
type Opts ¶
type Opts struct { // Files are the files to be included. // // Files here generally have priority over files in DefaultRecords or // BaseArchive. *Files // OutputFile is the file to write to. OutputFile WriteOpener // BaseArchive is an existing archive to add files to. // // BaseArchive may be nil. BaseArchive ReadOpener // UseExistingInit determines whether the init from BaseArchive is used // or not, if BaseArchive is specified. // // If this is false, the "init" file in BaseArchive will be renamed // "inito" (for init-original) in the output archive. UseExistingInit bool }
Opts are options for building an initramfs archive.
type ReadOpener ¶
type ReadOpener interface {
OpenReader() (cpio.RecordReader, error)
}
ReadOpener opens a cpio.RecordReader.
type WriteOpener ¶
WriteOpener opens a Writer.
type Writer ¶
type Writer interface { cpio.RecordWriter // Finish finishes the archive. Finish() error }
Writer is an initramfs archive that files can be written to.