Documentation ¶
Index ¶
- Constants
- Variables
- func CheckMountpoint(devID uint64) (string, bool, string)
- func CheckRegularFile(file string) (bool, error)
- func GetNextQuotaID() (uint32, error)
- func GetQuotaID(dir string) (uint32, error)
- func GetQuotaIDInFileAttr(dir string) uint32
- func IsSetQuotaID(id string) bool
- func SetDiskQuota(dir string, size string, quotaID uint32) error
- func SetFileAttrRecursive(dir string, quotaID uint32) error
- func SetQuotaDriver(name string)
- func SetRootfsDiskQuota(basefs, size string, quotaID uint32, update bool) (uint32, error)
- type BaseQuota
- type GrpQuotaDriver
- func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
- func (quota *GrpQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)
- func (quota *GrpQuotaDriver) GetNextQuotaID() (uint32, error)
- func (quota *GrpQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32
- func (quota *GrpQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error
- func (quota *GrpQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error
- func (quota *GrpQuotaDriver) SetQuotaIDInFileAttr(dir string, id uint32) error
- type MountInfo
- type OverlayMount
- type PrjQuotaDriver
- func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
- func (quota *PrjQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)
- func (quota *PrjQuotaDriver) GetNextQuotaID() (uint32, error)
- func (quota *PrjQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32
- func (quota *PrjQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error
- func (quota *PrjQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error
- func (quota *PrjQuotaDriver) SetQuotaIDInFileAttr(dir string, quotaID uint32) error
- type QMap
Constants ¶
const ( // QuotaMinID represents the minimize quota id. // The value is unit32(2^24). QuotaMinID = uint32(16777216) )
Variables ¶
var ( // GQuotaDriver represents global quota driver. GQuotaDriver = NewQuotaDriver("") )
Functions ¶
func CheckMountpoint ¶
CheckMountpoint is used to check mount point.
func CheckRegularFile ¶
CheckRegularFile is used to check the file is regular file or directory.
func GetNextQuotaID ¶
GetNextQuotaID returns the next available quota id.
func GetQuotaID ¶
GetQuotaID returns the quota id of directory, if no quota id, it will alloc the next available quota id.
func GetQuotaIDInFileAttr ¶
GetQuotaIDInFileAttr returns the directory attributes of quota ID.
func SetDiskQuota ¶
SetDiskQuota is used to set quota for directory.
func SetFileAttrRecursive ¶
SetFileAttrRecursive set the file attr by recursively.
func SetQuotaDriver ¶
func SetQuotaDriver(name string)
SetQuotaDriver is used to set global quota driver.
Types ¶
type BaseQuota ¶
type BaseQuota interface { // EnforceQuota is used to enforce disk quota effect on specified directory. EnforceQuota(dir string) (*MountInfo, 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. SetDiskQuota(dir string, size string, quotaID uint32) error // CheckMountpoint is used to check mount point. // It returns mointpoint, enable quota and filesystem type of the device. CheckMountpoint(devID uint64) (string, bool, string) // GetQuotaIDInFileAttr gets attributes of the file which is in the inode. // The returned result is quota ID. GetQuotaIDInFileAttr(dir string) uint32 // SetQuotaIDInFileAttr sets file attributes of quota ID for the input directory. // The input attributes is quota ID. SetQuotaIDInFileAttr(dir string, quotaID uint32) error // GetNextQuotaID gets next quota ID in global scope of host. GetNextQuotaID() (uint32, error) // SetFileAttrRecursive set the file attr by recursively. SetFileAttrRecursive(dir string, quotaID uint32) error }
BaseQuota defines the quota operation interface. It abstracts the common operation ways a quota driver should implement.
func NewQuotaDriver ¶
NewQuotaDriver returns a quota instance.
type GrpQuotaDriver ¶
type GrpQuotaDriver struct {
// contains filtered or unexported fields
}
GrpQuotaDriver represents group quota driver.
func (*GrpQuotaDriver) CheckMountpoint ¶
func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
CheckMountpoint is used to check mount point. It returns mointpoint, enable quota and filesystem type of the device.
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 (*GrpQuotaDriver) EnforceQuota ¶
func (quota *GrpQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)
EnforceQuota is used to enforce disk quota effect on specified directory.
func (*GrpQuotaDriver) GetNextQuotaID ¶
func (quota *GrpQuotaDriver) GetNextQuotaID() (uint32, error)
GetNextQuotaID returns the next available quota id.
func (*GrpQuotaDriver) GetQuotaIDInFileAttr ¶
func (quota *GrpQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32
GetQuotaIDInFileAttr returns quota ID in the directory attributes. getfattr -n system.subtree --only-values --absolute-names /
func (*GrpQuotaDriver) SetDiskQuota ¶
func (quota *GrpQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error
SetDiskQuota is used to set quota for directory.
func (*GrpQuotaDriver) SetFileAttrRecursive ¶
func (quota *GrpQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error
SetFileAttrRecursive set the file attr by recursively.
func (*GrpQuotaDriver) SetQuotaIDInFileAttr ¶
func (quota *GrpQuotaDriver) SetQuotaIDInFileAttr(dir string, id uint32) error
SetQuotaIDInFileAttr is used to set quota ID in file attributes.
type OverlayMount ¶
OverlayMount represents the parameters of overlay mount.
type PrjQuotaDriver ¶
type PrjQuotaDriver struct {
// contains filtered or unexported fields
}
PrjQuotaDriver represents project quota driver.
func (*PrjQuotaDriver) CheckMountpoint ¶
func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
CheckMountpoint is used to check mount point. It returns mointpoint, enable quota and filesystem type of the device.
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 (*PrjQuotaDriver) EnforceQuota ¶
func (quota *PrjQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)
EnforceQuota is used to enforce disk quota effect on specified directory. it returns the mountpoint and error.
func (*PrjQuotaDriver) GetNextQuotaID ¶
func (quota *PrjQuotaDriver) GetNextQuotaID() (uint32, 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) SetFileAttrRecursive ¶
func (quota *PrjQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error
SetFileAttrRecursive set the file attr by recursively.
func (*PrjQuotaDriver) SetQuotaIDInFileAttr ¶
func (quota *PrjQuotaDriver) SetQuotaIDInFileAttr(dir string, quotaID uint32) error
SetQuotaIDInFileAttr sets file attributes of quota ID for the input directory. The input attributes is quota ID.