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 2021-03-22 "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 \
39 The quota system can be used to set per-user, per-group, and per-project limits
40 on the amount of disk space used on a filesystem.
41 For each user and/or group,
42 a soft limit and a hard limit can be set for each filesystem.
43 The hard limit can't be exceeded.
44 The soft limit can be exceeded, but warnings will ensue.
45 Moreover, the user can't exceed the soft limit for more than grace period
46 duration (one week by default) at a time;
47 after this, the soft limit counts as a hard limit.
51 call manipulates disk quotas.
54 argument indicates a command to be applied to the user or
60 .IR "QCMD(subcmd, type)"
68 for group quotas, or (since Linux 4.1)
69 .\" 847aac644e92e5624f2c153bab409bf713d5ff9a
74 value is described below.
78 argument is a pointer to a null-terminated string containing the pathname
79 of the (mounted) block special device for the filesystem being manipulated.
83 argument is the address of an optional, command-specific, data structure
84 that is copied in or out of the system.
87 is given with each operation below.
91 value is one of the following operations:
94 Turn on quotas for a filesystem.
97 argument is the identification number of the quota format to be used.
98 Currently, there are three supported quota formats:
102 The original quota format.
105 The standard VFS v0 quota format, which can handle 32-bit UIDs and GIDs
106 and quota limits up to 2^42 bytes and 2^32 inodes.
109 A quota format that can handle 32-bit UIDs and GIDs
110 and quota limits of 2^64 bytes and 2^64 inodes.
115 argument points to the pathname of a file containing the quotas for
117 The quota file must exist; it is normally created with the
121 Quota information can be also stored in hidden system inodes
122 for ext4, XFS, and other filesystems if the filesystem is configured so.
123 In this case, there are no visible quota files and there is no need to
126 Quota information is always kept consistent by the filesystem and the
128 operation serves only to enable enforcement of quota limits.
129 The presence of hidden
130 system inodes with quota information is indicated by the
134 field returned by the
138 This operation requires privilege
139 .RB ( CAP_SYS_ADMIN ).
142 Turn off quotas for a filesystem.
147 arguments are ignored.
148 This operation requires privilege
149 .RB ( CAP_SYS_ADMIN ).
152 Get disk quota limits and current usage for user or group
156 argument is a pointer to a
164 /* uint64_t is an unsigned 64\-bit integer;
165 uint32_t is an unsigned 32\-bit integer */
167 struct dqblk { /* Definition since Linux 2.4.22 */
168 uint64_t dqb_bhardlimit; /* Absolute limit on disk
169 quota blocks alloc */
170 uint64_t dqb_bsoftlimit; /* Preferred limit on
172 uint64_t dqb_curspace; /* Current occupied space
174 uint64_t dqb_ihardlimit; /* Maximum number of
176 uint64_t dqb_isoftlimit; /* Preferred inode limit */
177 uint64_t dqb_curinodes; /* Current number of
179 uint64_t dqb_btime; /* Time limit for excessive
181 uint64_t dqb_itime; /* Time limit for excessive
183 uint32_t dqb_valid; /* Bit mask of QIF_*
187 /* Flags in dqb_valid that indicate which fields in
188 dqblk structure are valid. */
190 #define QIF_BLIMITS 1
192 #define QIF_ILIMITS 4
196 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
197 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
198 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
199 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
205 field is a bit mask that is set to indicate the entries in the
207 structure that are valid.
208 Currently, the kernel fills in all entries of the
210 structure and marks them as valid in the
213 Unprivileged users may retrieve only their own quotas;
215 .RB ( CAP_SYS_ADMIN )
216 can retrieve the quotas of any user.
218 .BR Q_GETNEXTQUOTA " (since Linux 4.6)"
219 .\" commit 926132c0257a5a8d149a6a395cc3405e55420566
220 This operation is the same as
222 but it returns quota information for the next ID greater than or equal to
224 that has a quota set.
228 argument is a pointer to a
230 structure whose fields are as for the
232 except for the addition of a
234 field that is used to return the ID for which
235 quota information is being returned:
240 uint64_t dqb_bhardlimit;
241 uint64_t dqb_bsoftlimit;
242 uint64_t dqb_curspace;
243 uint64_t dqb_ihardlimit;
244 uint64_t dqb_isoftlimit;
245 uint64_t dqb_curinodes;
255 Set quota information for user or group
257 using the information supplied in the
259 structure pointed to by
265 structure indicates which entries in the structure have been set by the caller.
266 This operation supersedes the
270 operations in the previous quota interfaces.
271 This operation requires privilege
272 .RB ( CAP_SYS_ADMIN ).
274 .BR Q_GETINFO " (since Linux 2.4.22)"
275 Get information (like grace times) about quotafile.
278 argument should be a pointer to a
281 This structure is defined in
287 /* uint64_t is an unsigned 64\-bit integer;
288 uint32_t is an unsigned 32\-bit integer */
290 struct dqinfo { /* Defined since kernel 2.4.22 */
291 uint64_t dqi_bgrace; /* Time before block soft limit
292 becomes hard limit */
293 uint64_t dqi_igrace; /* Time before inode soft limit
294 becomes hard limit */
295 uint32_t dqi_flags; /* Flags for quotafile
300 /* Bits for dqi_flags */
302 /* Quota format QFMT_VFS_OLD */
304 #define DQF_ROOT_SQUASH (1 << 0) /* Root squash enabled */
305 /* Before Linux v4.0, this had been defined
306 privately as V1_DQF_RSQUASH */
308 /* Quota format QFMT_VFS_V0 / QFMT_VFS_V1 */
310 #define DQF_SYS_FILE (1 << 16) /* Quota stored in
313 /* Flags in dqi_valid that indicate which fields in
314 dqinfo structure are valid. */
319 #define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
327 structure indicates the entries in the structure that are valid.
328 Currently, the kernel fills in all entries of the
330 structure and marks them all as valid in the
337 .BR Q_SETINFO " (since Linux 2.4.22)"
338 Set information about quotafile.
341 argument should be a pointer to a
348 structure indicates the entries in the structure
349 that have been set by the caller.
350 This operation supersedes the
354 operations in the previous quota interfaces.
358 This operation requires privilege
359 .RB ( CAP_SYS_ADMIN ).
361 .BR Q_GETFMT " (since Linux 2.4.22)"
362 Get quota format used on the specified filesystem.
365 argument should be a pointer to a 4-byte buffer
366 where the format number will be stored.
369 Update the on-disk copy of quota usages for a filesystem.
372 is NULL, then all filesystems with active quotas are sync'ed.
377 arguments are ignored.
379 .BR Q_GETSTATS " (supported up to Linux 2.4.21)"
380 Get statistics and other generic information about the quota subsystem.
383 argument should be a pointer to a
385 structure in which data should be stored.
386 This structure is defined in
392 arguments are ignored.
394 This operation is obsolete and was removed in Linux 2.4.22.
396 .I /proc/sys/fs/quota/
397 carry the information instead.
399 For XFS filesystems making use of the XFS Quota Manager (XQM),
400 the above operations are bypassed and the following operations are used:
403 Turn on quotas for an XFS filesystem.
404 XFS provides the ability to turn on/off quota limit enforcement
405 with quota accounting.
406 Therefore, XFS expects
408 to be a pointer to an
410 that contains a bitwise combination of the following flags (defined in
415 XFS_QUOTA_UDQ_ACCT /* User quota accounting */
416 XFS_QUOTA_UDQ_ENFD /* User quota limits enforcement */
417 XFS_QUOTA_GDQ_ACCT /* Group quota accounting */
418 XFS_QUOTA_GDQ_ENFD /* Group quota limits enforcement */
419 XFS_QUOTA_PDQ_ACCT /* Project quota accounting */
420 XFS_QUOTA_PDQ_ENFD /* Project quota limits enforcement */
424 This operation requires privilege
425 .RB ( CAP_SYS_ADMIN ).
431 Turn off quotas for an XFS filesystem.
434 XFS filesystems expect a pointer to an
436 that specifies whether quota accounting and/or limit enforcement need
437 to be turned off (using the same flags as for
440 This operation requires privilege
441 .RB ( CAP_SYS_ADMIN ).
447 Get disk quota limits and current usage for user
451 argument is a pointer to an
453 structure, which is defined in
459 /* All the blk units are in BBs (Basic Blocks) of
462 #define FS_DQUOT_VERSION 1 /* fs_disk_quota.d_version */
464 #define XFS_USER_QUOTA (1<<0) /* User quota type */
465 #define XFS_PROJ_QUOTA (1<<1) /* Project quota type */
466 #define XFS_GROUP_QUOTA (1<<2) /* Group quota type */
468 struct fs_disk_quota {
469 int8_t d_version; /* Version of this structure */
470 int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
471 uint16_t d_fieldmask; /* Field specifier */
472 uint32_t d_id; /* User, project, or group ID */
473 uint64_t d_blk_hardlimit; /* Absolute limit on
475 uint64_t d_blk_softlimit; /* Preferred limit on
477 uint64_t d_ino_hardlimit; /* Maximum # allocated
479 uint64_t d_ino_softlimit; /* Preferred inode limit */
480 uint64_t d_bcount; /* # disk blocks owned by
482 uint64_t d_icount; /* # inodes owned by the user */
483 int32_t d_itimer; /* Zero if within inode limits */
484 /* If not, we refuse service */
485 int32_t d_btimer; /* Similar to above; for
487 uint16_t d_iwarns; /* # warnings issued with
488 respect to # of inodes */
489 uint16_t d_bwarns; /* # warnings issued with
490 respect to disk blocks */
491 int32_t d_padding2; /* Padding \- for future use */
492 uint64_t d_rtb_hardlimit; /* Absolute limit on realtime
494 uint64_t d_rtb_softlimit; /* Preferred limit on RT
496 uint64_t d_rtbcount; /* # realtime blocks owned */
497 int32_t d_rtbtimer; /* Similar to above; for RT
499 uint16_t d_rtbwarns; /* # warnings issued with
500 respect to RT disk blocks */
501 int16_t d_padding3; /* Padding \- for future use */
502 char d_padding4[8]; /* Yet more padding */
507 Unprivileged users may retrieve only their own quotas;
509 .RB ( CAP_SYS_ADMIN )
510 may retrieve the quotas of any user.
512 .BR Q_XGETNEXTQUOTA " (since Linux 4.6)"
513 .\" commit 8b37524962b9c54423374717786198f5c0820a28
514 This operation is the same as
516 but it returns (in the
520 quota information for the next ID greater than or equal to
522 that has a quota set.
527 field, no separate structure type is needed (in contrast with
534 Set disk quota limits for user
538 argument is a pointer to an
541 This operation requires privilege
542 .RB ( CAP_SYS_ADMIN ).
545 Returns XFS filesystem-specific quota information in the
549 This is useful for finding out how much space is used to store quota
550 information, and also to get the quota on/off status of a given local XFS
554 structure itself is defined as follows:
558 #define FS_QSTAT_VERSION 1 /* fs_quota_stat.qs_version */
560 struct fs_qfilestat {
561 uint64_t qfs_ino; /* Inode number */
562 uint64_t qfs_nblks; /* Number of BBs
564 uint32_t qfs_nextents; /* Number of extents */
567 struct fs_quota_stat {
568 int8_t qs_version; /* Version number for
570 uint16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
571 int8_t qs_pad; /* Unused */
572 struct fs_qfilestat qs_uquota; /* User quota storage
574 struct fs_qfilestat qs_gquota; /* Group quota storage
576 uint32_t qs_incoredqs; /* Number of dquots in core */
577 int32_t qs_btimelimit; /* Limit for blocks timer */
578 int32_t qs_itimelimit; /* Limit for inodes timer */
579 int32_t qs_rtbtimelimit;/* Limit for RT
581 uint16_t qs_bwarnlimit; /* Limit for # of warnings */
582 uint16_t qs_iwarnlimit; /* Limit for # of warnings */
592 Returns XFS filesystem-specific quota information in the
596 This version of the operation uses a structure with proper versioning support,
597 along with appropriate layout (all fields are naturally aligned) and
598 padding to avoiding special compat handling;
599 it also provides the ability to get statistics regarding
600 the project quota file.
603 structure itself is defined as follows:
607 #define FS_QSTATV_VERSION1 1 /* fs_quota_statv.qs_version */
609 struct fs_qfilestatv {
610 uint64_t qfs_ino; /* Inode number */
611 uint64_t qfs_nblks; /* Number of BBs
613 uint32_t qfs_nextents; /* Number of extents */
614 uint32_t qfs_pad; /* Pad for 8\-byte alignment */
617 struct fs_quota_statv {
618 int8_t qs_version; /* Version for future
620 uint8_t qs_pad1; /* Pad for 16\-bit alignment */
621 uint16_t qs_flags; /* XFS_QUOTA_.* flags */
622 uint32_t qs_incoredqs; /* Number of dquots incore */
623 struct fs_qfilestatv qs_uquota; /* User quota
625 struct fs_qfilestatv qs_gquota; /* Group quota
627 struct fs_qfilestatv qs_pquota; /* Project quota
629 int32_t qs_btimelimit; /* Limit for blocks timer */
630 int32_t qs_itimelimit; /* Limit for inodes timer */
631 int32_t qs_rtbtimelimit; /* Limit for RT blocks
633 uint16_t qs_bwarnlimit; /* Limit for # of warnings */
634 uint16_t qs_iwarnlimit; /* Limit for # of warnings */
635 uint64_t qs_pad2[8]; /* For future proofing */
642 field of the structure should be filled with the version of the structure
643 supported by the callee (for now, only
646 The kernel will fill the structure in accordance with
652 .B Q_XQUOTARM " (since Linux 3.16)"
653 .\" 9da93f9b7cdf8ab28da6b364cdc1fafc8670b4dc
654 Free the disk space taken by disk quotas.
657 argument should be a pointer to an
659 value containing flags (the same as in
664 which identify what types of quota
666 (Note that the quota type passed in the
668 argument is ignored, but should remain valid in order to pass preliminary
669 quotactl syscall handler checks.)
671 Quotas must have already been turned off.
676 .BR Q_XQUOTASYNC " (since Linux 2.6.15; no-op since Linux 3.4)"
677 .\" Added in commit ee34807a65aa0c5911dc27682863afca780a003e
678 This operation was an XFS quota equivalent to
680 but it is no-op since Linux 3.4,
681 .\" 4b217ed9e30f94b6e8e5e262020ef0ceab6113af
684 writes quota information to disk now
685 (in addition to the other filesystem metadata that it writes out).
687 .IR special ", " id " and " addr
688 arguments are ignored.
692 returns 0; on error \-1
695 is set to indicate the error.
702 and the quota file pointed to by
704 exists, but is not a regular file or
705 is not on the filesystem pointed to by
714 had already been performed.
732 but the specified quota file is corrupted.
734 .BR EINVAL " (since Linux 5.5)"
735 .\" 3dd4d40b420846dd35869ccc8f8627feef2cff32
741 does not point to valid quota types.
744 The file specified by
751 The kernel has not been compiled with the
757 is not a block device.
760 The caller lacked the required privilege
761 .RB ( CAP_SYS_ADMIN )
762 for the specified operation.
768 but the specified limits are out of the range allowed by the quota format.
771 No disk quota is found for the indicated user.
772 Quotas have not been turned on for this filesystem.
778 but the specified quota format was not found.
785 .BR Q_XGETNEXTQUOTA ,
786 but there is no ID greater than or equal to
788 that has an active quota.
793 .IR <linux/dqblk_xfs.h> ,
794 taking into account that there are several naming discrepancies:
796 Quota enabling flags (of format
797 .BR XFS_QUOTA_[UGP]DQ_{ACCT,ENFD} )
798 are defined without a leading "X", as
799 .BR FS_QUOTA_[UGP]DQ_{ACCT,ENFD} .
802 .B XFS_{USER,GROUP,PROJ}_QUOTA
803 quota type flags, which are defined as
804 .BR FS_{USER,GROUP,PROJ}_QUOTA .
808 header file defines its own
813 constants for the available quota types, but their values are the same as for
814 constants without the