You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
758 B

5 years ago
  1. package stats
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
  4. "golang.org/x/sys/windows"
  5. "syscall"
  6. "unsafe"
  7. )
  8. var (
  9. kernel32 = windows.NewLazySystemDLL("Kernel32.dll")
  10. getDiskFreeSpaceEx = kernel32.NewProc("GetDiskFreeSpaceExW")
  11. )
  12. func fillInDiskStatus(disk *volume_server_pb.DiskStatus) {
  13. ptr, err := syscall.UTF16PtrFromString(disk.Dir)
  14. if err != nil {
  15. return
  16. }
  17. var _temp uint64
  18. /* #nosec */
  19. r, _, e := syscall.Syscall6(
  20. getDiskFreeSpaceEx.Addr(),
  21. 4,
  22. uintptr(unsafe.Pointer(ptr)),
  23. uintptr(unsafe.Pointer(&disk.Free)),
  24. uintptr(unsafe.Pointer(&disk.All)),
  25. uintptr(unsafe.Pointer(&_temp)),
  26. 0,
  27. 0,
  28. )
  29. if r == 0 {
  30. if e != 0 {
  31. return
  32. }
  33. return
  34. }
  35. calculateDiskRemaining(disk)
  36. return
  37. }