github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/local/about_unix.go (about) 1 //go:build darwin || dragonfly || freebsd || linux 2 3 package local 4 5 import ( 6 "context" 7 "fmt" 8 "os" 9 "syscall" 10 11 "github.com/rclone/rclone/fs" 12 ) 13 14 // About gets quota information 15 func (f *Fs) About(ctx context.Context) (*fs.Usage, error) { 16 var s syscall.Statfs_t 17 err := syscall.Statfs(f.root, &s) 18 if err != nil { 19 if os.IsNotExist(err) { 20 return nil, fs.ErrorDirNotFound 21 } 22 return nil, fmt.Errorf("failed to read disk usage: %w", err) 23 } 24 bs := int64(s.Bsize) // nolint: unconvert 25 usage := &fs.Usage{ 26 Total: fs.NewUsageValue(bs * int64(s.Blocks)), //nolint: unconvert // quota of bytes that can be used 27 Used: fs.NewUsageValue(bs * int64(s.Blocks-s.Bfree)), //nolint: unconvert // bytes in use 28 Free: fs.NewUsageValue(bs * int64(s.Bavail)), //nolint: unconvert // bytes which can be uploaded before reaching the quota 29 } 30 return usage, nil 31 } 32 33 // check interface 34 var _ fs.Abouter = &Fs{}