linuxkernel

package module
Version: v0.0.0-...-cd5e443 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: ISC Imports: 9 Imported by: 0

README

linuxkernel

import "acln.ro/linuxkernel"

GoDoc

Utilities for interacting with the Linux kernel in various ways.

For now, this package deals with kernel configuration files and kernel symbol tables. It's a little bit of a mixed bag at the moment, and might be split up into multiple packages in the future, if necessary.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]string

Config represents a parsed Linux kernel configuration file.

Given a value cfg of type Config:

* for CONFIG_X=something, cfg["X"] == "bar"

* for CONFIG_Y="", cfg["Y"] == "".

* for # CONFIG_Z is not set, cfg["Z"] == "n".

func ParseConfig

func ParseConfig(r io.Reader) (Config, error)

ParseConfig parses a Config from r. It reads from r until EOF. ParseConfig assumes that its input is a well-formed kernel configuration file: its behavior is undefined otherwise.

func (Config) ApplyDiff

func (cfg Config) ApplyDiff(diff ConfigDiff) (Config, error)

ApplyDiff applies the specified diff to cfg and returns a new config, such that, schematically, if x.ApplyDiff(d) == y, then DiffConfig(x, y) == d.

func (Config) Equal

func (cfg Config) Equal(other Config) bool

Equal returns a boolean indicating whether cfg and the specified config are equal, i.e. the two configurations contain the exact same set of keys, and all the corresponding values are equal.

Comparing configuration files from different kernel versions may or may not be meaningful.

func (Config) WriteTo

func (cfg Config) WriteTo(w io.Writer) (int64, error)

WriteTo writes cfg to w in deterministic order. The output is a valid kernel configuration file, but it is almost certainly different from the original file the Config was parsed from.

type ConfigChange

type ConfigChange struct {
	Opt, OldVal, NewVal string
}

ConfigChange specifies a change in a configuration value.

func (ConfigChange) String

func (cc ConfigChange) String() string

String formats cc as, for example: "INET6_ESP_OFFLOAD n -> m".

type ConfigDiff

type ConfigDiff struct {
	InOld   []ConfigValue
	Changes []ConfigChange
	InNew   []ConfigValue
}

ConfigDiff contains differences between two kernel configurations. The slices are sorted by the option name.

func DiffConfig

func DiffConfig(old, new Config) ConfigDiff

DiffConfig returns the differences between the old and new config.

func (ConfigDiff) WriteTo

func (diff ConfigDiff) WriteTo(w io.Writer) (int64, error)

WriteTo writes the diff to w in a similar format to the scripts/diffconfig tool distributed with the Linux kernel.

The order is predictable: InOld, Changes, InNew.

type ConfigValue

type ConfigValue struct {
	Opt, Val string
}

ConfigValue contains an option, value pair.

func (ConfigValue) String

func (cv ConfigValue) String() string

String formats vs as, for example: "PKCS8_PRIVATE_KEY_PARSER n".

type Symbol

type Symbol struct {
	Addr   uintptr
	Type   SymbolType
	Name   string
	Module string
}

Symbol represents a kernel symbol.

func (Symbol) String

func (sym Symbol) String() string

type SymbolTable

type SymbolTable map[Symbol]struct{}

SymbolTable is a Linux kernel symbol table.

func Kallsyms

func Kallsyms() (SymbolTable, error)

Kallsyms calls ParseSymbols("/proc/kallsyms").

func ParseSymbols

func ParseSymbols(path string) (SymbolTable, error)

ParseSymbols reads kernel symbols from the specified path. The path should indicate /proc/kallsyms or the equivalent file if procfs is mounted elsewhere.

func (SymbolTable) Find

func (symtab SymbolTable) Find(name string) []Symbol

Find finds symbols with the specified name.

type SymbolType

type SymbolType rune

SymbolType is the type of a symbol, as reported by nm and /proc/kallsyms.

func (SymbolType) Absolute

func (styp SymbolType) Absolute() bool

Absolute returns a boolean indicating whether the symbol's value is absolute, and will not be changed by further linking ('A' or 'a').

func (SymbolType) BSS

func (styp SymbolType) BSS() bool

BSS returns a boolean indicating whether the symbol is in the BSS data section ('B' or 'b').

func (SymbolType) Data

func (styp SymbolType) Data() bool

Data returns a boolean indicating whether the symbol is in the initialized data section ('D' or 'd').

func (SymbolType) Global

func (styp SymbolType) Global() bool

Global returns a boolean indicating whether the symbol is global (external).

func (SymbolType) Readonly

func (styp SymbolType) Readonly() bool

Readonly returns a boolean indicating whether the symbol is in a read only data section ('R' or 'r').

func (SymbolType) Text

func (styp SymbolType) Text() bool

Text returns a boolean indicating whether the symbol is in a text section ('T' or 't').

func (SymbolType) WeakObject

func (styp SymbolType) WeakObject() bool

WeakObject returns a boolean indicating whether the symbol is a weak object ('V' or 'v').

func (SymbolType) WeakSymbol

func (styp SymbolType) WeakSymbol() bool

WeakSymbol returns a boolean indicating whether the symbol is a weak symbol ('W' or 'w').

Source Files

Jump to

Keyboard shortcuts

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