blob: 0a388b2a565893bf64353c44cf0b37fe61e2b989 [file] [log] [blame]
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Dmitry V. Levinc02fd612016-01-19 01:15:49 +00006 * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +00007 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000030 */
31
32#include "defs.h"
33
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000034#define SUBCMDMASK 0x00ff
35#define SUBCMDSHIFT 8
Dmitry V. Levin08941942016-01-16 22:50:09 +000036#define QCMD_CMD(cmd) ((uint32_t)(cmd) >> SUBCMDSHIFT)
37#define QCMD_TYPE(cmd) ((uint32_t)(cmd) & SUBCMDMASK)
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000038
Dmitry V. Levin08941942016-01-16 22:50:09 +000039#define OLD_CMD(cmd) ((uint32_t)(cmd) << SUBCMDSHIFT)
40#define NEW_CMD(cmd) ((uint32_t)(cmd) | 0x800000)
41#define XQM_CMD(cmd) ((uint32_t)(cmd) | ('X' << SUBCMDSHIFT))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000042
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000043#include "xlat/quotacmds.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000044#include "xlat/quotatypes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000045#include "xlat/quota_formats.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000046#include "xlat/xfs_quota_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000047#include "xlat/xfs_dqblk_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000048#include "xlat/if_dqblk_valid.h"
Dmitry V. Levin60d48922016-01-19 02:10:23 +000049#include "xlat/if_dqinfo_flags.h"
Dmitry V. Levin2105a972016-01-16 22:50:09 +000050#include "xlat/if_dqinfo_valid.h"
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000051
52struct if_dqblk
53{
Dmitry V. Levin08941942016-01-16 22:50:09 +000054 uint64_t dqb_bhardlimit;
55 uint64_t dqb_bsoftlimit;
56 uint64_t dqb_curspace;
57 uint64_t dqb_ihardlimit;
58 uint64_t dqb_isoftlimit;
59 uint64_t dqb_curinodes;
60 uint64_t dqb_btime;
61 uint64_t dqb_itime;
62 uint32_t dqb_valid;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000063};
64
Dmitry V. Levincca2e532016-03-29 01:15:24 +000065struct if_nextdqblk {
66 uint64_t dqb_bhardlimit;
67 uint64_t dqb_bsoftlimit;
68 uint64_t dqb_curspace;
69 uint64_t dqb_ihardlimit;
70 uint64_t dqb_isoftlimit;
71 uint64_t dqb_curinodes;
72 uint64_t dqb_btime;
73 uint64_t dqb_itime;
74 uint32_t dqb_valid;
75 uint32_t dqb_id;
76};
77
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000078struct v1_dqblk
79{
Dmitry V. Levin08941942016-01-16 22:50:09 +000080 uint32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
81 uint32_t dqb_bsoftlimit; /* preferred limit on disk blks */
82 uint32_t dqb_curblocks; /* current block count */
83 uint32_t dqb_ihardlimit; /* maximum # allocated inodes */
84 uint32_t dqb_isoftlimit; /* preferred inode limit */
85 uint32_t dqb_curinodes; /* current # allocated inodes */
86 time_t dqb_btime; /* time limit for excessive disk use */
87 time_t dqb_itime; /* time limit for excessive files */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000088};
89
90struct v2_dqblk
91{
92 unsigned int dqb_ihardlimit;
93 unsigned int dqb_isoftlimit;
94 unsigned int dqb_curinodes;
95 unsigned int dqb_bhardlimit;
96 unsigned int dqb_bsoftlimit;
Dmitry V. Levin08941942016-01-16 22:50:09 +000097 uint64_t dqb_curspace;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +000098 time_t dqb_btime;
99 time_t dqb_itime;
100};
101
102struct xfs_dqblk
103{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000104 int8_t d_version; /* version of this structure */
105 int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
106 uint16_t d_fieldmask; /* field specifier */
107 uint32_t d_id; /* user, project, or group ID */
108 uint64_t d_blk_hardlimit; /* absolute limit on disk blks */
109 uint64_t d_blk_softlimit; /* preferred limit on disk blks */
110 uint64_t d_ino_hardlimit; /* maximum # allocated inodes */
111 uint64_t d_ino_softlimit; /* preferred inode limit */
112 uint64_t d_bcount; /* # disk blocks owned by the user */
113 uint64_t d_icount; /* # inodes owned by the user */
114 int32_t d_itimer; /* zero if within inode limits */
115 int32_t d_btimer; /* similar to above; for disk blocks */
116 uint16_t d_iwarns; /* # warnings issued wrt num inodes */
117 uint16_t d_bwarns; /* # warnings issued wrt disk blocks */
118 int32_t d_padding2; /* padding2 - for future use */
119 uint64_t d_rtb_hardlimit; /* absolute limit on realtime blks */
120 uint64_t d_rtb_softlimit; /* preferred limit on RT disk blks */
121 uint64_t d_rtbcount; /* # realtime blocks owned */
122 int32_t d_rtbtimer; /* similar to above; for RT disk blks */
123 uint16_t d_rtbwarns; /* # warnings issued wrt RT disk blks */
124 int16_t d_padding3; /* padding3 - for future use */
125 char d_padding4[8]; /* yet more padding */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000126};
127
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000128struct if_dqinfo
129{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000130 uint64_t dqi_bgrace;
131 uint64_t dqi_igrace;
132 uint32_t dqi_flags;
133 uint32_t dqi_valid;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000134};
135
136struct v2_dqinfo
137{
138 unsigned int dqi_bgrace;
139 unsigned int dqi_igrace;
140 unsigned int dqi_flags;
141 unsigned int dqi_blocks;
142 unsigned int dqi_free_blk;
143 unsigned int dqi_free_entry;
144};
145
146struct v1_dqstats
147{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000148 uint32_t lookups;
149 uint32_t drops;
150 uint32_t reads;
151 uint32_t writes;
152 uint32_t cache_hits;
153 uint32_t allocated_dquots;
154 uint32_t free_dquots;
155 uint32_t syncs;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000156};
157
158struct v2_dqstats
159{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000160 uint32_t lookups;
161 uint32_t drops;
162 uint32_t reads;
163 uint32_t writes;
164 uint32_t cache_hits;
165 uint32_t allocated_dquots;
166 uint32_t free_dquots;
167 uint32_t syncs;
168 uint32_t version;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000169};
170
171typedef struct fs_qfilestat
172{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000173 uint64_t qfs_ino; /* inode number */
174 uint64_t qfs_nblks; /* number of BBs 512-byte-blks */
175 uint32_t qfs_nextents; /* number of extents */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000176} fs_qfilestat_t;
177
178struct xfs_dqstats
179{
Dmitry V. Levin08941942016-01-16 22:50:09 +0000180 int8_t qs_version; /* version number for future changes */
181 uint16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
182 int8_t qs_pad; /* unused */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000183 fs_qfilestat_t qs_uquota; /* user quota storage information */
184 fs_qfilestat_t qs_gquota; /* group quota storage information */
Dmitry V. Levin08941942016-01-16 22:50:09 +0000185 uint32_t qs_incoredqs; /* number of dquots incore */
186 int32_t qs_btimelimit; /* limit for blks timer */
187 int32_t qs_itimelimit; /* limit for inodes timer */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000188 int32_t qs_rtbtimelimit; /* limit for rt blks timer */
Dmitry V. Levin08941942016-01-16 22:50:09 +0000189 uint16_t qs_bwarnlimit; /* limit for num warnings */
190 uint16_t qs_iwarnlimit; /* limit for num warnings */
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000191};
192
Dmitry V. Levined227112016-01-19 21:48:59 +0000193struct fs_qfilestatv {
194 uint64_t qfs_ino, qfs_nblks;
195 uint32_t qfs_nextents, qfs_pad;
196};
197
198struct fs_quota_statv {
199 int8_t qs_version;
200 uint8_t qs_pad1;
201 uint16_t qs_flags;
202 uint32_t qs_incoredqs;
203 struct fs_qfilestatv qs_uquota;
204 struct fs_qfilestatv qs_gquota;
205 struct fs_qfilestatv qs_pquota;
206 int32_t qs_btimelimit;
207 int32_t qs_itimelimit;
208 int32_t qs_rtbtimelimit;
209 uint16_t qs_bwarnlimit;
210 uint16_t qs_iwarnlimit;
211 uint64_t qs_pad2[8];
212};
213
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000214static int
Dmitry V. Levin08941942016-01-16 22:50:09 +0000215decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000216{
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200217 switch (cmd) {
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000218 case Q_GETQUOTA:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000219 if (entering(tcp))
220 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000221 case Q_SETQUOTA:
222 {
223 struct if_dqblk dq;
224
Dmitry V. Levin05646232015-07-17 17:35:07 +0000225 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000226 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000227 tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
228 tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
229 tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
230 tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
231 tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
232 tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200233 if (!abbrev(tcp)) {
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000234 tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
235 tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200236 tprints("valid=");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000237 printflags(if_dqblk_valid,
238 dq.dqb_valid, "QIF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200239 tprints("}");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000240 } else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200241 tprints("...}");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000242 break;
243 }
Dmitry V. Levincca2e532016-03-29 01:15:24 +0000244 case Q_GETNEXTQUOTA:
245 {
246 struct if_nextdqblk dq;
247
248 if (entering(tcp))
249 return 0;
250 if (umove_or_printaddr(tcp, data, &dq))
251 break;
252 tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
253 tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
254 tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
255 tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
256 tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
257 tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
258 if (!abbrev(tcp)) {
259 tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
260 tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
261 tprints("valid=");
262 printflags(if_dqblk_valid,
263 dq.dqb_valid, "QIF_???");
264 tprintf(", id=%u}", dq.dqb_id);
265 } else
266 tprintf("id=%u, ...}", dq.dqb_id);
267 break;
268 }
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000269 case Q_V1_GETQUOTA:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000270 if (entering(tcp))
271 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000272 case Q_V1_SETQUOTA:
273 {
274 struct v1_dqblk dq;
275
Dmitry V. Levin05646232015-07-17 17:35:07 +0000276 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000277 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000278 tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit);
279 tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
280 tprintf("curblocks=%u, ", dq.dqb_curblocks);
281 tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit);
282 tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
283 tprintf("curinodes=%u, ", dq.dqb_curinodes);
H.J. Lu0b315b62012-02-03 10:16:03 -0800284 tprintf("btime=%lu, ", (long) dq.dqb_btime);
285 tprintf("itime=%lu}", (long) dq.dqb_itime);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000286 break;
287 }
288 case Q_V2_GETQUOTA:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000289 if (entering(tcp))
290 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000291 case Q_V2_SETQUOTA:
292 {
293 struct v2_dqblk dq;
294
Dmitry V. Levin05646232015-07-17 17:35:07 +0000295 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000296 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000297 tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit);
298 tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
299 tprintf("curinodes=%u, ", dq.dqb_curinodes);
300 tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit);
301 tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
302 tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
H.J. Lu0b315b62012-02-03 10:16:03 -0800303 tprintf("btime=%lu, ", (long) dq.dqb_btime);
304 tprintf("itime=%lu}", (long) dq.dqb_itime);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000305 break;
306 }
307 case Q_XGETQUOTA:
Dmitry V. Levincca2e532016-03-29 01:15:24 +0000308 case Q_XGETNEXTQUOTA:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000309 if (entering(tcp))
310 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000311 case Q_XSETQLIM:
312 {
313 struct xfs_dqblk dq;
314
Dmitry V. Levin05646232015-07-17 17:35:07 +0000315 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000316 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000317 tprintf("{version=%d, ", dq.d_version);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200318 tprints("flags=");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000319 printflags(xfs_dqblk_flags,
Dmitry V. Levinf77ca9c2016-05-16 22:28:31 +0000320 (uint8_t) dq.d_flags, "XFS_???_QUOTA");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000321 tprintf(", fieldmask=%#x, ", dq.d_fieldmask);
322 tprintf("id=%u, ", dq.d_id);
323 tprintf("blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit);
324 tprintf("blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit);
325 tprintf("ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit);
326 tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
327 tprintf("bcount=%" PRIu64 ", ", dq.d_bcount);
328 tprintf("icount=%" PRIu64 ", ", dq.d_icount);
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200329 if (!abbrev(tcp)) {
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000330 tprintf("itimer=%d, ", dq.d_itimer);
331 tprintf("btimer=%d, ", dq.d_btimer);
332 tprintf("iwarns=%u, ", dq.d_iwarns);
333 tprintf("bwarns=%u, ", dq.d_bwarns);
334 tprintf("rtbcount=%" PRIu64 ", ", dq.d_rtbcount);
335 tprintf("rtbtimer=%d, ", dq.d_rtbtimer);
336 tprintf("rtbwarns=%u}", dq.d_rtbwarns);
337 } else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200338 tprints("...}");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000339 break;
340 }
341 case Q_GETFMT:
342 {
Dmitry V. Levin08941942016-01-16 22:50:09 +0000343 uint32_t fmt;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000344
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000345 if (entering(tcp))
346 return 0;
Dmitry V. Levin05646232015-07-17 17:35:07 +0000347 if (umove_or_printaddr(tcp, data, &fmt))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000348 break;
Dmitry V. Levin6a9ac962016-01-18 21:34:42 +0000349 tprints("[");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000350 printxval(quota_formats, fmt, "QFMT_VFS_???");
Dmitry V. Levin6a9ac962016-01-18 21:34:42 +0000351 tprints("]");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000352 break;
353 }
354 case Q_GETINFO:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000355 if (entering(tcp))
356 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000357 case Q_SETINFO:
358 {
359 struct if_dqinfo dq;
360
Dmitry V. Levin05646232015-07-17 17:35:07 +0000361 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000362 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000363 tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
364 tprintf("igrace=%" PRIu64 ", ", dq.dqi_igrace);
Dmitry V. Levin60d48922016-01-19 02:10:23 +0000365 tprints("flags=");
366 printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
367 tprints(", valid=");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000368 printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200369 tprints("}");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000370 break;
371 }
372 case Q_V2_GETINFO:
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000373 if (entering(tcp))
374 return 0;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000375 case Q_V2_SETINFO:
376 {
377 struct v2_dqinfo dq;
378
Dmitry V. Levin05646232015-07-17 17:35:07 +0000379 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000380 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000381 tprintf("{bgrace=%u, ", dq.dqi_bgrace);
382 tprintf("igrace=%u, ", dq.dqi_igrace);
Dmitry V. Levin60d48922016-01-19 02:10:23 +0000383 tprints("flags=");
384 printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
385 tprintf(", blocks=%u, ", dq.dqi_blocks);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000386 tprintf("free_blk=%u, ", dq.dqi_free_blk);
387 tprintf("free_entry=%u}", dq.dqi_free_entry);
388 break;
389 }
390 case Q_V1_GETSTATS:
391 {
392 struct v1_dqstats dq;
393
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000394 if (entering(tcp))
395 return 0;
Dmitry V. Levin05646232015-07-17 17:35:07 +0000396 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000397 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000398 tprintf("{lookups=%u, ", dq.lookups);
399 tprintf("drops=%u, ", dq.drops);
400 tprintf("reads=%u, ", dq.reads);
401 tprintf("writes=%u, ", dq.writes);
402 tprintf("cache_hits=%u, ", dq.cache_hits);
403 tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
404 tprintf("free_dquots=%u, ", dq.free_dquots);
405 tprintf("syncs=%u}", dq.syncs);
406 break;
407 }
408 case Q_V2_GETSTATS:
409 {
410 struct v2_dqstats dq;
411
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000412 if (entering(tcp))
413 return 0;
Dmitry V. Levin05646232015-07-17 17:35:07 +0000414 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000415 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000416 tprintf("{lookups=%u, ", dq.lookups);
417 tprintf("drops=%u, ", dq.drops);
418 tprintf("reads=%u, ", dq.reads);
419 tprintf("writes=%u, ", dq.writes);
420 tprintf("cache_hits=%u, ", dq.cache_hits);
421 tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
422 tprintf("free_dquots=%u, ", dq.free_dquots);
423 tprintf("syncs=%u, ", dq.syncs);
424 tprintf("version=%u}", dq.version);
425 break;
426 }
427 case Q_XGETQSTAT:
428 {
429 struct xfs_dqstats dq;
430
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000431 if (entering(tcp))
432 return 0;
Dmitry V. Levin05646232015-07-17 17:35:07 +0000433 if (umove_or_printaddr(tcp, data, &dq))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000434 break;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000435 tprintf("{version=%d, ", dq.qs_version);
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200436 if (abbrev(tcp)) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200437 tprints("...}");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000438 break;
439 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200440 tprints("flags=");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000441 printflags(xfs_quota_flags,
442 dq.qs_flags, "XFS_QUOTA_???");
443 tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
444 tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
445 tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
446 tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
447 tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
448 tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
449 tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
450 tprintf("btimelimit=%d, ", dq.qs_btimelimit);
451 tprintf("itimelimit=%d, ", dq.qs_itimelimit);
452 tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
453 tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
454 tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
455 break;
456 }
Dmitry V. Levined227112016-01-19 21:48:59 +0000457 case Q_XGETQSTATV:
458 {
459 struct fs_quota_statv dq;
460
461 if (entering(tcp))
462 return 0;
463 if (umove_or_printaddr(tcp, data, &dq))
464 break;
465 tprintf("{version=%d, ", dq.qs_version);
466 if (abbrev(tcp)) {
467 tprints("...}");
468 break;
469 }
470 tprints("flags=");
471 printflags(xfs_quota_flags,
472 dq.qs_flags, "XFS_QUOTA_???");
473 tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
474 tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
475 tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
476 tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
477 tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
478 tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
479 tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
480 tprintf("p_ino=%" PRIu64 ", ", dq.qs_pquota.qfs_ino);
481 tprintf("p_nblks=%" PRIu64 ", ", dq.qs_pquota.qfs_nblks);
482 tprintf("p_nextents=%u, ", dq.qs_pquota.qfs_nextents);
483 tprintf("btimelimit=%d, ", dq.qs_btimelimit);
484 tprintf("itimelimit=%d, ", dq.qs_itimelimit);
485 tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
486 tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
487 tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
488 break;
489 }
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000490 case Q_XQUOTAON:
Dmitry V. Levin7ea48d62016-01-18 21:41:22 +0000491 case Q_XQUOTAOFF:
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000492 {
Dmitry V. Levin08941942016-01-16 22:50:09 +0000493 uint32_t flag;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000494
Dmitry V. Levin05646232015-07-17 17:35:07 +0000495 if (umove_or_printaddr(tcp, data, &flag))
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000496 break;
Dmitry V. Levin6a9ac962016-01-18 21:34:42 +0000497 tprints("[");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000498 printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
Dmitry V. Levin6a9ac962016-01-18 21:34:42 +0000499 tprints("]");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000500 break;
501 }
502 default:
Dmitry V. Levin05646232015-07-17 17:35:07 +0000503 printaddr(data);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000504 break;
505 }
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000506 return RVAL_DECODED;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000507}
508
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000509SYS_FUNC(quotactl)
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000510{
511 /*
512 * The Linux kernel only looks at the low 32 bits of command and id
513 * arguments, but on some 64-bit architectures (s390x) this word
514 * will have been sign-extended when we see it. The high 1 bits
515 * don't mean anything, so don't confuse the output with them.
516 */
Dmitry V. Levin08941942016-01-16 22:50:09 +0000517 uint32_t qcmd = tcp->u_arg[0];
518 uint32_t cmd = QCMD_CMD(qcmd);
519 uint32_t type = QCMD_TYPE(qcmd);
520 uint32_t id = tcp->u_arg[2];
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000521
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200522 if (entering(tcp)) {
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000523 printxval(quotacmds, cmd, "Q_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200524 tprints("|");
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000525 printxval(quotatypes, type, "???QUOTA");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200526 tprints(", ");
Dmitry V. Levin79439662012-10-26 23:43:13 +0000527 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200528 tprints(", ");
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200529 switch (cmd) {
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000530 case Q_QUOTAON:
Dmitry V. Levinb1769202016-01-18 21:53:54 +0000531 case Q_V1_QUOTAON:
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000532 printxval(quota_formats, id, "QFMT_VFS_???");
Dmitry V. Levinb1769202016-01-18 21:53:54 +0000533 tprints(", ");
534 printpath(tcp, tcp->u_arg[3]);
535 return RVAL_DECODED;
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000536 }
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000537 tprintf("%u, ", id);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000538 }
Dmitry V. Levinc02fd612016-01-19 01:15:49 +0000539 return decode_cmd_data(tcp, cmd, tcp->u_arg[3]);
Dmitry V. Levinef5c3d62006-10-16 00:26:47 +0000540}