1 .\" Copyright (c) 2010, Jan Kara
2 .\" A few pieces copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
3 .\" and copyright 2010 (c) Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of
11 .\" this manual under the conditions for verbatim copying, provided that
12 .\" the entire resulting derived work is distributed under the terms of
13 .\" a permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume
17 .\" no responsibility for errors or omissions, or for damages resulting
18 .\" from the use of the information contained herein. The author(s) may
19 .\" not have taken the same level of care in the production of this
20 .\" manual, which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .TH QUOTACTL 2 2017-09-15 "Linux" "Linux Programmer's Manual"
29 quotactl \- manipulate disk quotas
32 .B #include <sys/quota.h>
33 .B #include <xfs/xqm.h> /* for XFS quotas */
35 .BI "int quotactl(int " cmd ", const char *" special ", int " id \
40 The quota system can be used to set per-user, per-group, and per-project limits
41 on the amount of disk space used on a filesystem.
42 For each user and/or group,
43 a soft limit and a hard limit can be set for each filesystem.
44 The hard limit can't be exceeded.
45 The soft limit can be exceeded, but warnings will ensue.
46 Moreover, the user can't exceed the soft limit for more than grace period
47 duration (one week by default) at a time;
48 after this, the soft limit counts as a hard limit.
52 call manipulates disk quotas.
55 argument indicates a command to be applied to the user or
61 .IR "QCMD(subcmd, type)"
69 for group quotas, or (since Linux 4.1)
70 .\" 847aac644e92e5624f2c153bab409bf713d5ff9a
75 value is described below.
79 argument is a pointer to a null-terminated string containing the pathname
80 of the (mounted) block special device for the filesystem being manipulated.
84 argument is the address of an optional, command-specific, data structure
85 that is copied in or out of the system.
88 is given with each command below.
92 value is one of the following:
95 Turn on quotas for a filesystem.
98 argument is the identification number of the quota format to be used.
99 Currently, there are three supported quota formats:
103 The original quota format.
106 The standard VFS v0 quota format, which can handle 32-bit UIDs and GIDs
107 and quota limits up to 2^42 bytes and 2^32 inodes.
110 A quota format that can handle 32-bit UIDs and GIDs
111 and quota limits of 2^64 bytes and 2^64 inodes.
116 argument points to the pathname of a file containing the quotas for
118 The quota file must exist; it is normally created with the
121 This operation requires privilege
122 .RB ( CAP_SYS_ADMIN ).
125 Turn off quotas for a filesystem.
130 arguments are ignored.
131 This operation requires privilege
132 .RB ( CAP_SYS_ADMIN ).
135 Get disk quota limits and current usage for user or group
139 argument is a pointer to a
147 /* uint64_t is an unsigned 64\-bit integer;
148 uint32_t is an unsigned 32\-bit integer */
150 struct dqblk { /* Definition since Linux 2.4.22 */
151 uint64_t dqb_bhardlimit; /* Absolute limit on disk
152 quota blocks alloc */
153 uint64_t dqb_bsoftlimit; /* Preferred limit on
155 uint64_t dqb_curspace; /* Current occupied space
157 uint64_t dqb_ihardlimit; /* Maximum number of
159 uint64_t dqb_isoftlimit; /* Preferred inode limit */
160 uint64_t dqb_curinodes; /* Current number of
162 uint64_t dqb_btime; /* Time limit for excessive
164 uint64_t dqb_itime; /* Time limit for excessive
166 uint32_t dqb_valid; /* Bit mask of QIF_*
170 /* Flags in dqb_valid that indicate which fields in
171 dqblk structure are valid. */
173 #define QIF_BLIMITS 1
175 #define QIF_ILIMITS 4
179 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
180 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
181 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
182 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
188 field is a bit mask that is set to indicate the entries in the
190 structure that are valid.
191 Currently, the kernel fills in all entries of the
193 structure and marks them as valid in the
196 Unprivileged users may retrieve only their own quotas;
198 .RB ( CAP_SYS_ADMIN )
199 can retrieve the quotas of any user.
201 .BR Q_GETNEXTQUOTA " (since Linux 4.6)"
202 .\" commit 926132c0257a5a8d149a6a395cc3405e55420566
203 This operation is the same as
205 but it returns quota information for the next ID greater than or equal to
207 that has a quota set.
211 argument is a pointer to a
213 structure whose fields are as for the
215 except for the addition of a
217 field that is used to return the ID for which
218 quota information is being returned:
223 uint64_t dqb_bhardlimit;
224 uint64_t dqb_bsoftlimit;
225 uint64_t dqb_curspace;
226 uint64_t dqb_ihardlimit;
227 uint64_t dqb_isoftlimit;
228 uint64_t dqb_curinodes;
238 Set quota information for user or group
240 using the information supplied in the
242 structure pointed to by
248 structure indicates which entries in the structure have been set by the caller.
249 This operation supersedes the
253 operations in the previous quota interfaces.
254 This operation requires privilege
255 .RB ( CAP_SYS_ADMIN ).
257 .BR Q_GETINFO " (since Linux 2.4.22)"
258 Get information (like grace times) about quotafile.
261 argument should be a pointer to a
264 This structure is defined in
270 /* uint64_t is an unsigned 64\-bit integer;
271 uint32_t is an unsigned 32\-bit integer */
273 struct dqinfo { /* Defined since kernel 2.4.22 */
274 uint64_t dqi_bgrace; /* Time before block soft limit
275 becomes hard limit */
276 uint64_t dqi_igrace; /* Time before inode soft limit
277 becomes hard limit */
278 uint32_t dqi_flags; /* Flags for quotafile
283 /* Bits for dqi_flags */
285 /* Quota format QFMT_VFS_OLD */
287 #define DQF_ROOT_SQUASH (1 << 0) /* Root squash enabled */
288 /* Before Linux v4.0, this had been defined
289 privately as V1_DQF_RSQUASH */
291 /* Quota format QFMT_VFS_V0 / QFMT_VFS_V1 */
293 #define DQF_SYS_FILE (1 << 16) /* Quota stored in
296 /* Flags in dqi_valid that indicate which fields in
297 dqinfo structure are valid. */
302 #define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
310 structure indicates the entries in the structure that are valid.
311 Currently, the kernel fills in all entries of the
313 structure and marks them all as valid in the
320 .BR Q_SETINFO " (since Linux 2.4.22)"
321 Set information about quotafile.
324 argument should be a pointer to a
331 structure indicates the entries in the structure
332 that have been set by the caller.
333 This operation supersedes the
337 operations in the previous quota interfaces.
341 This operation requires privilege
342 .RB ( CAP_SYS_ADMIN ).
344 .BR Q_GETFMT " (since Linux 2.4.22)"
345 Get quota format used on the specified filesystem.
348 argument should be a pointer to a 4-byte buffer
349 where the format number will be stored.
352 Update the on-disk copy of quota usages for a filesystem.
355 is NULL, then all filesystems with active quotas are sync'ed.
360 arguments are ignored.
362 .BR Q_GETSTATS " (supported up to Linux 2.4.21)"
363 Get statistics and other generic information about the quota subsystem.
366 argument should be a pointer to a
368 structure in which data should be stored.
369 This structure is defined in
375 arguments are ignored.
377 This operation is obsolete and was removed in Linux 2.4.22.
379 .I /proc/sys/fs/quota/
380 carry the information instead.
382 For XFS filesystems making use of the XFS Quota Manager (XQM),
383 the above commands are bypassed and the following commands are used:
386 Turn on quotas for an XFS filesystem.
387 XFS provides the ability to turn on/off quota limit enforcement
388 with quota accounting.
389 Therefore, XFS expects
391 to be a pointer to an
393 that contains a combination of the following flags (defined in
398 #define XFS_QUOTA_UDQ_ACCT (1<<0) /* User quota
400 #define XFS_QUOTA_UDQ_ENFD (1<<1) /* User quota limits
402 #define XFS_QUOTA_GDQ_ACCT (1<<2) /* Group quota
404 #define XFS_QUOTA_GDQ_ENFD (1<<3) /* Group quota limits
406 #define XFS_QUOTA_PDQ_ACCT (1<<4) /* Project quota
408 #define XFS_QUOTA_PDQ_ENFD (1<<5) /* Project quota limits
413 This operation requires privilege
414 .RB ( CAP_SYS_ADMIN ).
420 Turn off quotas for an XFS filesystem.
423 XFS filesystems expect a pointer to an
425 that specifies whether quota accounting and/or limit enforcement need
426 to be turned off (using the same flags as for
429 This operation requires privilege
430 .RB ( CAP_SYS_ADMIN ).
436 Get disk quota limits and current usage for user
440 argument is a pointer to an
442 structure, which is defined in
448 /* All the blk units are in BBs (Basic Blocks) of
451 #define FS_DQUOT_VERSION 1 /* fs_disk_quota.d_version */
453 #define XFS_USER_QUOTA (1<<0) /* User quota type */
454 #define XFS_PROJ_QUOTA (1<<1) /* Project quota type */
455 #define XFS_GROUP_QUOTA (1<<2) /* Group quota type */
457 struct fs_disk_quota {
458 int8_t d_version; /* Version of this structure */
459 int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
460 uint16_t d_fieldmask; /* Field specifier */
461 uint32_t d_id; /* User, project, or group ID */
462 uint64_t d_blk_hardlimit; /* Absolute limit on
464 uint64_t d_blk_softlimit; /* Preferred limit on
466 uint64_t d_ino_hardlimit; /* Maximum # allocated
468 uint64_t d_ino_softlimit; /* Preferred inode limit */
469 uint64_t d_bcount; /* # disk blocks owned by
471 uint64_t d_icount; /* # inodes owned by the user */
472 int32_t d_itimer; /* Zero if within inode limits */
473 /* If not, we refuse service */
474 int32_t d_btimer; /* Similar to above; for
476 uint16_t d_iwarns; /* # warnings issued with
477 respect to # of inodes */
478 uint16_t d_bwarns; /* # warnings issued with
479 respect to disk blocks */
480 int32_t d_padding2; /* Padding - for future use */
481 uint64_t d_rtb_hardlimit; /* Absolute limit on realtime
483 uint64_t d_rtb_softlimit; /* Preferred limit on RT
485 uint64_t d_rtbcount; /* # realtime blocks owned */
486 int32_t d_rtbtimer; /* Similar to above; for RT
488 uint16_t d_rtbwarns; /* # warnings issued with
489 respect to RT disk blocks */
490 int16_t d_padding3; /* Padding - for future use */
491 char d_padding4[8]; /* Yet more padding */
496 Unprivileged users may retrieve only their own quotas;
498 .RB ( CAP_SYS_ADMIN )
499 may retrieve the quotas of any user.
501 .BR Q_XGETNEXTQUOTA " (since Linux 4.6)"
502 .\" commit 8b37524962b9c54423374717786198f5c0820a28
503 This operation is the same as
505 but it returns (in the
509 quota information for the next ID greater than or equal to
511 that has a quota set.
516 field, no separate structure type is needed (in contrast with
523 Set disk quota limits for user
527 argument is a pointer to an
530 This operation requires privilege
531 .RB ( CAP_SYS_ADMIN ).
534 Returns XFS filesystem-specific quota information in the
538 This is useful for finding out how much space is used to store quota
539 information, and also to get the quota on/off status of a given local XFS
543 structure itself is defined as follows:
547 #define FS_QSTAT_VERSION 1 /* fs_quota_stat.qs_version */
549 struct fs_qfilestat {
550 uint64_t qfs_ino; /* Inode number */
551 uint64_t qfs_nblks; /* Number of BBs
553 uint32_t qfs_nextents; /* Number of extents */
556 struct fs_quota_stat {
557 int8_t qs_version; /* Version number for
559 uint16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
560 int8_t qs_pad; /* Unused */
561 struct fs_qfilestat qs_uquota; /* User quota storage
563 struct fs_qfilestat qs_gquota; /* Group quota storage
565 uint32_t qs_incoredqs; /* Number of dquots in core */
566 int32_t qs_btimelimit; /* Limit for blocks timer */
567 int32_t qs_itimelimit; /* Limit for inodes timer */
568 int32_t qs_rtbtimelimit;/* Limit for RT
570 uint16_t qs_bwarnlimit; /* Limit for # of warnings */
571 uint16_t qs_iwarnlimit; /* Limit for # of warnings */
581 Returns XFS filesystem-specific quota information in the
585 This version of the command uses a structure with proper versioning support,
586 along with appropriate layout (all fields are naturally aligned) and
587 padding to avoiding special compat handling;
588 it also provides the ability to get statistics regarding
589 the project quota file.
592 structure itself is defined as follows:
596 #define FS_QSTATV_VERSION1 1 /* fs_quota_statv.qs_version */
598 struct fs_qfilestatv {
599 uint64_t qfs_ino; /* Inode number */
600 uint64_t qfs_nblks; /* Number of BBs
602 uint32_t qfs_nextents; /* Number of extents */
603 uint32_t qfs_pad; /* Pad for 8-byte alignment */
606 struct fs_quota_statv {
607 int8_t qs_version; /* Version for future
609 uint8_t qs_pad1; /* Pad for 16-bit alignment */
610 uint16_t qs_flags; /* XFS_QUOTA_.* flags */
611 uint32_t qs_incoredqs; /* Number of dquots incore */
612 struct fs_qfilestatv qs_uquota; /* User quota
614 struct fs_qfilestatv qs_gquota; /* Group quota
616 struct fs_qfilestatv qs_pquota; /* Project quota
618 int32_t qs_btimelimit; /* Limit for blocks timer */
619 int32_t qs_itimelimit; /* Limit for inodes timer */
620 int32_t qs_rtbtimelimit; /* Limit for RT blocks
622 uint16_t qs_bwarnlimit; /* Limit for # of warnings */
623 uint16_t qs_iwarnlimit; /* Limit for # of warnings */
624 uint64_t qs_pad2[8]; /* For future proofing */
631 field of the structure should be filled with the version of the structure
632 supported by the callee (for now, only
635 The kernel will fill the structure in accordance with
642 Free the disk space taken by disk quotas. The
644 argument should be a pointer to an
646 value containing flags (the same as in
650 structure) which identify what types of quota should be removed
651 (note that the quota type passed in the
653 argument is ignored, but should remain valid in order to pass preliminary
654 quotactl syscall handler checks).
656 Quotas must have already been turned off.
661 .BR Q_XQUOTASYNC " (since Linux 2.6.15; no-op since Linux 3.4)"
662 .\" Added in commit ee34807a65aa0c5911dc27682863afca780a003e
663 This command was an XFS quota equivalent to
665 but it is no-op since Linux 3.4,
666 .\" 4b217ed9e30f94b6e8e5e262020ef0ceab6113af
669 writes quota information to disk now
670 (in addition to the other filesystem metadata that it writes out).
672 .IR special ", " id " and " addr
673 arguments are ignored.
678 returns 0; on error \-1
681 is set to indicate the error.
688 and the quota file pointed to by
690 exists, but is not a regular file or
691 is not on the filesystem pointed to by
700 had already been performed.
718 but the specified quota file is corrupted.
721 The file specified by
728 The kernel has not been compiled with the
734 is not a block device.
737 The caller lacked the required privilege
738 .RB ( CAP_SYS_ADMIN )
739 for the specified operation.
745 but the specified limits are out of the range allowed by the quota format.
748 No disk quota is found for the indicated user.
749 Quotas have not been turned on for this filesystem.
755 but the specified quota format was not found.
762 .BR Q_XGETNEXTQUOTA ,
763 but there is no ID greater than or equal to
765 that has an active quota.
770 .IR <linux/dqblk_xfs.h> ,
771 taking into account that there are several naming discrepancies:
773 Quota enabling flags (of format
774 .BR XFS_QUOTA_[UGP]DQ_{ACCT,ENFD} )
775 are defined without a leading "X", as
776 .BR FS_QUOTA_[UGP]DQ_{ACCT,ENFD} .
779 .B XFS_{USER,GROUP,PROJ}_QUOTA
780 quota type flags, which are defined as
781 .BR FS_{USER,GROUP,PROJ}_QUOTA .
785 header file defines its own
790 constants for the available quota types, but their values are the same as for
791 constants without the