use actual system mdstat file
This commit is contained in:
parent
a0068579b4
commit
3eb1477ffc
@ -62,5 +62,5 @@ pub fn parse_lsblk() -> Vec<Disk> {
|
|||||||
if d.kind != "disk" { continue; };
|
if d.kind != "disk" { continue; };
|
||||||
disks.push(Disk { name: d.name, size: d.size });
|
disks.push(Disk { name: d.name, size: d.size });
|
||||||
}
|
}
|
||||||
disks
|
return disks;
|
||||||
}
|
}
|
@ -20,8 +20,7 @@ pub struct MdRaid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_mdstat() -> MdRaidSystem {
|
pub fn parse_mdstat() -> MdRaidSystem {
|
||||||
// let mdstat_path = "/proc/mdstat";
|
let mdstat_path = "/proc/mdstat";
|
||||||
let mdstat_path = "testmdstat.txt";
|
|
||||||
return match fs::read_to_string(mdstat_path) {
|
return match fs::read_to_string(mdstat_path) {
|
||||||
Ok(contents) => parse_mdstat_str(contents),
|
Ok(contents) => parse_mdstat_str(contents),
|
||||||
Err(_) => MdRaidSystem{
|
Err(_) => MdRaidSystem{
|
||||||
@ -40,10 +39,7 @@ fn parse_mdstat_str(contents: String) -> MdRaidSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for cap in RE.captures_iter(&contents) {
|
for cap in RE.captures_iter(&contents) {
|
||||||
if cap.len() != 5 {
|
if cap.len() == 5 {
|
||||||
// todo error handling
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
let devicesplit = cap[4].split(" ");
|
let devicesplit = cap[4].split(" ");
|
||||||
let mut devices = Vec::new();
|
let mut devices = Vec::new();
|
||||||
for i in devicesplit {
|
for i in devicesplit {
|
||||||
|
Loading…
Reference in New Issue
Block a user