blob: 9979f3007331d56a1c51c956da59b2dec1e6b1ce (
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
25
26
27
|
use std::process::Command;
// TODO: Rewrite this bad fn
pub fn spawn_udev() -> Result<(), Box<dyn std::error::Error>> {
let udevd_paths = [
"/sbin/udevd",
"/usr/sbin/udevd",
"/bin/udevd",
"/usr/bin/udevd",
];
let udevd_path = udevd_paths
.iter()
.find(|path| std::path::Path::new(path).exists())
.ok_or_else(|| -> Box<dyn std::error::Error> {
"udevd not found in standard locations".into()
})?;
Command::new(udevd_path).arg("--daemon").spawn().map_err(
|e| -> Box<dyn std::error::Error> { format!("Failed to spawn udevd: {}", e).into() },
)?;
Command::new(udevd_path).arg("--trigger").output().map_err(
|e| -> Box<dyn std::error::Error> { format!("Failed to trigger udev: {}", e).into() },
)?;
Ok(())
}
|