ErrModuleInUse is the error resulting if a module can't be unloaded because it is in use.
var ErrModuleInUse = errors.New("module is in use")
ErrModuleNotFound is the error resulting if a module can't be found.
var ErrModuleNotFound = errors.New("module not found")
InitFunc provides a hook to load a kernel module into the kernel.
type InitFunc func(filename string, params string, flags int) error
Kmod represents internal configuration
type Kmod struct {
// contains filtered or unexported fields
}
func New(opts ...Option) (*Kmod, error)
New returns a new Kmod.
func (k *Kmod) Dependencies(name string) ([]string, error)
Dependencies returns a list of module dependencies.
func (k *Kmod) Load(name, params string, flags int) error
Load loads a kernel module. If the module depends on other modules Load will try to load all dependencies first.
func (k *Kmod) Unload(name string) error
Unload unloads a module from the kernel. Unload also tries to unload all module dependencies that are no longer in use.
Option configures Kmod.
type Option func(*Kmod)
func SetConfigFile(path string) Option
SetConfigFile returns an Option that specifies the (optional) configuration file for modules, default: /etc/modprobe.conf. The config file is used only for module parameters. options <name> parameter [parameter]...
func SetDryrun() Option
SetDryrun returns an Option that specifies to do everything but actually load or unload.
func SetIgnoreAlias() Option
SetIgnoreAlias returns an Option that specifies not to consult modules.alias to resolve aliases.
func SetIgnoreBuiltin() Option
SetIgnoreBuiltin returns an Option that specifies not to consult modules.builtin to find built-in modules.
func SetIgnoreStatus() Option
SetIgnoreStatus returns an Option that specifies not to consult /proc/modules to get the current status of a module.
func SetInitFunc(fn InitFunc) Option
SetInitFunc returns an Option that sets fn to be used for loading module files into the kernel. The default function tries to use finit_module(2) first and if that failes init_module(2). To support compressed module files see the example cmd/modprobe.
func SetRootDir(dir string) Option
SetRootDir returns an Option that sets dir as root directory for modules, default: /lib/modules
func SetVerbose() Option
SetVerbose returns an Option that specifies to log info messages about what's going on.