statvfs_unix.go 626 B

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