blob: 374ce363ea41d2be54d31433d796be62a5ebc1d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use liblmod::Selection;
use liblmod::modprobe;
use std::fs;
fn parse_modules() -> Result<Vec<String>, Box<dyn std::error::Error>> {
let raw_mods = fs::read_to_string("/etc/modules")?
.split(',')
.map(|s| s.trim().to_string())
.collect();
Ok(raw_mods)
}
pub fn load_modules() -> Result<(), Box<dyn std::error::Error>> {
let modules = parse_modules()?;
for i in 0..modules.len() {
modprobe(modules[i].to_string(), "".to_string(), Selection::Current)?;
}
Ok(())
}
// TODO: Think, is `rmmod` needed?
|