package diskquota

import "github.com/containerd/accelerated-container-image/pkg/snapshot/diskquota"

Index

Constants

const (
	// QuotaMinID represents the minimum quota id.
	// The value is unit32(2^24).
	QuotaMinID = uint32(16777216)

	// QuotaMaxID represents the maximum quota id.
	QuotaMaxID = uint32(200000000)
)

Functions

func CheckRegularFile

func CheckRegularFile(file string) (bool, error)

CheckRegularFile is used to check the file is regular file or directory.

func ExecSync

func ExecSync(bin string, args ...string) (std, serr string, err error)

func SetDiskQuotaBytes

func SetDiskQuotaBytes(dir string, limit int64, quotaID uint32) error

SetDiskQuotaBytes set dir project quota to the quotaId

Types

type PrjQuotaDriver

type PrjQuotaDriver struct {

	// quotaIDs saves all of quota ids.
	// key: quota ID which means this ID is used in the global scope.
	// value: stuct{}
	QuotaIDs map[uint32]struct{}

	// lastID is used to mark last used quota ID.
	// quota ID is allocated increasingly by sequence one by one.
	LastID uint32
	// contains filtered or unexported fields
}

PrjQuotaDriver represents project quota driver.

func (*PrjQuotaDriver) CheckMountpoint

func (quota *PrjQuotaDriver) CheckMountpoint(dir string) (string, bool, error)

func (*PrjQuotaDriver) GetNextQuotaID

func (quota *PrjQuotaDriver) GetNextQuotaID() (quotaID uint32, err error)

GetNextQuotaID returns the next available quota id.

func (*PrjQuotaDriver) GetQuotaIDInFileAttr

func (quota *PrjQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32

GetQuotaIDInFileAttr gets attributes of the file which is in the inode. The returned result is quota ID. return 0 if failure happens, since quota ID must be positive. execution command: `lsattr -p $dir`

func (*PrjQuotaDriver) SetDiskQuota

func (quota *PrjQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error

SetDiskQuota uses the following two parameters to set disk quota for a directory. * quota size: a byte size of requested quota. * quota ID: an ID represent quota attr which is used in the global scope.

func (*PrjQuotaDriver) SetFileAttr

func (quota *PrjQuotaDriver) SetFileAttr(dir string, quotaID uint32) error

SetFileAttr set the file attr. ext4: chattr -p quotaid +P $DIR

Source Files

prjquota.go quota_utils.go

Version
v1.3.0 (latest)
Published
Feb 13, 2025
Platform
linux/amd64
Imports
14 packages
Last checked
1 minute ago

Tools for package owners.