22 lines
475 B
Go
22 lines
475 B
Go
//go:build !windows
|
|
|
|
package health
|
|
|
|
import "syscall"
|
|
|
|
type fsKey struct {
|
|
typ int32
|
|
val0 int32
|
|
val1 int32
|
|
}
|
|
|
|
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
|
|
}
|
|
fs = fsKey{typ: 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
|
|
}
|