disk_supported.go 351 B

12345678910111213141516171819
  1. // +build !windows,!openbsd,!netbsd,!plan9,!solaris
  2. package stats
  3. import (
  4. "syscall"
  5. )
  6. func (disk *DiskStatus) fillInStatus() {
  7. fs := syscall.Statfs_t{}
  8. err := syscall.Statfs(disk.Dir, &fs)
  9. if err != nil {
  10. return
  11. }
  12. disk.All = fs.Blocks * uint64(fs.Bsize)
  13. disk.Free = fs.Bfree * uint64(fs.Bsize)
  14. disk.Used = disk.All - disk.Free
  15. return
  16. }