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

This commit is contained in:
Michal Kucharczyk authored and GitHub committed 2023-01-24 19:22:47 +00:00
1 parent 545de88c47
commit d99e2e4bea
1 file changed
+4 -1
+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)
}