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
- func InInitrd() (bool, error)
- func LoadBootDuration(path string) (time.Duration, error)
- func NeedsReexec(mode Mode, argv0 string, initrd, closeBeforeRemoval bool) bool
- func Notify(addr, state string) error
- func Run(ctx context.Context, cfg Config, t theme.Theme, bgrt *theme.BGRT, dev Devices) (err error)
- func SaveBootDuration(path string, d time.Duration) error
- func SwitchRoot(dir string) error
- type Clock
- type Config
- type Console
- type Devices
- type Display
- type KMS
- type Mode
- type Screen
- type SystemClock
- type Terminal
- type Timer
Constants ¶
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.
const FrameInterval = time.Second / 30
FrameInterval is how long one of the throbber's phases lasts.
const InitrdRelease = "/etc/initrd-release"
InitrdRelease is the file whose presence marks the initrd.
const NotifyEnv = "NOTIFY_SOCKET"
NotifyEnv names the socket systemd's Type=notify services report on.
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 LoadBootDuration ¶
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 ¶
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 ¶
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 ¶
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. Whatever ends Run, a panic in a handler included, gives the VT back and releases the display and the console.
func SaveBootDuration ¶
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 ¶
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 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 off the loop.
RasterizeLogo func(scale int) (*theme.LogoRaster, 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 ¶
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.