 
         | October 2025 | ||||||
| Mo | Tu | We | Th | Fr | Sa | Su | 
| 29 | 30 | 1 | 2 | 3 | 4 | 5 | 
| 6 | 7 | 8 | 9 | 10 | 11 | 12 | 
| 13 | 14 | 15 | 16 | 17 | 18 | 19 | 
| 20 | 21 | 22 | 23 | 24 | 25 | 26 | 
| 27 | 28 | 29 | 30 | 31 | 1 | 2 | 
| 3 | 4 | 5 | 6 | 7 | 8 | 9 | 
#include <sys/quota.h> #include <xfs/xqm.h> int quotactl(int cmd, const char *special, int id, caddr_t addr);
The quota system can be used to set per-user and per-group limits on the amount of disk space used on a file system. For each user and/or group, a soft limit and a hard limit can be set for each file system. 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 one week (by default) at a time; after this time, 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, or GRPQUOTA, for group 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 file system 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 command below.
The subcmd value is one of the following:
/* 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 quota block
                                  count */
    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
                                  files */
    uint32_t dqb_valid;        /* bit mask of QIF_*
                                  constants */
};
/* Flags in dqb_valid that indicate which fields in
   dqblk structure are valid. */
#define QIF_BLIMITS   1
#define QIF_SPACE     2
#define QIF_ILIMITS   4
#define QIF_INODES    8
#define QIF_BTIME     16
#define QIF_ITIME     32
#define QIF_LIMITS    (QIF_BLIMITS | QIF_ILIMITS)
#define QIF_USAGE     (QIF_SPACE | QIF_INODES)
#define QIF_TIMES     (QIF_BTIME | QIF_ITIME)
#define QIF_ALL       (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
The
dqb_valid
field is a bit mask that is set to indicate the entries in the
dqblk
structure that are valid.
Currently, the kernel fills in all entries of the
dqblk
structure and marks them as valid in the
dqb_valid
field.
Unprivileged users may retrieve only their own quotas;
a privileged user
(CAP_SYS_ADMIN)
can retrieve the quotas of any user.
/* uint64_t is an unsigned 64-bit integer;
   uint32_t is an unsigned 32-bit integer */
struct dqinfo {         /* Defined since kernel 2.4.22 */
    uint64_t dqi_bgrace;    /* Time before block soft limit
                               becomes hard limit */
    uint64_t dqi_igrace;    /* Time before inode soft limit
                               becomes hard limit */
    uint32_t dqi_flags;     /* Flags for quotafile
                               (DQF_*) */
    uint32_t dqi_valid;
};
/* Bits for dqi_flags */
/* Quota format QFMT_VFS_OLD */
#define V1_DQF_RSQUASH  1   /* Root squash enabled */
/* Other quota formats have no dqi_flags bits defined */
/* Flags in dqi_valid that indicate which fields in
   dqinfo structure are valid. */
# define IIF_BGRACE     1
# define IIF_IGRACE     2
# define IIF_FLAGS      4
# define IIF_ALL        (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
The
dqi_valid
field in the
dqinfo
structure indicates the entries in the structure that are valid.
Currently, the kernel fills in all entries of the
dqinfo
structure and marks them all as valid in the
dqi_valid
field.
The
id
argument is ignored.
For XFS file systems making use of the XFS Quota Manager (XQM), the above commands are bypassed and the following commands are used:
There is no command equivalent to Q_SYNC for XFS since sync(1) writes quota information to disk (in addition to the other file system metadata that it writes out).
On success, quotactl() returns 0; on error -1 is returned, and errno is set to indicate the error.
If cmd is Q_SETQUOTA, quotactl() may also set errno to:
If cmd is Q_QUOTAON, quotactl() may also set errno to: