daemon

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package daemon is the splash process: it serves plymouthd's protocol, draws the theme on every output or as text on the VT, answers prompts from the keyboard and follows the protocol's lifecycle from boot to quit.

Index

Constants

View Source
const BootDurationFile = "/var/lib/lys-splash/boot-duration"

BootDurationFile is where a boot records how long its splash showed, for the next boot's progress.

View Source
const FrameInterval = time.Second / 30

FrameInterval is how long one of the throbber's phases lasts.

View Source
const InitrdRelease = "/etc/initrd-release"

InitrdRelease is the file whose presence marks the initrd.

View Source
const NotifyEnv = "NOTIFY_SOCKET"

NotifyEnv names the socket systemd's Type=notify services report on.

View Source
const RootStorageMarker = '@'

RootStorageMarker is the first byte of argv[0] that makes systemd spare a process when it switches out of the initrd.

Variables

This section is empty.

Functions

func InInitrd

func InInitrd() (bool, error)

InInitrd reports whether this process runs in the initrd.

func LoadBootDuration

func LoadBootDuration(path string) (time.Duration, error)

LoadBootDuration reads the duration a previous boot recorded at path: a positive number of seconds. A missing file is an error wrapping fs.ErrNotExist.

func NeedsReexec

func NeedsReexec(mode Mode, argv0 string, initrd, closeBeforeRemoval bool) bool

NeedsReexec reports whether the splash, about to run in mode with argv0, must first re-execute itself with RootStorageMarker leading argv[0], once. In boot mode inside the initrd the marker lets it survive the switch to the real root. In the shutdown, reboot and kexec modes it keeps systemd-shutdown from killing it, so its card stays open until the power goes: the kernel puts fbdev's console back on the screen when the last file on a card closes, CLOSEFB or not. With closeBeforeRemoval it goes unmarked in those modes, so systemd-shutdown ends it while the driver can still take the close.

func Notify

func Notify(addr, state string) error

Notify sends state, such as "READY=1", to the notify socket at addr, as sd_notify does; "@" leads an abstract address. With addr empty there is no supervisor listening and Notify does nothing.

func Run

func Run(ctx context.Context, cfg Config, t theme.Theme, bgrt *splashframe.BGRT, dev Devices) (err error)

Run serves the splash until a quit request or ctx ends. ctx ending is a SIGTERM: it quits as a quit request without retain would, except in the shutdown, reboot and kexec modes, where the frame stays until the power goes. In those modes a quit retaining the splash, which systemd-shutdown's last step sends to a splash it spared, fades the group out and keeps the splash running with the frame on screen. Whatever ends Run, a panic in a handler included, gives the VT back and releases the display and the console.

func SaveBootDuration

func SaveBootDuration(path string, d time.Duration) error

SaveBootDuration records d at path, replacing the file whole so a crash leaves either the previous duration or this one, and creating its directory.

func SwitchRoot

func SwitchRoot(dir string) error

SwitchRoot chroots into dir and changes to its root directory, so that after the switch out of the initrd the splash's paths resolve in the real root rather than the freed initramfs.

Types

type Clock

type Clock interface {
	Now() time.Time
	// NewTimer is a stopped timer.
	NewTimer() Timer
}

Clock is where the daemon reads the time and arms its one timer.

type Config

type Config struct {
	Mode Mode
	// ThemePath is the theme.yaml that Reload reads again.
	ThemePath string
	// Server is where the protocol is served, listening already; Run
	// serves it and closes it.
	Server *server.Server
	// Notify is the systemd notify socket, empty without a supervisor.
	Notify string
	// Chroot switches into the new root, as `R` asks.
	Chroot func(dir string) error
	// BootDuration is the file a boot reads the previous boot's duration
	// from, for its progress, and records its own in if it came through the
	// switch to a real root that became writable: BootDurationFile.
	BootDuration     string
	LoadBootDuration func(path string) (time.Duration, error)
	SaveBootDuration func(path string, d time.Duration) error
	// LoadTheme reads the theme Reload shows.
	LoadTheme func(path string) (theme.Theme, error)
	// RasterizeLogo draws the logo for a scale in a colour off the loop.
	SaveLastFrame             func(splashframe.LastFrame) error
	ForgetLastFrame           func() error
	UnbindFramebufferConsoles func() ([]string, error)
	LoadKeymap                func() (string, error)
	Clock                     Clock
	Log                       *slog.Logger
	// contains filtered or unexported fields
}

Config is how the daemon runs.

type Console

type Console interface {
	Read(b []byte) (int, error)
	// Restore gives the console back and writes lines to it.
	Restore(lines []string) error
	// Leave gives the console back without writing to it.
	Leave() error
}

Console is the console's output, captured while the splash shows so the kernel console does not draw over it, and shown as the boot messages.

type Devices

type Devices struct {
	Display Display
	VT      Terminal
	Console Console
}

Devices are what the splash shows on and reads from. VT is nil on a kernel without VTs, and Console nil when the console's output could not be captured.

type Display

type Display interface {
	Events() <-chan kms.Event
	// Handle applies e and says whether the set of screens changed.
	Handle(e kms.Event) (bool, error)
	Screens() []Screen
	Deactivate() error
	Reactivate() error
	Close(retain bool) error
}

Display is every graphical output; with no Screens the splash is text on the VT.

type KMS

type KMS struct {
	*kms.Display
	// contains filtered or unexported fields
}

KMS adapts a kms.Display to Display.

func (*KMS) Screens

func (k *KMS) Screens() []Screen

Screens are the display's lit outputs; the list is built again only when they change, and a change gives a new list rather than altering this one.

type Mode

type Mode uint8

Mode is what the splash is shown for.

const (
	Boot Mode = iota
	Shutdown
	Reboot
	Kexec
	Updates
)

The modes plymouthd's --mode takes.

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode reads a --mode value.

func (Mode) Stopping

func (m Mode) Stopping() bool

Stopping reports whether the machine goes down in m, so the splash stays until the power goes rather than waiting for a quit.

func (Mode) String

func (m Mode) String() string

type Screen

type Screen interface {
	Name() string
	Frame() kms.Frame
	Scale() int
	Present(damage kms.Damage) error
}

Screen is one output the splash draws on.

type SystemClock

type SystemClock struct{}

SystemClock is the wall clock.

func (SystemClock) NewTimer

func (SystemClock) NewTimer() Timer

NewTimer is a stopped time.Timer.

func (SystemClock) Now

func (SystemClock) Now() time.Time

Now is the current time.

type Terminal

type Terminal interface {
	Graphics() error
	Text() error
	Rows() (int, error)
	Reclaim() error
	CapsLock() (bool, error)
	Read(b []byte) (int, error)
	Write(b []byte) (int, error)
	Restore() error
	Leave() error
}

Terminal is the VT the splash took over.

type Timer

type Timer interface {
	C() <-chan time.Time
	Reset(d time.Duration)
	Stop()
}

Timer fires once per Reset; a Reset or Stop leaves no stale firing behind.

Jump to

Keyboard shortcuts

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