use std::process;
use std::str;
pub fn architecture() -> String {
let arch = process::Command::new("uname")
.arg("-p")
.output()
.expect("Error while fetching CPU architecture");
let arch = str::from_utf8(&arch.stdout).unwrap();
let arch = str::trim(arch);
String::from(arch)
}
pub fn kernel_version() -> String {
let output = process::Command::new("uname")
.arg("-r")
.output()
.expect("Error while fetching kernel version");
let output = str::from_utf8(&output.stdout).unwrap();
let output = str::trim(output);
String::from(output)
}
pub fn is_module_loaded(module: &str) -> bool {
let lsmod = process::Command::new("lsmod")
.stdout(process::Stdio::piped())
.spawn()
.expect("Error while fetching loaded kernel modules");
let mut grep = process::Command::new("grep")
.arg(module)
.stdin(process::Stdio::from(lsmod.stdout.unwrap()))
.stdout(process::Stdio::null())
.spawn()
.expect("Error while searching for loaded kernel module");
grep.wait().unwrap().success()
}