quota

package
v0.0.0-...-2812ca0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// QuotaMinID represents the minimize quota id.
	QuotaMinID = uint32(16777216)
)

Variables

View Source
var (
	// UseQuota represents use quota or not.
	UseQuota = true
	// Gquota represents global quota.
	Gquota = NewQuota("")
)

Functions

func CheckMountpoint

func CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point.

func GetDefaultQuota

func GetDefaultQuota(quotas map[string]string) string

GetDefaultQuota returns the default quota size.

func GetDevID

func GetDevID(dir string) (uint64, error)

GetDevID returns device id.

func GetFileAttr

func GetFileAttr(dir string) uint32

GetFileAttr returns the directory attributes.

func GetNextQuatoID

func GetNextQuatoID() (uint32, error)

GetNextQuatoID returns the next available quota id.

func SetDiskQuota

func SetDiskQuota(dir string, size string, quotaID uint32) error

SetDiskQuota is used to set quota for directory.

func SetFileAttr

func SetFileAttr(dir string, id uint32) error

SetFileAttr is used to set file attributes.

func SetFileAttrNoOutput

func SetFileAttrNoOutput(dir string, id uint32)

SetFileAttrNoOutput is used to set file attributes without error.

func SetQuotaDriver

func SetQuotaDriver(name string)

SetQuotaDriver is used to set global quota driver.

func SetSubtree

func SetSubtree(dir string, qid uint32) (uint32, error)

SetSubtree is used to set quota id for directory.

func StartQuotaDriver

func StartQuotaDriver(dir string) (string, error)

StartQuotaDriver is used to start quota driver.

Types

type BaseQuota

type BaseQuota interface {
	StartQuotaDriver(dir string) (string, error)
	SetSubtree(dir string, qid uint32) (uint32, error)
	SetDiskQuota(dir string, size string, quotaID uint32) error
	CheckMountpoint(devID uint64) (string, bool, string)
	GetFileAttr(dir string) uint32
	SetFileAttr(dir string, id uint32) error
	SetFileAttrNoOutput(dir string, id uint32)
	GetNextQuatoID() (uint32, error)
}

BaseQuota defines the quota operation interface.

func NewQuota

func NewQuota(name string) BaseQuota

NewQuota returns a quota instance.

type GrpQuota

type GrpQuota struct {
	// contains filtered or unexported fields
}

GrpQuota represents group quota.

func (*GrpQuota) CheckMountpoint

func (quota *GrpQuota) CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point. cat /proc/mounts as follows: /dev/sda3 / ext4 rw,relatime,data=ordered 0 0 /dev/sda2 /boot/grub2 ext4 rw,relatime,stripe=4,data=ordered 0 0 /dev/sda5 /home ext4 rw,relatime,data=ordered 0 0 /dev/sdb1 /home/pouch ext4 rw,relatime,grpquota,data=ordered 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/cpuset,cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu,cpuset 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0

func (*GrpQuota) GetFileAttr

func (quota *GrpQuota) GetFileAttr(dir string) uint32

GetFileAttr returns the directory attributes getfattr -n system.subtree --only-values --absolute-names /

func (*GrpQuota) GetNextQuatoID

func (quota *GrpQuota) GetNextQuatoID() (uint32, error)

GetNextQuatoID returns the next available quota id.

func (*GrpQuota) SetDiskQuota

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

SetDiskQuota is used to set quota for directory.

func (*GrpQuota) SetFileAttr

func (quota *GrpQuota) SetFileAttr(dir string, id uint32) error

SetFileAttr is used to set file attributes.

func (*GrpQuota) SetFileAttrNoOutput

func (quota *GrpQuota) SetFileAttrNoOutput(dir string, id uint32)

SetFileAttrNoOutput is used to set file attributes without error.

func (*GrpQuota) SetSubtree

func (quota *GrpQuota) SetSubtree(dir string, qid uint32) (uint32, error)

SetSubtree is used to set quota id for directory, setfattr -n system.subtree -v $QUOTAID

func (*GrpQuota) StartQuotaDriver

func (quota *GrpQuota) StartQuotaDriver(dir string) (string, error)

StartQuotaDriver is used to start quota driver.

type OverlayMount

type OverlayMount struct {
	Merged string
	Lower  string
	Upper  string
	Work   string
}

OverlayMount represents the parameters of overlay mount.

type PrjQuota

type PrjQuota struct {
	// contains filtered or unexported fields
}

PrjQuota represents project quota.

func (*PrjQuota) CheckMountpoint

func (quota *PrjQuota) CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point. cat /proc/mounts as follows: /dev/sda3 / ext4 rw,relatime,data=ordered 0 0 /dev/sda2 /boot/grub2 ext4 rw,relatime,stripe=4,data=ordered 0 0 /dev/sda5 /home ext4 rw,relatime,data=ordered 0 0 /dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/cpuset,cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu,cpuset 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0

func (*PrjQuota) GetFileAttr

func (quota *PrjQuota) GetFileAttr(dir string) uint32

GetFileAttr returns the directory attributes lsattr -p $dir

func (*PrjQuota) GetNextQuatoID

func (quota *PrjQuota) GetNextQuatoID() (uint32, error)

GetNextQuatoID returns the next available quota id.

func (*PrjQuota) SetDiskQuota

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

SetDiskQuota is used to set quota for directory.

func (*PrjQuota) SetFileAttr

func (quota *PrjQuota) SetFileAttr(dir string, id uint32) error

SetFileAttr is used to set file attributes.

func (*PrjQuota) SetFileAttrNoOutput

func (quota *PrjQuota) SetFileAttrNoOutput(dir string, id uint32)

SetFileAttrNoOutput is used to set file attributes without error.

func (*PrjQuota) SetSubtree

func (quota *PrjQuota) SetSubtree(dir string, qid uint32) (uint32, error)

SetSubtree is used to set quota id for directory, chattr -p qid +P $QUOTAID

func (*PrjQuota) StartQuotaDriver

func (quota *PrjQuota) StartQuotaDriver(dir string) (string, error)

StartQuotaDriver is used to start quota driver.

type RegExp

type RegExp struct {
	Pattern *regexp.Regexp
	Path    string
	Size    string
}

RegExp defines the regular expression of disk quota.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL