statvfs_linux.go 592 B

1234567891011121314151617181920212223242526272829
  1. //go:build linux
  2. // +build linux
  3. package vfs
  4. import (
  5. "github.com/pkg/sftp"
  6. "golang.org/x/sys/unix"
  7. )
  8. func getStatFS(path string) (*sftp.StatVFS, error) {
  9. stat := unix.Statfs_t{}
  10. err := unix.Statfs(path, &stat)
  11. if err != nil {
  12. return nil, err
  13. }
  14. return &sftp.StatVFS{
  15. Bsize: uint64(stat.Bsize),
  16. Frsize: uint64(stat.Frsize),
  17. Blocks: stat.Blocks,
  18. Bfree: stat.Bfree,
  19. Bavail: stat.Bavail,
  20. Files: stat.Files,
  21. Ffree: stat.Ffree,
  22. Favail: stat.Ffree, // not sure how to calculate Favail
  23. Flag: uint64(stat.Flags),
  24. Namemax: uint64(stat.Namelen),
  25. }, nil
  26. }