Skip to content

Commit 66cd979

Browse files
gballetcfilipescu
authored andcommitted
cmd/utils: add workaround for FreeBSD statfs quirk (ethereum#22310)
Make geth build on FreeBSD, fixes ethereum#22309.
1 parent 4f2ddb3 commit 66cd979

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/utils/diskusage.go

Lines changed: 8 additions & 1 deletion
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)