From 265dd08ac9addacbf662730925d9ee45077697da Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Thu, 25 Jun 2026 23:44:09 -0400 Subject: [PATCH] don't use cached values --- src/collection/disks/freebsd.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/collection/disks/freebsd.rs b/src/collection/disks/freebsd.rs index 951e21fe..754a7272 100644 --- a/src/collection/disks/freebsd.rs +++ b/src/collection/disks/freebsd.rs @@ -117,7 +117,11 @@ fn mounts() -> CollectionResult> { // SAFETY: System API FFI call. The buffer has capacity for `expected_len` // entries, and `bufsize` describes its size in bytes. - let result = unsafe { libc::getfsstat(mounts.as_mut_ptr(), bufsize, libc::MNT_NOWAIT) }; + // + // `MNT_WAIT` requests fresh statistics from each filesystem rather than + // possibly-stale cached values (`MNT_NOWAIT`). This matches the default + // behaviour of `df`, so the reported free/used space lines up with it. + let result = unsafe { libc::getfsstat(mounts.as_mut_ptr(), bufsize, libc::MNT_WAIT) }; if result < 0 { return Err(std::io::Error::last_os_error().into()); }