golang-kmod

module
v0.0.0-...-808c2b3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: Apache-2.0

README

Golang-kmod

Kmod is a set of tools for manipulating Linux Kernel modules. It relies on libkmod, which can be found at:

https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git

This project provides Golang bindings to the library libkmod. This way, it is possible to perform module manipulation operations straight from Golang.

Example

The following example must be run as root, and libkmod must be installed (headers files included).

package main

import (
    "fmt"
    "github.com/ElyKar/golang-kmod/kmod"
)

func main() {
    km, err := kmod.NewKmod()

    if err != nil {
        panic(err)
    }

    // List all loaded modules
    list, err := km.List()
    if err != nil {
        panic(err)
    }

    for _, module := range list {
        fmt.Printf("%s, %d\n", module.Name(), module.Size())
    }

    // Finds a specific module and display some informations about it
    if pcspkr, err := km.ModuleFromName("pcspkr"); err == nil {
        infoMod, err := pcspkr.Info()
        if err != nil {
            panic(err)
        }

        fmt.Printf("Author: %s\n", infoMod["author"])
        fmt.Printf("Description: %s\n", infoMod["description"])
        fmt.Printf("License: %s\n", infoMod["license"])
    }

    // Insert a module and its dependencies
    _ = km.Insert("rtl2832")

    // Remove a module
    _ = km.Remove("rtl2832")
}

From there

This package is really super simple (intended). The complete documentation can be found on Godoc.

Directories

Path Synopsis
Package kmod performs bindings over libkmod to manipulate kernel modules from Golang seemlessly.
Package kmod performs bindings over libkmod to manipulate kernel modules from Golang seemlessly.

Jump to

Keyboard shortcuts

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