storage-monitor: statvfs arithmetic bug fixed (#13234)

This commit is contained in:
Michal Kucharczyk
2023-01-24 20:22:47 +01:00
committed by GitHub
parent 545de88c47
commit d99e2e4bea
+4 -1
View File
@@ -118,7 +118,10 @@ impl StorageMonitorService {
/// Returns free space in MB, or error if statvfs failed.
fn free_space(path: &Path) -> Result<u64, Error> {
statvfs(path)
.map(|stats| stats.blocks_available() * stats.block_size() / 1_000_000)
.map(|stats| {
u64::from(stats.blocks_available()).saturating_mul(u64::from(stats.block_size())) /
1_000_000
})
.map_err(Error::from)
}