github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/lib/diskusage/diskusage_openbsd.go (about) 1 //go:build openbsd 2 3 package diskusage 4 5 import ( 6 "golang.org/x/sys/unix" 7 ) 8 9 // New returns the disk status for dir. 10 // 11 // May return Unsupported error if it doesn't work on this platform. 12 func New(dir string) (info Info, err error) { 13 var statfs unix.Statfs_t 14 err = unix.Statfs(dir, &statfs) 15 if err != nil { 16 return info, err 17 } 18 // Note that these can be different sizes on different OSes so 19 // we upcast them all to uint64 20 //nolint:unconvert 21 info.Free = uint64(statfs.F_bfree) * uint64(statfs.F_bsize) 22 //nolint:unconvert 23 info.Available = uint64(statfs.F_bavail) * uint64(statfs.F_bsize) 24 //nolint:unconvert 25 info.Total = uint64(statfs.F_blocks) * uint64(statfs.F_bsize) 26 return info, nil 27 }