use actual system mdstat file
This commit is contained in:
		@@ -26,4 +26,4 @@ async fn main() -> Result<(), rocket::Error> {
 | 
			
		||||
        .await?;
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -62,5 +62,5 @@ pub fn parse_lsblk() -> Vec<Disk> {
 | 
			
		||||
        if d.kind != "disk" { continue; };
 | 
			
		||||
        disks.push(Disk { name: d.name, size: d.size });
 | 
			
		||||
    }
 | 
			
		||||
    disks
 | 
			
		||||
}
 | 
			
		||||
    return disks;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -20,8 +20,7 @@ pub struct MdRaid {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn parse_mdstat() -> MdRaidSystem {
 | 
			
		||||
    // let mdstat_path = "/proc/mdstat";
 | 
			
		||||
    let mdstat_path = "testmdstat.txt";
 | 
			
		||||
    let mdstat_path = "/proc/mdstat";
 | 
			
		||||
    return match fs::read_to_string(mdstat_path) {
 | 
			
		||||
        Ok(contents) => parse_mdstat_str(contents),
 | 
			
		||||
        Err(_) => MdRaidSystem{
 | 
			
		||||
@@ -40,10 +39,7 @@ fn parse_mdstat_str(contents: String) -> MdRaidSystem {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for cap in RE.captures_iter(&contents) {
 | 
			
		||||
        if cap.len() != 5 {
 | 
			
		||||
            // todo error handling
 | 
			
		||||
            continue
 | 
			
		||||
        } else {
 | 
			
		||||
        if cap.len() == 5 {
 | 
			
		||||
            let devicesplit = cap[4].split(" ");
 | 
			
		||||
            let mut devices = Vec::new();
 | 
			
		||||
            for i in devicesplit {
 | 
			
		||||
@@ -166,4 +162,4 @@ md0 : active raid1 sdb1[1] sda1[0]
 | 
			
		||||
unused devices: <none>
 | 
			
		||||
        "#.to_string())).to_string(), exp);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user