Manpage of QUOTACTL

QUOTACTL

Section: Linux Programmer's Manual (2)
Updated: 2016-05-09
Index
 

NAME

quotactl - manipulate disk quotas  

SYNOPSIS

#include <sys/quota.h>#include <xfs/xqm.h>int quotactl(int cmd, const char *special, int id, caddr_t addr);
 

DESCRIPTION

The quota system can be used to set per-user and per-group 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 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 cmdargument indicates a command to be applied to the user or group ID specified in id. To initialize the cmdargument, use the QCMD(subcmd, type)macro. The typevalue is either USRQUOTA, for user quotas, or GRPQUOTA, for group quotas. The subcmdvalue is described below.

The specialargument is a pointer to a null-terminated string containing the pathname of the (mounted) block special device for the filesystem being manipulated.

The addrargument is the address of an optional, command-specific, data structure that is copied in or out of the system. The interpretation of addris given with each command below.

The subcmdvalue is one of the following:

Q_QUOTAON
Turn on quotas for a filesystem. The idargument 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 addrargument 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. This operation requires privilege (CAP_SYS_ADMIN).
Q_QUOTAOFF
Turn off quotas for a filesystem. The addrand idarguments are ignored. This operation requires privilege (CAP_SYS_ADMIN).
Q_GETQUOTA
Get disk quota limits and current usage for user or group id. The addrargument is a pointer to a dqblkstructure 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 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_validfield is a bit mask that is set to indicate the entries in the dqblkstructure that are valid. Currently, the kernel fills in all entries of the dqblkstructure and marks them as valid in the dqb_validfield. Unprivileged users may retrieve only their own quotas; a privileged user (CAP_SYS_ADMIN) can retrieve the quotas of any user.
Q_GETNEXTQUOTA (since Linux 4.6)
This operation is the same as Q_GETQUOTA, but it returns quota information for the next ID greater than or equal to idthat has a quota set.

The addrargument is a pointer to a nextdqblkstructure whose fields are as for the dqblk, except for the addition of a dqb_idfield that is used to return the ID for which quota information is being returned:

struct nextdqblk {
    uint64_t dqb_bhardlimit;
    uint64_t dqb_bsoftlimit;
    uint64_t dqb_curspace;
    uint64_t dqb_ihardlimit;
    uint64_t dqb_isoftlimit;
    uint64_t dqb_curinodes;
    uint64_t dqb_btime;
    uint64_t dqb_itime;
    uint32_t dqb_valid;
    uint32_t dqb_id;
};
Q_SETQUOTA
Set quota information for user or group id, using the information supplied in the dqblkstructure pointed to by addr. The dqb_validfield of the dqblkstructure indicates which entries in the structure have been set by the caller. This operation supersedes the Q_SETQLIMand Q_SETUSEoperations in the previous quota interfaces. This operation requires privilege (CAP_SYS_ADMIN).
Q_GETINFO (since Linux 2.4.22)
Get information (like grace times) about quotafile. The addrargument should be a pointer to a dqinfostructure. This structure is defined in <sys/quota.h>as follows:
/* 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_validfield in the dqinfostructure indicates the entries in the structure that are valid. Currently, the kernel fills in all entries of the dqinfostructure and marks them all as valid in the dqi_validfield. The idargument is ignored.
Q_SETINFO (since Linux 2.4.22)
Set information about quotafile. The addrargument should be a pointer to a dqinfostructure. The dqi_validfield of the dqinfostructure indicates the entries in the structure that have been set by the caller. This operation supersedes the Q_SETGRACEand Q_SETFLAGSoperations in the previous quota interfaces. The idargument is ignored. This operation requires privilege (CAP_SYS_ADMIN).
Q_GETFMT (since Linux 2.4.22)
Get quota format used on the specified filesystem. The addrargument should be a pointer to a 4-byte buffer where the format number will be stored.
Q_SYNC
Update the on-disk copy of quota usages for a filesystem. If specialis NULL, then all filesystems with active quotas are sync'ed. The addrand idarguments are ignored.
Q_GETSTATS (supported up to Linux 2.4.21)
Get statistics and other generic information about the quota subsystem. The addrargument should be a pointer to a dqstatsstructure in which data should be stored. This structure is defined in <sys/quota.h>. The specialand idarguments are ignored.

This operation is obsolete and was removed in Linux 2.4.22. Files in /proc/sys/fs/quota/carry the information instead.

For XFS filesystems making use of the XFS Quota Manager (XQM), the above commands are bypassed and the following commands are used:

Q_XQUOTAON
Turn on quotas for an XFS filesystem. XFS provides the ability to turn on/off quota limit enforcement with quota accounting. Therefore, XFS expects addrto be a pointer to an unsigned intthat contains either the flags XFS_QUOTA_UDQ_ACCTand/or XFS_QUOTA_UDQ_ENFD(for user quota), or XFS_QUOTA_GDQ_ACCTand/or XFS_QUOTA_GDQ_ENFD(for group quota), as defined in <xfs/xqm.h>. This operation requires privilege (CAP_SYS_ADMIN).
Q_XQUOTAOFF
Turn off quotas for an XFS filesystem. As with Q_QUOTAON, XFS filesystems expect a pointer to an unsigned intthat specifies whether quota accounting and/or limit enforcement need to be turned off. This operation requires privilege (CAP_SYS_ADMIN).
Q_XGETQUOTA
Get disk quota limits and current usage for user id. The addrargument is a pointer to an fs_disk_quotastructure (defined in <xfs/xqm.h>). Unprivileged users may retrieve only their own quotas; a privileged user (CAP_SYS_ADMIN) may retrieve the quotas of any user.
Q_XGETNEXTQUOTA (since Linux 4.6)
This operation is the same as Q_XGETQUOTA, but it returns quota information for the next ID greater than or equal to idthat has a quota set.
Q_XSETQLIM
Set disk quota limits for user id. The addrargument is a pointer to an fs_disk_quotastructure (defined in <xfs/xqm.h>). This operation requires privilege (CAP_SYS_ADMIN).
Q_XGETQSTAT
Returns an fs_quota_statstructure containing XFS filesystem-specific quota information. This is useful for finding out how much space is used to store quota information, and also to get quotaon/off status of a given local XFS filesystem.
Q_XQUOTARM
Free the disk space taken by disk quotas. Quotas must have already been turned off.

There is no command equivalent to Q_SYNCfor XFS since sync(1) writes quota information to disk (in addition to the other filesystem metadata that it writes out).  

RETURN VALUE

On success, quotactl() returns 0; on error -1 is returned, and errnois set to indicate the error.  

ERRORS

EACCES
cmdis Q_QUOTAON, and the quota file pointed to by addrexists, but is not a regular file or is not on the filesystem pointed to by special.
EBUSY
cmdis Q_QUOTAON, but another Q_QUOTAONhad already been performed.
EFAULT
addror specialis invalid.
EINVAL
cmdor typeis invalid.
EINVAL
cmdis Q_QUOTAON, but the specified quota file is corrupted.
ENOENT
The file specified by specialor addrdoes not exist.
ENOSYS
The kernel has not been compiled with the CONFIG_QUOTAoption.
ENOTBLK
specialis not a block device.
EPERM
The caller lacked the required privilege (CAP_SYS_ADMIN) for the specified operation.
ERANGE
cmdis Q_SETQUOTA, but the specified limits are out of the range allowed by the quota format.
ESRCH
No disk quota is found for the indicated user. Quotas have not been turned on for this filesystem.
ESRCH
cmdis Q_QUOTAON, but the specified quota format was not found.
ESRCH
cmdis Q_GETNEXTQUOTAor Q_XGETNEXTQUOTA, but there is no ID greater than or equal to idthat has an active quota.
 

SEE ALSO

quota(1), getrlimit(2), quotacheck(8), quotaon(8)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 22:27:41 GMT, June 20, 2016