1QUOTACTL(2) Linux Programmer's Manual QUOTACTL(2)
2
3
4
6 quotactl - manipulate disk quotas
7
9 #include <sys/quota.h>
10 #include <xfs/xqm.h>
11
12 int quotactl(int cmd, const char *special, int id, caddr_t addr);
13
15 The quota system can be used to set per-user and per-group limits on
16 the amount of disk space used on a file system. For each user and/or
17 group, a soft limit and a hard limit can be set for each file system.
18 The hard limit can't be exceeded. The soft limit can be exceeded, but
19 warnings will ensue. Moreover, the user can't exceed the soft limit
20 for more than one week (by default) at a time; after this time, the
21 soft limit counts as a hard limit.
22
23 The quotactl() call manipulates disk quotas. The cmd argument indi‐
24 cates a command to be applied to the user or group ID specified in id.
25 To initialize the cmd argument, use the QCMD(subcmd, type) macro. The
26 type value is either USRQUOTA, for user quotas, or GRPQUOTA, for group
27 quotas. The subcmd value is described below.
28
29 The special argument is a pointer to a null-terminated string contain‐
30 ing the pathname of the (mounted) block special device for the file
31 system being manipulated.
32
33 The addr argument is the address of an optional, command-specific, data
34 structure that is copied in or out of the system. The interpretation
35 of addr is given with each command below.
36
37 The subcmd value is one of the following:
38
39 Q_QUOTAON
40 Turn on quotas for a file system. The id argument is the iden‐
41 tification number of the quota format to be used. Currently,
42 there are three supported quota formats:
43
44 QFMT_VFS_OLD The original quota format.
45
46 QFMT_VFS_V0 The standard VFS v0 quota format, which can handle
47 32-bit UIDs and GIDs and quota limits up to 2^42
48 bytes and 2^32 inodes.
49
50 QFMT_VFS_V1 A quota format that can handle 32-bit UIDs and
51 GIDs and quota limits of 2^64 bytes and 2^64
52 inodes.
53
54 The addr argument points to the pathname of a file containing
55 the quotas for the file system. The quota file must exist; it
56 is normally created with the quotacheck(8) program. This oper‐
57 ation requires privilege (CAP_SYS_ADMIN).
58
59 Q_QUOTAOFF
60 Turn off quotas for a file system. The addr and id arguments
61 are ignored. This operation requires privilege
62 (CAP_SYS_ADMIN).
63
64 Q_GETQUOTA
65 Get disk quota limits and current usage for user or group id.
66 The addr argument is a pointer to a dqblk structure defined in
67 <sys/quota.h> as follows:
68
69 /* uint64_t is an unsigned 64-bit integer;
70 uint32_t is an unsigned 32-bit integer */
71
72 struct dqblk { /* Definition since Linux 2.4.22 */
73 uint64_t dqb_bhardlimit; /* absolute limit on disk
74 quota blocks alloc */
75 uint64_t dqb_bsoftlimit; /* preferred limit on
76 disk quota blocks */
77 uint64_t dqb_curspace; /* current quota block
78 count */
79 uint64_t dqb_ihardlimit; /* maximum number of
80 allocated inodes */
81 uint64_t dqb_isoftlimit; /* preferred inode limit */
82 uint64_t dqb_curinodes; /* current number of
83 allocated inodes */
84 uint64_t dqb_btime; /* time limit for excessive
85 disk use */
86 uint64_t dqb_itime; /* time limit for excessive
87 files */
88 uint32_t dqb_valid; /* bit mask of QIF_*
89 constants */
90 };
91
92 /* Flags in dqb_valid that indicate which fields in
93 dqblk structure are valid. */
94
95 #define QIF_BLIMITS 1
96 #define QIF_SPACE 2
97 #define QIF_ILIMITS 4
98 #define QIF_INODES 8
99 #define QIF_BTIME 16
100 #define QIF_ITIME 32
101 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
102 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
103 #define QIF_TIMES (QIF_BTIME | QIF_ITIME)
104 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
105
106 The dqb_valid field is a bit mask that is set to indicate the
107 entries in the dqblk structure that are valid. Currently, the
108 kernel fills in all entries of the dqblk structure and marks
109 them as valid in the dqb_valid field. Unprivileged users may
110 retrieve only their own quotas; a privileged user
111 (CAP_SYS_ADMIN) can retrieve the quotas of any user.
112
113 Q_SETQUOTA
114 Set quota information for user or group id, using the informa‐
115 tion supplied in the dqblk structure pointed to by addr. The
116 dqb_valid field of the dqblk structure indicates which entries
117 in the structure have been set by the caller. This operation
118 supersedes the Q_SETQLIM and Q_SETUSE operations in the previ‐
119 ous quota interfaces. This operation requires privilege
120 (CAP_SYS_ADMIN).
121
122 Q_GETINFO
123 Get information (like grace times) about quotafile. The addr
124 argument should be a pointer to a dqinfo structure. This
125 structure is defined in <sys/quota.h> as follows:
126
127 /* uint64_t is an unsigned 64-bit integer;
128 uint32_t is an unsigned 32-bit integer */
129
130 struct dqinfo { /* Defined since kernel 2.4.22 */
131 uint64_t dqi_bgrace; /* Time before block soft limit
132 becomes hard limit */
133
134 uint64_t dqi_igrace; /* Time before inode soft limit
135 becomes hard limit */
136 uint32_t dqi_flags; /* Flags for quotafile
137 (DQF_*) */
138 uint32_t dqi_valid;
139 };
140
141 /* Bits for dqi_flags */
142
143 /* Quota format QFMT_VFS_OLD */
144
145 #define V1_DQF_RSQUASH 1 /* Root squash enabled */
146
147 /* Other quota formats have no dqi_flags bits defined */
148
149 /* Flags in dqi_valid that indicate which fields in
150 dqinfo structure are valid. */
151
152 # define IIF_BGRACE 1
153 # define IIF_IGRACE 2
154 # define IIF_FLAGS 4
155 # define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
156
157 The dqi_valid field in the dqinfo structure indicates the
158 entries in the structure that are valid. Currently, the kernel
159 fills in all entries of the dqinfo structure and marks them all
160 as valid in the dqi_valid field. The id argument is ignored.
161
162 Q_SETINFO
163 Set information about quotafile. The addr argument should be a
164 pointer to a dqinfo structure. The dqi_valid field of the
165 dqinfo structure indicates the entries in the structure that
166 have been set by the caller. This operation supersedes the
167 Q_SETGRACE and Q_SETFLAGS operations in the previous quota
168 interfaces. The id argument is ignored. This operation
169 requires privilege (CAP_SYS_ADMIN).
170
171 Q_GETFMT
172 Get quota format used on the specified file system. The addr
173 argument should be a pointer to a 4-byte buffer where the for‐
174 mat number will be stored.
175
176 Q_SYNC Update the on-disk copy of quota usages for a file system. If
177 special is NULL, then all file systems with active quotas are
178 sync'ed. The addr and id arguments are ignored.
179
180 Q_GETSTATS
181 Get statistics and other generic information about the quota
182 subsystem. The addr argument should be a pointer to a dqstats
183 structure in which data should be stored. This structure is
184 defined in <sys/quota.h>. The special and id arguments are
185 ignored. This operation is obsolete and not supported by
186 recent kernels. Files in /proc/sys/fs/quota/ carry the infor‐
187 mation instead.
188
189 For XFS file systems making use of the XFS Quota Manager (XQM), the
190 above commands are bypassed and the following commands are used:
191
192 Q_XQUOTAON
193 Turn on quotas for an XFS file system. XFS provides the abil‐
194 ity to turn on/off quota limit enforcement with quota account‐
195 ing. Therefore, XFS expects addr to be a pointer to an
196 unsigned int that contains either the flags XFS_QUOTA_UDQ_ACCT
197 and/or XFS_QUOTA_UDQ_ENFD (for user quota), or
198 XFS_QUOTA_GDQ_ACCT and/or XFS_QUOTA_GDQ_ENFD (for group quota),
199 as defined in <xfs/xqm.h>. This operation requires privilege
200 (CAP_SYS_ADMIN).
201
202 Q_XQUOTAOFF
203 Turn off quotas for an XFS file system. As with Q_QUOTAON, XFS
204 file systems expect a pointer to an unsigned int that specifies
205 whether quota accounting and/or limit enforcement need to be
206 turned off. This operation requires privilege (CAP_SYS_ADMIN).
207
208 Q_XGETQUOTA
209 Get disk quota limits and current usage for user id. The addr
210 argument is a pointer to an fs_disk_quota structure (defined in
211 <xfs/xqm.h>). Unprivileged users may retrieve only their own
212 quotas; a privileged user (CAP_SYS_ADMIN) may retrieve the quo‐
213 tas of any user.
214
215 Q_XSETQLIM
216 Set disk quota limits for user id. The addr argument is a
217 pointer to an fs_disk_quota structure (defined in <xfs/xqm.h>).
218 This operation requires privilege (CAP_SYS_ADMIN).
219
220 Q_XGETQSTAT
221 Returns an fs_quota_stat structure containing XFS file system
222 specific quota information. This is useful for finding out how
223 much space is used to store quota information, and also to get
224 quotaon/off status of a given local XFS file system.
225
226 Q_XQUOTARM
227 Free the disk space taken by disk quotas. Quotas must have
228 already been turned off.
229
230 There is no command equivalent to Q_SYNC for XFS since sync(1) writes
231 quota information to disk (in addition to the other file system meta‐
232 data that it writes out).
233
235 On success, quotactl() returns 0; on error -1 is returned, and errno is
236 set to indicate the error.
237
239 EFAULT addr or special is invalid.
240
241 EINVAL cmd or type is invalid.
242
243 ENOENT The file specified by special or addr does not exist.
244
245 ENOSYS The kernel has not been compiled with the CONFIG_QUOTA option.
246
247 ENOTBLK
248 special is not a block device.
249
250 EPERM The caller lacked the required privilege (CAP_SYS_ADMIN) for the
251 specified operation.
252
253 ESRCH No disk quota is found for the indicated user. Quotas have not
254 been turned on for this file system.
255
256 If cmd is Q_SETQUOTA, quotactl() may also set errno to:
257
258 ERANGE Specified limits are out of range allowed by quota format.
259
260 If cmd is Q_QUOTAON, quotactl() may also set errno to:
261
262 EACCES The quota file pointed to by addr exists, but is not a regular
263 file; or, the quota file pointed to by addr exists, but is not
264 on the file system pointed to by special.
265
266 EBUSY Q_QUOTAON attempted, but another Q_QUOTAON had already been per‐
267 formed.
268
269 EINVAL The quota file is corrupted.
270
271 ESRCH Specified quota format was not found.
272
274 quota(1), getrlimit(2), quotacheck(8), quotaon(8)
275
277 This page is part of release 3.53 of the Linux man-pages project. A
278 description of the project, and information about reporting bugs, can
279 be found at http://www.kernel.org/doc/man-pages/.
280
281
282
283Linux 2010-06-16 QUOTACTL(2)