kcmdline

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KernelCommandLine

func KernelCommandLine() (string, error)

KernelCommandLine returns the command line reported by the running kernel.

func KeyValues

func KeyValues(keys ...string) (map[string]string, error)

KeyValues returns a map of the specified keys to the values set for them in the kernel command line (eg. panic=-1). If the key is missing from the kernel command line, it is omitted from the returned map, but it is added if present even if it has no value.

func MockProcCmdline

func MockProcCmdline(newPath string) (restore func())

MockProcCmdline overrides the path to /proc/cmdline. For use in tests.

func RemoveMatchingFilter

func RemoveMatchingFilter(cmdline string, match []ArgumentPattern) []string

RemoveMatchingFilter parses a kernel command line and remove arguments that matches match patterns.

func Split

func Split(s string) (out []string, err error)

Split tries to split the string comprising full or a part of a kernel command line into a list of individual arguments. Returns an error when the input string is incorrectly formatted.

See https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html for details.

Types

type Argument

type Argument struct {
	Param  string
	Value  string
	Quoted bool
}

Argument represents a parsed kernel argument.

func Parse

func Parse(cmdline string) (args []Argument)

Parse parses a kernel command line, returning a slice with the arguments in the same order as in cmdline. Note that kernel arguments can be repeated. We follow the same algorithm as in linux kernel's function lib/cmdline.c:next_arg as far as possible. TODO Replace Split with this eventually

func (*Argument) String

func (ka *Argument) String() string

func (*Argument) UnmarshalYAML

func (ka *Argument) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaler interface.

type ArgumentPattern

type ArgumentPattern struct {
	// contains filtered or unexported fields
}

ArgumentPattern represents a pattern which can match a Argument This is intended to be used with Matcher

func NewAnyPattern

func NewAnyPattern(param string) ArgumentPattern

This constructor is needed mainly for test instead of unmarshaling from yaml

func NewConstantPattern

func NewConstantPattern(param string, value string) ArgumentPattern

This constructor is needed mainly for test instead of unmarshaling from yaml

func (*ArgumentPattern) MarshalBinary

func (kap *ArgumentPattern) MarshalBinary() ([]byte, error)

func (*ArgumentPattern) MarshalText

func (kap *ArgumentPattern) MarshalText() ([]byte, error)

func (*ArgumentPattern) UnmarshalBinary

func (kap *ArgumentPattern) UnmarshalBinary(data []byte) error

func (*ArgumentPattern) UnmarshalText

func (kap *ArgumentPattern) UnmarshalText(data []byte) error

func (*ArgumentPattern) UnmarshalYAML

func (kap *ArgumentPattern) UnmarshalYAML(unmarshal func(interface{}) error) error

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher matches a Argument with multiple ArgumentPatterns

func NewMatcher

func NewMatcher(allowed []ArgumentPattern) Matcher

func (*Matcher) Match

func (m *Matcher) Match(arg Argument) bool

Jump to

Keyboard shortcuts

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