github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/graphdriver/vfs/quota_linux.go (about)

     1  package vfs // import "github.com/demonoid81/moby/daemon/graphdriver/vfs"
     2  
     3  import (
     4  	"github.com/demonoid81/moby/daemon/graphdriver/quota"
     5  	"github.com/sirupsen/logrus"
     6  )
     7  
     8  //nolint:structcheck
     9  type driverQuota struct {
    10  	quotaCtl *quota.Control
    11  	quotaOpt quota.Quota
    12  }
    13  
    14  func setupDriverQuota(driver *Driver) {
    15  	if quotaCtl, err := quota.NewControl(driver.home); err == nil {
    16  		driver.quotaCtl = quotaCtl
    17  	} else if err != quota.ErrQuotaNotSupported {
    18  		logrus.Warnf("Unable to setup quota: %v\n", err)
    19  	}
    20  }
    21  
    22  func (d *Driver) setQuotaOpt(size uint64) error {
    23  	d.quotaOpt.Size = size
    24  	return nil
    25  }
    26  
    27  func (d *Driver) getQuotaOpt() uint64 {
    28  	return d.quotaOpt.Size
    29  }
    30  
    31  func (d *Driver) setupQuota(dir string, size uint64) error {
    32  	return d.quotaCtl.SetQuota(dir, quota.Quota{Size: size})
    33  }
    34  
    35  func (d *Driver) quotaSupported() bool {
    36  	return d.quotaCtl != nil
    37  }