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 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of
10 .\" this manual under the conditions for verbatim copying, provided that
11 .\" the entire resulting derived work is distributed under the terms of
12 .\" a permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume.
16 .\" no responsibility for errors or omissions, or for damages resulting.
17 .\" from the use of the information contained herein. The author(s) may.
18 .\" not have taken the same level of care in the production of this.
19 .\" manual, which is licensed free of charge, as they might when working.
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH QUOTACTL 2 2010-06-16 "Linux" "Linux Programmer's Manual"
27 quotactl \- manipulate disk quotas
30 .B #include <sys/quota.h>
31 .B #include <xfs/xqm.h>
33 .BI "int quotactl(int " cmd ", const char *" special ", int " id \
38 The quota system can be used to set per-user and per-group limits on the
39 amount of disk space used on a file system.
40 For each user and/or group,
41 a soft limit and a hard limit can be set for each file system.
42 The hard limit can't be exceeded.
43 The soft limit can be exceeded, but warnings will ensue.
44 Moreover, the user can't exceed the soft limit for more than one week
45 (by default) at a time;
46 after this time, the soft limit counts as a hard limit.
50 call manipulates disk quotas.
53 argument indicates a command to be applied to the user or
59 .IR "QCMD(subcmd, type)"
71 value is described below.
75 argument is a pointer to a null-terminated string containing the pathname
76 of the (mounted) block special device for the file system being manipulated.
80 argument is the address of an optional, command-specific, data structure
81 that is copied in or out of the system.
84 is given with each command below.
88 value is one of the following:
91 Turn on quotas for a file system.
94 argument is the identification number of the quota format to be used.
95 Currently, there are three supported quota formats:
99 The original quota format.
102 The standard VFS v0 quota format, which can handle 32-bit UIDs and GIDs
103 and quota limits up to 2^42 bytes and 2^32 inodes.
106 A quota format that can handle 32-bit UIDs and GIDs
107 and quota limits of 2^64 bytes and 2^64 inodes.
112 argument points to the pathname of a file containing the quotas for
114 The quota file must exist; it is normally created with the
117 This operation requires privilege
118 .RB ( CAP_SYS_ADMIN ).
121 Turn off quotas for a file system.
126 arguments are ignored.
127 This operation requires privilege
128 .RB ( CAP_SYS_ADMIN ).
131 Get disk quota limits and current usage for user or group
135 argument is a pointer to a
143 /* uint64_t is an unsigned 64-bit integer;
144 uint32_t is an unsigned 32-bit integer */
146 struct dqblk { /* Definition since Linux 2.4.22 */
147 uint64_t dqb_bhardlimit; /* absolute limit on disk
148 quota blocks alloc */
149 uint64_t dqb_bsoftlimit; /* preferred limit on
151 uint64_t dqb_curspace; /* current quota block
153 uint64_t dqb_ihardlimit; /* maximum number of
155 uint64_t dqb_isoftlimit; /* preferred inode limit */
156 uint64_t dqb_curinodes; /* current number of
158 uint64_t dqb_btime; /* time limit for excessive
160 uint64_t dqb_itime; /* time limit for excessive
162 uint32_t dqb_valid; /* bit mask of QIF_*
166 /* Flags in dqb_valid that indicate which fields in
167 dqblk structure are valid. */
169 #define QIF_BLIMITS 1
171 #define QIF_ILIMITS 4
175 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
176 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
177 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
178 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
184 field is a bit mask that is set to indicate the entries in the
186 structure that are valid.
187 Currently, the kernel fills in all entries of the
189 structure and marks them as valid in the
192 Unprivileged users may retrieve only their own quotas;
194 .RB ( CAP_SYS_ADMIN )
195 can retrieve the quotas of any user.
198 Set quota information for user or group
200 using the information supplied in the
202 structure pointed to by
208 structure indicates which entries in the structure have been set by the caller.
209 This operation supersedes the
213 operations in the previous quota interfaces.
214 This operation requires privilege
215 .RB ( CAP_SYS_ADMIN ).
218 Get information (like grace times) about quotafile.
221 argument should be a pointer to a
224 This structure is defined in
230 /* uint64_t is an unsigned 64-bit integer;
231 uint32_t is an unsigned 32-bit integer */
233 struct dqinfo { /* Defined since kernel 2.4.22 */
234 uint64_t dqi_bgrace; /* Time before block soft limit
235 becomes hard limit */
237 uint64_t dqi_igrace; /* Time before inode soft limit
238 becomes hard limit */
239 uint32_t dqi_flags; /* Flags for quotafile
244 /* Bits for dqi_flags */
246 /* Quota format QFMT_VFS_OLD */
248 #define V1_DQF_RSQUASH 1 /* Root squash enabled */
250 /* Other quota formats have no dqi_flags bits defined */
252 /* Flags in dqi_valid that indicate which fields in
253 dqinfo structure are valid. */
255 # define IIF_BGRACE 1
256 # define IIF_IGRACE 2
258 # define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
266 structure indicates the entries in the structure that are valid.
267 Currently, the kernel fills in all entries of the
269 structure and marks them all as valid in the
277 Set information about quotafile.
280 argument should be a pointer to a
287 structure indicates the entries in the structure
288 that have been set by the caller.
289 This operation supersedes the
293 operations in the previous quota interfaces.
297 This operation requires privilege
298 .RB ( CAP_SYS_ADMIN ).
301 Get quota format used on the specified file system.
304 argument should be a pointer to a 4-byte buffer
305 where the format number will be stored.
308 Update the on-disk copy of quota usages for a file system.
311 is NULL, then all file systems with active quotas are sync'ed.
316 arguments are ignored.
319 Get statistics and other generic information about the quota subsystem.
322 argument should be a pointer to a
324 structure in which data should be stored.
325 This structure is defined in
331 arguments are ignored.
332 This operation is obsolete and not supported by recent kernels.
333 .\" Q_GETSTATS was removed in kernel 2.4.22.
335 .I /proc/sys/fs/quota/
336 carry the information instead.
338 For XFS file systems making use of the XFS Quota Manager (XQM),
339 the above commands are bypassed and the following commands are used:
342 Turn on quotas for an XFS file system.
343 XFS provides the ability to turn on/off quota limit enforcement
344 with quota accounting.
345 Therefore, XFS expects
347 to be a pointer to an
349 that contains either the flags
350 .B XFS_QUOTA_UDQ_ACCT
352 .B XFS_QUOTA_UDQ_ENFD
354 .B XFS_QUOTA_GDQ_ACCT
356 .B XFS_QUOTA_GDQ_ENFD
357 (for group quota), as defined in
359 This operation requires privilege
360 .RB ( CAP_SYS_ADMIN ).
363 Turn off quotas for an XFS file system.
366 XFS file systems expect a pointer to an
368 that specifies whether quota accounting and/or limit enforcement need
370 This operation requires privilege
371 .RB ( CAP_SYS_ADMIN ).
374 Get disk quota limits and current usage for user
378 argument is a pointer to an
380 structure (defined in
382 Unprivileged users may retrieve only their own quotas;
384 .RB ( CAP_SYS_ADMIN )
385 may retrieve the quotas of any user.
388 Set disk quota limits for user
392 argument is a pointer to an
394 structure (defined in
396 This operation requires privilege
397 .RB ( CAP_SYS_ADMIN ).
402 structure containing XFS file system specific quota information.
403 This is useful for finding out how much space is used to store quota
404 information, and also to get quotaon/off status of a given local XFS
408 Free the disk space taken by disk quotas.
409 Quotas must have already been turned off.
411 There is no command equivalent to
415 writes quota information to disk (in addition to the other file system
416 metadata that it writes out).
421 returns 0; on error \-1
424 is set to indicate the error.
440 The file specified by
447 The kernel has not been compiled with the
453 is not a block device.
456 The caller lacked the required privilege
457 .RB ( CAP_SYS_ADMIN )
458 for the specified operation.
461 No disk quota is found for the indicated user.
462 Quotas have not been turned on for this file system.
474 Specified limits are out of range allowed by quota format.
486 The quota file pointed to by
488 exists, but is not a regular file; or,
489 the quota file pointed to by
491 exists, but is not on the file system pointed to by
496 attempted, but another
498 had already been performed.
501 The quota file is corrupted.
504 Specified quota format was not found.