Crate kmod

source ·
Expand description

Bindings to libkmod to manage linux kernel modules.

Example

fn main() -> anyhow::Result<()> {
    // create a new kmod context
    let ctx = kmod::Context::new()?;

    // get a kmod_list of all loaded modules
    for module in ctx.modules_loaded()? {
        let name = module.name().to_string_lossy();
        let refcount = module.refcount();
        let size = module.size();

        let holders: Vec<_> = module.holders()
            .map(|x| x.name().to_string_lossy().into_owned())
            .collect();

        println!("{:<19} {:8}  {} {:?}", name, size, refcount, holders);
    }
    Ok(())
}

Re-exports

pub use ctx::*;
pub use errors::*;
pub use modules::*;

Modules

Structs

Wraps a platform-specific error code.