disk_supported.go 429 B

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