fsstat.go 495 B

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