5733c71c50
We were ignoring quite a few error cases, and had one case where we weren't actually updating state where we wanted to. Unfortunately, if the linter doesn't pass, nobody has any reason to actually check lint failures in CI. There are three remaining XXXs marked in the code for lint.
22 lines
452 B
Go
22 lines
452 B
Go
package fsutil
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
func Statfs(path string) (FsStat, error) {
|
|
var stat syscall.Statfs_t
|
|
if err := syscall.Statfs(path, &stat); err != nil {
|
|
return FsStat{}, xerrors.Errorf("statfs: %w", err)
|
|
}
|
|
|
|
// force int64 to handle platform specific differences
|
|
//nolint:unconvert
|
|
return FsStat{
|
|
Capacity: int64(stat.Blocks) * int64(stat.Bsize),
|
|
Available: int64(stat.Bavail) * int64(stat.Bsize),
|
|
}, nil
|
|
}
|