Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( CPIO = CPIOArchiver{ RecordFormat: cpio.Newc, } Dir = DirArchiver{} // Archivers are the supported initramfs archivers at the moment. // // - cpio: writes the initramfs to a cpio. // - dir: writes the initramfs relative to a specified directory. Archivers = map[string]Archiver{ "cpio": CPIO, "dir": Dir, } )
Functions ¶
Types ¶
type Archiver ¶
type Archiver interface {
// OpenWriter opens an archive writer at `path`.
//
// If `path` is unspecified, implementations may choose an arbitrary
// default location, potentially based on `goos` and `goarch`.
OpenWriter(path, goos, goarch string) (Writer, error)
// Reader returns a Reader that allows reading files from a file.
Reader(file io.ReaderAt) Reader
}
Archiver is an archive format that builds an archive using a given set of files.
func GetArchiver ¶
GetArchiver finds a registered initramfs archiver by name.
Good to use with command-line arguments.
type CPIOArchiver ¶
type CPIOArchiver struct {
cpio.RecordFormat
}
CPIOArchiver is an implementation of Archiver for the cpio format.
func (CPIOArchiver) OpenWriter ¶
func (ca CPIOArchiver) OpenWriter(path, goos, goarch string) (Writer, error)
OpenWriter opens `path` as the correct file type and returns an Writer pointing to `path`.
If `path` is empty, a default path of /tmp/initramfs.GOOS_GOARCH.cpio is used.
type DirArchiver ¶
type DirArchiver struct{}
DirArchiver implements Archiver for a directory.
func (DirArchiver) OpenWriter ¶
func (da DirArchiver) OpenWriter(path, goos, goarch string) (Writer, error)
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.
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 Writer
// BaseArchive is an existing archive to add files to.
//
// BaseArchive may be nil.
BaseArchive Reader
// 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 Writer ¶
type Writer interface {
cpio.RecordWriter
// Finish finishes the archive.
Finish() error
}
Writer is an initramfs archive that files can be written to.