quotactl (2) - Linux Manuals
quotactl: manipulate disk quotas
NAME
quotactl - manipulate disk quotas
SYNOPSIS
#include <sys/quota.h> #include <xfs/xqm.h> /* for XFS quotas */ int quotactl(int cmd, const char *special, int id, caddr_t addr);
DESCRIPTION
The quota system can be used to set per-user, per-group, and per-project limits on the amount of disk space used on a filesystem. For each user and/or group, a soft limit and a hard limit can be set for each filesystem. The hard limit can't be exceeded. The soft limit can be exceeded, but warnings will ensue. Moreover, the user can't exceed the soft limit for more than grace period duration (one week by default) at a time; after this, the soft limit counts as a hard limit.The quotactl() call manipulates disk quotas. The cmd argument indicates a command to be applied to the user or group ID specified in id. To initialize the cmd argument, use the QCMD(subcmd, type) macro. The type value is either USRQUOTA, for user quotas, GRPQUOTA, for group quotas, or (since Linux 4.1) PRJQUOTA, for project quotas. The subcmd value is described below.
The special argument is a pointer to a null-terminated string containing the pathname of the (mounted) block special device for the filesystem being manipulated.
The addr argument is the address of an optional, command-specific, data structure that is copied in or out of the system. The interpretation of addr is given with each operation below.
The subcmd value is one of the following operations:
- Q_QUOTAON
-
Turn on quotas for a filesystem.
The
id
argument is the identification number of the quota format to be used.
Currently, there are three supported quota formats:
-
- QFMT_VFS_OLD
- The original quota format.
- QFMT_VFS_V0
- The standard VFS v0 quota format, which can handle 32-bit UIDs and GIDs and quota limits up to 2^42 bytes and 2^32 inodes.
- QFMT_VFS_V1
- A quota format that can handle 32-bit UIDs and GIDs and quota limits of 2^64 bytes and 2^64 inodes.
-
- The addr argument points to the pathname of a file containing the quotas for the filesystem. The quota file must exist; it is normally created with the quotacheck(8) program
- Quota information can be also stored in hidden system inodes for ext4, XFS, and other filesystems if the filesystem is configured so. In this case, there are no visible quota files and there is no need to use quotacheck(8). Quota information is always kept consistent by the filesystem and the Q_QUOTAON operation serves only to enable enforcement of quota limits. The presence of hidden system inodes with quota information is indicated by the DQF_SYS_FILE flag in the dqi_flags field returned by the Q_GETINFO operation.
- This operation requires privilege (CAP_SYS_ADMIN).
- Q_QUOTAOFF
- Turn off quotas for a filesystem. The addr and id arguments are ignored. This operation requires privilege (CAP_SYS_ADMIN).
- Q_GETQUOTA
- Get disk quota limits and current usage for user or group id. The addr argument is a pointer to a dqblk structure defined in <sys/quota.h> as follows:
-
/* uint64_t is an unsigned 64-bit integer;
uint32_t is an unsigned 32-bit integer */ struct dqblk { /* Definition since Linux 2.4.22 */
uint64_t dqb_bhardlimit; /* Absolute limit on disk
quota blocks alloc */
uint64_t dqb_bsoftlimit; /* Preferred limit on
disk quota blocks */
uint64_t dqb_curspace; /* Current occupied space
(in bytes) */
uint64_t dqb_ihardlimit; /* Maximum number of
allocated inodes */
uint64_t dqb_isoftlimit; /* Preferred inode limit */
uint64_t dqb_curinodes; /* Current number of
allocated inodes */
uint64_t dqb_btime; /* Time limit for excessive
disk use */
uint64_t dqb_itime; /* Time limit for excessive