kernel

package
v0.0.0-...-263a040 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidAssetName = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9-]*$")

ValidAssetName is a regular expression matching valid asset name.

Functions

func DriversTreeDir

func DriversTreeDir(rootdir, kernelName string, rev snap.Revision) string

DriversTreeDir returns the directory for a given kernel and revision under rootdir.

func EnsureKernelDriversTree

func EnsureKernelDriversTree(kMntPts MountPoints, compsMntPts []ModulesCompMountPoints, destDir string, opts *KernelDriversTreeOptions) (err error)

EnsureKernelDriversTree creates a drivers tree that can include modules/fw from kernel-modules components. opts.KernelInstall tells the function if this is a kernel install (which might be installing components at the same time) or an only components install.

For kernel installs, this function creates a tree in destDir (should be of the form <somedir>/var/lib/snapd/kernel/<ksnapName>/<rev>), which is bind-mounted after a reboot to /usr/lib/{modules,firmware} (the currently active kernel is using a different path as it has a different revision). This tree contains files from the kernel snap content in kSnapRoot, as well as symlinks to it. Information from modules is found by looking at comps slice.

For components-only install, we want the components to be available without rebooting. For this, we work on a temporary tree, and after finishing it we swap atomically the affected modules/firmware folders with those of the currently active kernel drivers tree.

To make this work in all cases we need to know the current mounts of the kernel snap / components to be installed and the final mounts when the system is run after installation (as the installing system might be classic while the installed system could be hybrid or UC, or we could be installing from the initramfs). To consider all cases, we need to run depmod with links to the currently available content, and then replace those links with the expected mounts in the running system.

func KernelVersionFromModulesDir

func KernelVersionFromModulesDir(mountPoint string) (string, error)

KernelVersionFromModulesDir returns the kernel version for a mounted kernel snap (this would be the output if "uname -r" for a running kernel). It assumes that there is a folder named modules/$(uname -r) inside the snap.

func RemoveKernelDriversTree

func RemoveKernelDriversTree(treeRoot string) (err error)

RemoveKernelDriversTree cleans-up the writable kernel tree in snapd data folder, under kernelSubdir/<rev> (kernelSubdir is usually the snap name). When called from the kernel package <rev> might be <rev>_tmp.

func Validate

func Validate(kernelRoot string) error

Validate checks whether the given directory contains valid kernel snap metadata and a matching content.

Types

type Asset

type Asset struct {
	// TODO: we may make this an (optional) map at some point in
	//       the future to select what things should be updated.
	//
	// Update set to true indicates that assets shall be updated.
	Update  bool     `yaml:"update,omitempty"`
	Content []string `yaml:"content,omitempty"`
}

type Info

type Info struct {
	// DynamicModules points to a folder containing {modules,firmware}
	// subfolders that are created by snap or component hooks. The only
	// valid value at the moment is $SNAP_DATA (or ${SNAP_DATA}).
	DynamicModules string            `yaml:"dynamic-modules,omitempty"`
	Assets         map[string]*Asset `yaml:"assets,omitempty"`
}

func InfoFromKernelYaml

func InfoFromKernelYaml(kernelYaml []byte) (*Info, error)

InfoFromKernelYaml reads the provided kernel metadata.

func ReadInfo

func ReadInfo(kernelSnapRootDir string) (*Info, error)

ReadInfo reads the kernel specific metadata from meta/kernel.yaml in the snap root directory if the file exists.

func (*Info) DynamicModulesDir

func (ki *Info) DynamicModulesDir(kSnapName string, ksnapRev snap.Revision) string

DynamicModulesDir returns the directory where the kernel is expected to store dynamically generated modules/firmware. To find out this needs the kernel snap name and revision.

type KernelDriversTreeOptions

type KernelDriversTreeOptions struct {
	// Set if we are building the tree for a kernel we are installing right now
	KernelInstall bool
}

type ModulesCompMountPoints

type ModulesCompMountPoints struct {
	// LinkName is the name of the symlink in the drivers tree that will
	// point to the component modules.
	LinkName string
	MountPoints
}

ModulesCompMountPoints contains mount points for a component plus its name.

type MountPoints

type MountPoints struct {
	// Current is where the container to be installed is currently
	// available
	Current string
	// Target is where the container will be found in a running system
	Target string
}

MountPoints describes mount points for a snap or a component.

func (*MountPoints) CurrentEqualsTarget

func (mp *MountPoints) CurrentEqualsTarget() bool

func (*MountPoints) UnderCurrentPath

func (mp *MountPoints) UnderCurrentPath(dirs ...string) string

func (*MountPoints) UnderTargetPath

func (mp *MountPoints) UnderTargetPath(dirs ...string) string

Directories

Path Synopsis
package fde implements helper used by low level parts like secboot in snap-bootstrap and high level parts like DeviceManager in snapd.
package fde implements helper used by low level parts like secboot in snap-bootstrap and high level parts like DeviceManager in snapd.

Jump to

Keyboard shortcuts

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