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 2016-07-17 "Linux" "Linux Programmer's Manual"
29 quotactl \- manipulate disk quotas
32 .B #include <sys/quota.h>
33 .B #include <xfs/xqm.h>
35 .BI "int quotactl(int " cmd ", const char *" special ", int " id \
40 The quota system can be used to set per-user and per-group limits on the
41 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 one week
47 (by default) at a time;
48 after this time, 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)"
73 value is described below.
77 argument is a pointer to a null-terminated string containing the pathname
78 of the (mounted) block special device for the filesystem being manipulated.
82 argument is the address of an optional, command-specific, data structure
83 that is copied in or out of the system.
86 is given with each command below.
90 value is one of the following:
93 Turn on quotas for a filesystem.
96 argument is the identification number of the quota format to be used.
97 Currently, there are three supported quota formats:
101 The original quota format.
104 The standard VFS v0 quota format, which can handle 32-bit UIDs and GIDs
105 and quota limits up to 2^42 bytes and 2^32 inodes.
108 A quota format that can handle 32-bit UIDs and GIDs
109 and quota limits of 2^64 bytes and 2^64 inodes.
114 argument points to the pathname of a file containing the quotas for
116 The quota file must exist; it is normally created with the
119 This operation requires privilege
120 .RB ( CAP_SYS_ADMIN ).
123 Turn off quotas for a filesystem.
128 arguments are ignored.
129 This operation requires privilege
130 .RB ( CAP_SYS_ADMIN ).
133 Get disk quota limits and current usage for user or group
137 argument is a pointer to a
145 /* uint64_t is an unsigned 64\-bit integer;
146 uint32_t is an unsigned 32\-bit integer */
148 struct dqblk { /* Definition since Linux 2.4.22 */
149 uint64_t dqb_bhardlimit; /* absolute limit on disk
150 quota blocks alloc */
151 uint64_t dqb_bsoftlimit; /* preferred limit on
153 uint64_t dqb_curspace; /* current occupied space
155 uint64_t dqb_ihardlimit; /* maximum number of
157 uint64_t dqb_isoftlimit; /* preferred inode limit */
158 uint64_t dqb_curinodes; /* current number of
160 uint64_t dqb_btime; /* time limit for excessive
162 uint64_t dqb_itime; /* time limit for excessive
164 uint32_t dqb_valid; /* bit mask of QIF_*
168 /* Flags in dqb_valid that indicate which fields in
169 dqblk structure are valid. */
171 #define QIF_BLIMITS 1
173 #define QIF_ILIMITS 4
177 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
178 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
179 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
180 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
186 field is a bit mask that is set to indicate the entries in the
188 structure that are valid.
189 Currently, the kernel fills in all entries of the
191 structure and marks them as valid in the
194 Unprivileged users may retrieve only their own quotas;
196 .RB ( CAP_SYS_ADMIN )
197 can retrieve the quotas of any user.
199 .BR Q_GETNEXTQUOTA " (since Linux 4.6)"
200 .\" commit 926132c0257a5a8d149a6a395cc3405e55420566
201 This operation is the same as
203 but it returns quota information for the next ID greater than or equal to
205 that has a quota set.
209 argument is a pointer to a
211 structure whose fields are as for the
213 except for the addition of a
215 field that is used to return the ID for which
216 quota information is being returned:
221 uint64_t dqb_bhardlimit;
222 uint64_t dqb_bsoftlimit;
223 uint64_t dqb_curspace;
224 uint64_t dqb_ihardlimit;
225 uint64_t dqb_isoftlimit;
226 uint64_t dqb_curinodes;
236 Set quota information for user or group
238 using the information supplied in the
240 structure pointed to by
246 structure indicates which entries in the structure have been set by the caller.
247 This operation supersedes the
251 operations in the previous quota interfaces.
252 This operation requires privilege
253 .RB ( CAP_SYS_ADMIN ).
255 .BR Q_GETINFO " (since Linux 2.4.22)"
256 Get information (like grace times) about quotafile.
259 argument should be a pointer to a
262 This structure is defined in
268 /* uint64_t is an unsigned 64\-bit integer;
269 uint32_t is an unsigned 32\-bit integer */
271 struct dqinfo { /* Defined since kernel 2.4.22 */
272 uint64_t dqi_bgrace; /* Time before block soft limit
273 becomes hard limit */
275 uint64_t dqi_igrace; /* Time before inode soft limit
276 becomes hard limit */
277 uint32_t dqi_flags; /* Flags for quotafile
282 /* Bits for dqi_flags */
284 /* Quota format QFMT_VFS_OLD */
286 #define V1_DQF_RSQUASH 1 /* Root squash enabled */
288 /* Other quota formats have no dqi_flags bits defined */
290 /* Flags in dqi_valid that indicate which fields in
291 dqinfo structure are valid. */
293 # define IIF_BGRACE 1
294 # define IIF_IGRACE 2
296 # define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
304 structure indicates the entries in the structure that are valid.
305 Currently, the kernel fills in all entries of the
307 structure and marks them all as valid in the
314 .BR Q_SETINFO " (since Linux 2.4.22)"
315 Set information about quotafile.
318 argument should be a pointer to a
325 structure indicates the entries in the structure
326 that have been set by the caller.
327 This operation supersedes the
331 operations in the previous quota interfaces.
335 This operation requires privilege
336 .RB ( CAP_SYS_ADMIN ).
338 .BR Q_GETFMT " (since Linux 2.4.22)"
339 Get quota format used on the specified filesystem.
342 argument should be a pointer to a 4-byte buffer
343 where the format number will be stored.
346 Update the on-disk copy of quota usages for a filesystem.
349 is NULL, then all filesystems with active quotas are sync'ed.
354 arguments are ignored.
356 .BR Q_GETSTATS " (supported up to Linux 2.4.21)"
357 Get statistics and other generic information about the quota subsystem.
360 argument should be a pointer to a
362 structure in which data should be stored.
363 This structure is defined in
369 arguments are ignored.
371 This operation is obsolete and was removed in Linux 2.4.22.
373 .I /proc/sys/fs/quota/
374 carry the information instead.
376 For XFS filesystems making use of the XFS Quota Manager (XQM),
377 the above commands are bypassed and the following commands are used:
380 Turn on quotas for an XFS filesystem.
381 XFS provides the ability to turn on/off quota limit enforcement
382 with quota accounting.
383 Therefore, XFS expects
385 to be a pointer to an
387 that contains either the flags
388 .B XFS_QUOTA_UDQ_ACCT
390 .B XFS_QUOTA_UDQ_ENFD
392 .B XFS_QUOTA_GDQ_ACCT
394 .B XFS_QUOTA_GDQ_ENFD
395 (for group quota), as defined in
397 This operation requires privilege
398 .RB ( CAP_SYS_ADMIN ).
401 Turn off quotas for an XFS filesystem.
404 XFS filesystems expect a pointer to an
406 that specifies whether quota accounting and/or limit enforcement need
408 This operation requires privilege
409 .RB ( CAP_SYS_ADMIN ).
412 Get disk quota limits and current usage for user
416 argument is a pointer to an
418 structure (defined in
420 Unprivileged users may retrieve only their own quotas;
422 .RB ( CAP_SYS_ADMIN )
423 may retrieve the quotas of any user.
425 .BR Q_XGETNEXTQUOTA " (since Linux 4.6)"
426 .\" commit 8b37524962b9c54423374717786198f5c0820a28
427 This operation is the same as
429 but it returns quota information for the next ID greater than or equal to
431 that has a quota set.
434 Set disk quota limits for user
438 argument is a pointer to an
440 structure (defined in
442 This operation requires privilege
443 .RB ( CAP_SYS_ADMIN ).
448 structure containing XFS filesystem-specific quota information.
449 This is useful for finding out how much space is used to store quota
450 information, and also to get quotaon/off status of a given local XFS
454 Free the disk space taken by disk quotas.
455 Quotas must have already been turned off.
457 There is no command equivalent to
461 writes quota information to disk (in addition to the other filesystem
462 metadata that it writes out).
467 returns 0; on error \-1
470 is set to indicate the error.
477 and the quota file pointed to by
479 exists, but is not a regular file or
480 is not on the filesystem pointed to by
489 had already been performed.
507 but the specified quota file is corrupted.
510 The file specified by
517 The kernel has not been compiled with the
523 is not a block device.
526 The caller lacked the required privilege
527 .RB ( CAP_SYS_ADMIN )
528 for the specified operation.
534 but the specified limits are out of the range allowed by the quota format.
537 No disk quota is found for the indicated user.
538 Quotas have not been turned on for this filesystem.
544 but the specified quota format was not found.
551 .BR Q_XGETNEXTQUOTA ,
552 but there is no ID greater than or equal to
554 that has an active quota.