server_statvfs_darwin.go 793 B

12345678910111213141516171819202122
  1. package sftp
  2. import (
  3. "syscall"
  4. )
  5. func statvfsFromStatfst(stat *syscall.Statfs_t) (*StatVFS, error) {
  6. return &StatVFS{
  7. Bsize: uint64(stat.Bsize),
  8. Frsize: uint64(stat.Bsize), // fragment size is a linux thing; use block size here
  9. Blocks: stat.Blocks,
  10. Bfree: stat.Bfree,
  11. Bavail: stat.Bavail,
  12. Files: stat.Files,
  13. Ffree: stat.Ffree,
  14. Favail: stat.Ffree, // not sure how to calculate Favail
  15. Fsid: uint64(uint64(stat.Fsid.Val[1])<<32 | uint64(stat.Fsid.Val[0])), // endianness?
  16. Flag: uint64(stat.Flags), // assuming POSIX?
  17. Namemax: 1024, // man 2 statfs shows: #define MAXPATHLEN 1024
  18. }, nil
  19. }