Skip to content

Commit d3db428

Browse files
committed
exit when the dmi file is not found
1 parent 62d4c22 commit d3db428

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/dmi.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66
fmt::Display,
77
fs::File,
88
io::{BufRead, BufReader, Read},
9+
path::Path,
910
};
1011

1112
use anyhow::{Result, bail};
@@ -82,6 +83,16 @@ impl DMI {
8283
let mut system: Option<System> = None;
8384
let mut baseboard: Option<Baseboard> = None;
8485

86+
let dmi_file_path = Path::new("/sys/firmware/dmi/tables/DMI");
87+
88+
match dmi_file_path.try_exists() {
89+
Ok(true) => {}
90+
Ok(false) | Err(_) => {
91+
eprintln!("No SMBIOS found");
92+
std::process::exit(1);
93+
}
94+
}
95+
8596
let mem_file = File::open("/sys/firmware/dmi/tables/DMI")?;
8697
let mut file = BufReader::new(mem_file);
8798

0 commit comments

Comments
 (0)