Documentation ¶
Overview ¶
Package modprobe allows users to load and unload Linux kernel modules by calling the relevant Linux syscalls.
Index ¶
- func Dependencies(path string) ([]string, error)
- func Init(file *os.File, params string) error
- func InitWithFlags(file *os.File, params string, flags int) error
- func Load(module, params string) error
- func ModInfo(file *os.File) (map[string]string, error)
- func Name(file *os.File) (string, error)
- func Remove(name string) error
- func ResolveName(name string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dependencies ¶
Dependencies takes a path to a .ko file, determine what modules will have to be present before loading that module, and return those modules as a slice of strings.
func Init ¶
Init will use the provide .ko file's os.File (created with os.Open or similar), to load that kernel module into the running kernel. This may error out for a number of reasons, such as no permission (either setcap CAP_SYS_MODULE or run as root), the .ko being for the wrong kernel, or the file not being a module at all.
Any arguments to the module may be passed through `params`, such as `file=/root/data/backing_file`.
func InitWithFlags ¶
InitWithFlags will preform an Init, but allow the passing of flags to the syscall. The `flags` parameter is a bit mask value created by ORing together zero or more of the following flags:
MODULE_INIT_IGNORE_MODVERSIONS - Ignore symbol version hashes MODULE_INIT_IGNORE_VERMAGIC - Ignore kernel version magic.
Both flags are defined in the golang.org/x/sys/unix package.
func Load ¶
Load will, given a short module name (such as `g_ether`), determine where the kernel module is located, determine any dependencies, and load all required modules.
func Name ¶
Name will, given a file descriptor to a Kernel Module (.ko file), parse the binary to get the module name. For instance, given a handle to the file at `kernel/drivers/usb/gadget/legacy/g_ether.ko`, return `g_ether`.
func Remove ¶
Remove will unload a loaded kernel module. If no such module is loaded, or if the module can not be unloaded, this function will return an error.
func ResolveName ¶
ResolveName will, given a module name (such as `g_ether`) return an absolute path to the .ko that provides that module.
Types ¶
This section is empty.