initramfs

package
v0.6.15 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package initramfs builds deterministic SVR4 newc cpio archives (Linux initramfs images) from a directory tree or a tar/tar.gz rootfs.

The archive is byte-for-byte deterministic: entries are written in the order given, with a zero mtime and nlink 1, so the same input always yields the same image. PackTree walks a directory; PackTar streams a (possibly gzipped) tar; both accept extra in-memory Entry values (config files, injected guest binaries) that are appended before the archive trailer.

The package is format-only and has no notion of any particular guest's layout: callers decide what extra entries to inject and under what names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanName

func CleanName(name string) (string, error)

CleanName returns a cpio-safe relative entry name, rejecting empty names and names containing a NUL byte.

func Pack

func Pack(w io.Writer, entries []Entry) error

Pack writes entries as a deterministic SVR4 newc cpio archive, in order, followed by the trailer.

func PackTar

func PackTar(w io.Writer, r io.Reader, extras ...Entry) error

PackTar writes a (possibly gzipped) tar rootfs from r as a newc initramfs, then appends extras before the trailer. Regular files are streamed rather than buffered.

func PackTree

func PackTree(w io.Writer, root string, extras ...Entry) error

PackTree writes the directory tree at root as a newc initramfs, then appends extras (e.g. config files or injected binaries) before the trailer.

func TarReader

func TarReader(r *bufio.Reader) (*tar.Reader, error)

TarReader returns a tar reader over r, transparently decompressing gzip input.

Types

type Entry

type Entry struct {
	Name      string
	Mode      uint32
	UID       uint32
	GID       uint32
	RDevMajor uint32
	RDevMinor uint32
	Data      []byte
}

Entry is one filesystem entry in a newc initramfs archive. Mode is a full st_mode (type bits OR permission bits); for device nodes set RDevMajor and RDevMinor. Data holds a regular file's contents or a symlink's target.

Jump to

Keyboard shortcuts

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