Skip to content

Commit 08c878a

Browse files
authored
cmd/utils: add workaround for FreeBSD statfs quirk (#22310)
Make geth build on FreeBSD, fixes #22309.
1 parent 7d1b711 commit 08c878a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/utils/diskusage.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,12 @@ func getFreeDiskSpace(path string) (uint64, error) {
3131
}
3232

3333
// Available blocks * size per block = available space in bytes
34-
return stat.Bavail * uint64(stat.Bsize), nil
34+
var bavail = stat.Bavail
35+
if stat.Bavail < 0 {
36+
// FreeBSD can have a negative number of blocks available
37+
// because of the grace limit.
38+
bavail = 0
39+
}
40+
//nolint:unconvert
41+
return uint64(bavail) * uint64(stat.Bsize), nil
3542
}

0 commit comments

Comments
 (0)