procfs

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MPL-2.0 Imports: 4 Imported by: 9

Documentation

Overview

Package procfs provides function to manager kernel command line arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendAllOption

type AppendAllOption func(*AppendAllOptions)

AppendAllOption is a functional option for AppendAll.

func WithDeleteNegatedArgs added in v0.1.2

func WithDeleteNegatedArgs() AppendAllOption

WithDeleteNegatedArgs specifies whether kernel arguments that starts with `-` should be removed with AppendAll.

func WithOverwriteArgs

func WithOverwriteArgs(args ...string) AppendAllOption

WithOverwriteArgs specifies kernel arguments which should be overwritten with AppendAll.

type AppendAllOptions

type AppendAllOptions struct {
	OverwriteArgs     []string
	DeleteNegatedArgs bool
}

AppendAllOptions provides additional options for AppendAll.

type Cmdline

type Cmdline struct {
	Parameters
	sync.Mutex
}

Cmdline represents a set of kernel parameters.

func NewCmdline

func NewCmdline(parameters string) *Cmdline

NewCmdline initializes and returns a representation of the cmdline values specified by `parameters`.

func ProcCmdline

func ProcCmdline() *Cmdline

ProcCmdline returns a representation of /proc/cmdline.

func (*Cmdline) Append

func (c *Cmdline) Append(k, v string)

Append appends a kernel parameter.

func (*Cmdline) AppendAll

func (c *Cmdline) AppendAll(args []string, opts ...AppendAllOption) error

AppendAll appends a set of kernel parameters.

func (*Cmdline) Bytes

func (c *Cmdline) Bytes() []byte

Bytes returns the byte slice representation of the cmdline struct.

func (*Cmdline) Delete added in v0.1.2

func (c *Cmdline) Delete(v *Parameter)

Delete deletes a kernel parameter by exact match.

func (*Cmdline) DeleteAll added in v0.1.2

func (c *Cmdline) DeleteAll(k string)

DeleteAll deletes all occurrences of the kernel parameter.

func (*Cmdline) Get

func (c *Cmdline) Get(k string) (value *Parameter)

Get gets a kernel parameter.

func (*Cmdline) Set

func (c *Cmdline) Set(k string, v *Parameter)

Set sets a kernel parameter.

func (*Cmdline) SetAll

func (c *Cmdline) SetAll(args []string)

SetAll sets kernel parameters.

type Key

type Key = string

Key represents a key in a kernel parameter key-value pair.

type Parameter

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

Parameter represents a value in a kernel parameter key-value pair.

func NewParameter

func NewParameter(k string) *Parameter

NewParameter initializes and returns a Parameter.

func (*Parameter) Append

func (v *Parameter) Append(s string) *Parameter

Append appends a string to a value's internal representation.

func (*Parameter) Contains

func (v *Parameter) Contains(s string) (ok bool)

Contains returns a boolean indicating the existence of a value.

func (*Parameter) First

func (v *Parameter) First() *string

First attempts to return the first string of a value's internal representation.

func (*Parameter) Get

func (v *Parameter) Get(idx int) *string

Get attempts to get a string from a value's internal representation.

func (*Parameter) Key

func (v *Parameter) Key() string

Key returns the value's key.

type Parameters

type Parameters []*Parameter

Parameters represents /proc/cmdline.

func (Parameters) String

func (p Parameters) String() string

String returns a string representation of all parameters.

func (Parameters) Strings

func (p Parameters) Strings() []string

Strings returns a string representation of all parameters.

Jump to

Keyboard shortcuts

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