21 lines
505 B
Go
21 lines
505 B
Go
//go:build !windows
|
|
|
|
package health
|
|
|
|
import "syscall"
|
|
|
|
func diskStat(path string) (total, free uint64, fs fsKey, ok bool) {
|
|
var st syscall.Statfs_t
|
|
if err := syscall.Statfs(path, &st); err != nil {
|
|
return 0, 0, fsKey{}, false
|
|
}
|
|
// st.Type is int64 on amd64 / int32 on some arches — always widen.
|
|
fs = fsKey{
|
|
typ: int64(st.Type),
|
|
val0: st.Fsid.X__val[0],
|
|
val1: st.Fsid.X__val[1],
|
|
}
|
|
total = st.Blocks * uint64(st.Bsize)
|
|
free = st.Bavail * uint64(st.Bsize)
|
|
return total, free, fs, true
|
|
}
|