[−][src]Function nix::kmod::init_module
pub fn init_module(module_image: &[u8], param_values: &CStr) -> Result<()>
Loads a kernel module from a buffer.
It loads an ELF image into kernel space, performs any necessary symbol relocations, initializes module parameters to values provided by the caller, and then runs the module's init function.
This function requires CAP_SYS_MODULE
privilege.
The module_image
argument points to a buffer containing the binary image
to be loaded. The buffer should contain a valid ELF image
built for the running kernel.
The param_values
argument is a string containing space-delimited specifications
of the values for module parameters.
Each of the parameter specifications has the form:
name[=value[,value...]]
Example
use std::fs::File; use std::io::Read; use std::ffi::CString; use nix::kmod::init_module; let mut f = File::open("mykernel.ko").unwrap(); let mut contents: Vec<u8> = Vec::new(); f.read_to_end(&mut contents).unwrap(); init_module(&mut contents, &CString::new("who=Rust when=Now,12").unwrap()).unwrap();
See man init_module(2)
for more information.