Unverified Commit 08c878ac authored by Guillaume Ballet's avatar Guillaume Ballet Committed by GitHub

cmd/utils: add workaround for FreeBSD statfs quirk (#22310)

Make geth build on FreeBSD, fixes #22309.
parent 7d1b711c
...@@ -31,5 +31,12 @@ func getFreeDiskSpace(path string) (uint64, error) { ...@@ -31,5 +31,12 @@ func getFreeDiskSpace(path string) (uint64, error) {
} }
// Available blocks * size per block = available space in bytes // Available blocks * size per block = available space in bytes
return stat.Bavail * uint64(stat.Bsize), nil var bavail = stat.Bavail
if stat.Bavail < 0 {
// FreeBSD can have a negative number of blocks available
// because of the grace limit.
bavail = 0
}
//nolint:unconvert
return uint64(bavail) * uint64(stat.Bsize), nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment