From 7c1f50d920c804097ec5dd5e9cd2c8e17f685d80 Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Sun, 22 Nov 2020 20:00:37 -0500 Subject: [PATCH] Unbreak FreeBSD compilation (syscall.Statfs_t) (#1734) The types of fields in syscall.Statfs_t varies between platforms. fs.Bavail is uint64 on Linux and int64 on FreeBSD. This is the opposite way around to fs.Bsize. For now, just coerce the Bavail to be uint64. If the VFS layer might return -1 for one or the other of these then these casts will be problematic and we'll need more safeguards. --- server/disk_avail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/disk_avail.go b/server/disk_avail.go index 90157fe7..8abe3e49 100644 --- a/server/disk_avail.go +++ b/server/disk_avail.go @@ -28,7 +28,7 @@ func diskAvailable(storeDir string) int64 { var fs syscall.Statfs_t if err := syscall.Statfs(storeDir, &fs); err == nil { // Estimate 75% of available storage. - ba = int64(fs.Bavail * uint64(fs.Bsize) / 4 * 3) + ba = int64(uint64(fs.Bavail) * uint64(fs.Bsize) / 4 * 3) } else { // Used 1TB default as a guess if all else fails. ba = JetStreamMaxStoreDefault