Documentation
¶
Overview ¶
ginit is a high(er) level library for Linux. It is intended for consumption by mesanine and also Linuxkit. This library will be majorly refactored several times before becoming stable.
Index ¶
- func Call(args ScriptArgs) error
- func CopyFileInfo(info os.FileInfo, path string) error
- func Exec(exe string, args ...string) error
- func Hostname(prefix string) (string, error)
- func Init(children ...Handler) error
- func IsMemFS(path string) (bool, error)
- func IsRoot() bool
- func Mount(args MountArgs, opts ...MountOption) error
- func MustMount(args MountArgs, opts ...MountOption)
- func SwitchRoot(opts SwitchOptions) error
- func Unmount(path string) error
- type Controller
- type Handler
- type KeyFS
- type MountArgs
- type MountOption
- type ScriptArgs
- type SwitchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
func Call(args ScriptArgs) error
Call executes the script parameters copying the existing environment into the command. Call blocks until the command is finished and stdout/stderr have been synchronized with OnStdout/OnSterr functions.
func CopyFileInfo ¶
CopyFileInfo takes an os.FileInfo and applies it to a file at the given path.
func Exec ¶
Exec does an execve with provided arguments it appends the executable to the front of the arguments and copies the existing environment.
func Hostname ¶
Hostname generates a hostname based on the prefix and the first valid MAC address from sysfs.
func Init ¶
Init launches an "origin" signal handler propagating any signal it receives to it's children. If any child returns an error it will be passed back to the caller. Assuming the calling program is running as PID 1, the caller can print an informative message and then exit causing a kernel panic. If we receive SIGUSR1, SIGUSR2, or SIGTERM we trigger a halt, poweroff, or restart command with a syscall to the kernel. Resources: https://github.com/mirror/busybox/tree/master/init https://github.com/torvalds/linux/blob/master/kernel/reboot.c
func Mount ¶
func Mount(args MountArgs, opts ...MountOption) error
Mount performs the unix.Mount syscall
func MustMount ¶
func MustMount(args MountArgs, opts ...MountOption)
MustMount performs a unix.Mount syscall and panics on failure.
func SwitchRoot ¶
func SwitchRoot(opts SwitchOptions) error
Most of this code comes from Linuxkit's init package: https://github.com/linuxkit/linuxkit/blob/master/pkg/init/cmd/init/init.go
Types ¶
type Controller ¶
Controller represents a cgroup system controller see http://man7.org/linux/man-pages/man7/cgroups.7.html
func ReadControllers ¶
func ReadControllers() ([]Controller, error)
ReadControllers returns Cgroup controllers listed at /proc/cgroups Modified from https://github.com/opencontainers/runc/blob/master/libcontainer/cgroups/utils.go
type KeyFS ¶
type KeyFS struct {
Base string
}
KeyFS implements a simple structure for interacting with "key" based filesystems like procfs and sysfs.
type MountArgs ¶
type MountArgs struct { Source string Target string FSType string Flags uintptr // mount -o options // TODO: Make strongly typed. Data string Before func() error }
MountArgs hold arguments for making unix.Mount syscalls.
type MountOption ¶
Option is a functional option to modify MountArgs.
func Mkdir ¶
func Mkdir(mode os.FileMode) MountOption
Mkdir creates the target directory if it is missing before performing a mount operation.
type ScriptArgs ¶
type SwitchOptions ¶
func NewSwitchOptions ¶
func NewSwitchOptions(path string) (*SwitchOptions, error)