fsstat.go 480 B

12345678910111213141516171819202122232425262728293031
  1. // +build aix
  2. package perfstat
  3. /*
  4. #include "c_helpers.h"
  5. */
  6. import "C"
  7. import (
  8. "fmt"
  9. )
  10. func FileSystemStat() ([]FileSystem, error) {
  11. var fsinfo *C.struct_fsinfo
  12. var nmounts C.int
  13. fsinfo = C.get_all_fs(&nmounts)
  14. if nmounts <= 0 {
  15. return nil, fmt.Errorf("No mounts found")
  16. }
  17. fs := make([]FileSystem, nmounts)
  18. for i := 0; i < int(nmounts); i++ {
  19. f := C.get_filesystem_stat(fsinfo, C.int(i))
  20. if f != nil {
  21. fs[i] = fsinfo2filesystem(f)
  22. }
  23. }
  24. return fs, nil
  25. }