From a1ffca18e32f9fbdb1093ac88714e753b3b06e62 Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Thu, 24 Mar 2022 20:51:18 +0800 Subject: [PATCH] Cherry pick: fix taking rootfs as filesystem by mistake (#11554) (#52) * fix adding rootfs as filesystem by mistake Signed-off-by: onlyacat * reformat by lints Signed-off-by: onlyacat * close #11552 Signed-off-by: onlyacat Signed-off-by: CalvinNeo Co-authored-by: Z.H <29370032+onlyacat@users.noreply.github.com> Co-authored-by: Zhigao Tong --- src/server/service/diagnostics/sys.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server/service/diagnostics/sys.rs b/src/server/service/diagnostics/sys.rs index c6160bc841a..399101a9a06 100644 --- a/src/server/service/diagnostics/sys.rs +++ b/src/server/service/diagnostics/sys.rs @@ -362,6 +362,10 @@ fn disk_hardware_info(collector: &mut Vec) { system.refresh_disks(); let disks = system.get_disks(); for disk in disks { + let file_sys = std::str::from_utf8(disk.get_file_system()).unwrap_or("unknown"); + if file_sys == "rootfs" { + continue; + } let total = disk.get_total_space(); let free = disk.get_available_space(); let used = total - free; @@ -369,12 +373,7 @@ fn disk_hardware_info(collector: &mut Vec) { let used_pct = (used as f64) / (total as f64); let infos = vec![ ("type", format!("{:?}", disk.get_type())), - ( - "fstype", - std::str::from_utf8(disk.get_file_system()) - .unwrap_or("unkonwn") - .to_string(), - ), + ("fstype", file_sys.to_string()), ( "path", disk.get_mount_point()