bootparam

package
v0.0.0-...-5fb8a3f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package bootparam implements encoding and decoding of Linux kernel command lines as documented in https://docs.kernel.org/admin-guide/kernel-parameters.html

The format is quite quirky and thus the implementation is mostly based on the code in the Linux kernel implementing the decoder and not the specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(params Params, rest string) (string, error)

Marshal encodes a set of kernel parameters and an optional rest string into a Linux kernel command line. It rejects data which is not encodable, which includes null bytes, double quotes in params as well as characters which contain 0xa0 in their UTF-8 representation (historical Linux quirk of treating that as a space, inherited from Latin-1).

func TrimLeftSpace

func TrimLeftSpace(s string) string

TrimLeftSpace spaces as defined by Linux from the left of the string. This is only exported for tests, do not use this. Because of import loops as well as cgo restrictions this cannot be an internal function used by tests.

Types

type Param

type Param struct {
	Param, Value string
	HasValue     bool
}

Param represents a single boot parameter with or without a value

type Params

type Params []Param

Params represents a list of kernel boot parameters

func Unmarshal

func Unmarshal(cmdline string) (params Params, rest string, err error)

Unmarshal decodes a Linux kernel command line and returns a list of kernel parameters as well as a rest section after the "--" parsing terminator.

func (Params) Consoles

func (p Params) Consoles() map[string]bool

Consoles returns the set of consoles passed to the kernel, i.e. the values passed to the console= directive. It normalizes away any possibly present /dev/ prefix, returning values like ttyS0. It returns an empty set in case no valid console parameters exist.

Directories

Path Synopsis
Package ref provides the reference implementation for kernel command line parsing as present in the Linux kernel.
Package ref provides the reference implementation for kernel command line parsing as present in the Linux kernel.

Jump to

Keyboard shortcuts

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