github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/daemon/graphdriver/vfs/quota_linux.go (about)

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