Documentation ¶
Overview ¶
Package initramfs provides a simple library for creating Linux initramfs archives.
A simple program creating an initramfs archive and writing it to stdout can be found in "cmd/mkinitramfs".
Only regular files are copied from the local file system. Mode is always set to 0755. For all added ELF file, the linked libraries can be resolved and added to the archive by calling Archive.ResolveLinkedLibs.
Index ¶
Constants ¶
const ( // LibsDir is the archive's directory for all dynamically linked libraries. LibsDir = "lib" // AdditionalFilesDir is the archive's directory for all additional files // beside the init file. FilesDir = "files" // LibSearchPath defines the directories to lookup linked libraries. LibSearchPath = "/lib:/lib64:/usr/lib:/usr/lib64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive represents a file tree that can be used as an initramfs for the Linux kernel.
Create a new instance using New. Additional files can be added with Archive.AddFiles. Dynamically linked ELF libraries can be resolved and added for all already added files by calling Archive.ResolveLinkedLibs. Once ready, write the Archive with Archive.WriteCPIO.
func New ¶
New creates a new Archive with the given file added as "/init". The file path must be absolute or relative to "/".
func (*Archive) AddFile ¶
AddFile creates FilesDir and adds the given file to it. If name is empty the base name of the file is used. The file path must be absolute or relative to "/".
func (*Archive) AddFiles ¶
AddFiles creates FilesDir and adds the given files to it. The file paths must be absolute or relative to "/".
func (*Archive) ResolveLinkedLibs ¶
ResolveLinkedLibs recursively resolves the dynamically linked libraries of all regular files in the Archive.
If the given searchPath string is empty the default LibSearchPath is used. Resolved libraries are added to LibsDir. For each search path a symoblic link is added pointiong to LibsDir.