feat: enforce tiered storage reservations
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//go:build !windows
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func filesystemFreeBytes(path string) (uint64, error) {
|
||||
var status syscall.Statfs_t
|
||||
if err := syscall.Statfs(path, &status); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
blockSize := uint64(status.Bsize)
|
||||
availableBlocks := uint64(status.Bavail)
|
||||
if blockSize != 0 && availableBlocks > math.MaxUint64/blockSize {
|
||||
return 0, errors.New("filesystem free-space value overflowed")
|
||||
}
|
||||
return availableBlocks * blockSize, nil
|
||||
}
|
||||
Reference in New Issue
Block a user