summaryrefslogtreecommitdiff
path: root/init/src/kmods/load.rs
blob: 164d429e9042c26802d82777fb9eea5b7254d29c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use liblmod::{Selection, 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 kmod in &modules {
        modprobe(kmod.to_string(), "".to_string(), Selection::Current)?;
    }

    Ok(())
}

// TODO: Think, is `rmmod` needed?