-
Notifications
You must be signed in to change notification settings - Fork 2
/
quota.c
652 lines (603 loc) · 18 KB
/
quota.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/*
* Copyright (c) 1991, 1992 Paul Kranenburg <[email protected]>
* Copyright (c) 1993 Branko Lankester <[email protected]>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <[email protected]>
* Copyright (c) 1996-1999 Wichert Akkerman <[email protected]>
* Copyright (c) 2005, 2006 Dmitry V. Levin <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#define SUBCMDMASK 0x00ff
#define SUBCMDSHIFT 8
#define QCMD_CMD(cmd) ((u_int32_t)(cmd) >> SUBCMDSHIFT)
#define QCMD_TYPE(cmd) ((u_int32_t)(cmd) & SUBCMDMASK)
#define OLD_CMD(cmd) ((u_int32_t)(cmd) << 8)
#define NEW_CMD(cmd) ((u_int32_t)(cmd) | 0x800000)
#define XQM_CMD(cmd) ((u_int32_t)(cmd) | ('X'<<8))
#define Q_V1_QUOTAON OLD_CMD(0x1)
#define Q_V1_QUOTAOFF OLD_CMD(0x2)
#define Q_V1_GETQUOTA OLD_CMD(0x3)
#define Q_V1_SETQUOTA OLD_CMD(0x4)
#define Q_V1_SETUSE OLD_CMD(0x5)
#define Q_V1_SYNC OLD_CMD(0x6)
#define Q_SETQLIM OLD_CMD(0x7)
#define Q_V1_GETSTATS OLD_CMD(0x8)
#define Q_V1_RSQUASH OLD_CMD(0x10)
#define Q_V2_GETQUOTA OLD_CMD(0xD)
#define Q_V2_SETQUOTA OLD_CMD(0xE)
#define Q_V2_SETUSE OLD_CMD(0xF)
#define Q_V2_GETINFO OLD_CMD(0x9)
#define Q_V2_SETINFO OLD_CMD(0xA)
#define Q_V2_SETGRACE OLD_CMD(0xB)
#define Q_V2_SETFLAGS OLD_CMD(0xC)
#define Q_V2_GETSTATS OLD_CMD(0x11)
#define Q_SYNC NEW_CMD(0x1)
#define Q_QUOTAON NEW_CMD(0x2)
#define Q_QUOTAOFF NEW_CMD(0x3)
#define Q_GETFMT NEW_CMD(0x4)
#define Q_GETINFO NEW_CMD(0x5)
#define Q_SETINFO NEW_CMD(0x6)
#define Q_GETQUOTA NEW_CMD(0x7)
#define Q_SETQUOTA NEW_CMD(0x8)
#define Q_XQUOTAON XQM_CMD(0x1)
#define Q_XQUOTAOFF XQM_CMD(0x2)
#define Q_XGETQUOTA XQM_CMD(0x3)
#define Q_XSETQLIM XQM_CMD(0x4)
#define Q_XGETQSTAT XQM_CMD(0x5)
#define Q_XQUOTARM XQM_CMD(0x6)
#define Q_XQUOTASYNC XQM_CMD(0x7)
static const struct xlat quotacmds[] = {
{Q_V1_QUOTAON, "Q_V1_QUOTAON"},
{Q_V1_QUOTAOFF, "Q_V1_QUOTAOFF"},
{Q_V1_GETQUOTA, "Q_V1_GETQUOTA"},
{Q_V1_SETQUOTA, "Q_V1_SETQUOTA"},
{Q_V1_SETUSE, "Q_V1_SETUSE"},
{Q_V1_SYNC, "Q_V1_SYNC"},
{Q_SETQLIM, "Q_SETQLIM"},
{Q_V1_GETSTATS, "Q_V1_GETSTATS"},
{Q_V1_RSQUASH, "Q_V1_RSQUASH"},
{Q_V2_GETQUOTA, "Q_V2_GETQUOTA"},
{Q_V2_SETQUOTA, "Q_V2_SETQUOTA"},
{Q_V2_SETUSE, "Q_V2_SETUSE"},
{Q_V2_GETINFO, "Q_V2_GETINFO"},
{Q_V2_SETINFO, "Q_V2_SETINFO"},
{Q_V2_SETGRACE, "Q_V2_SETGRACE"},
{Q_V2_SETFLAGS, "Q_V2_SETFLAGS"},
{Q_V2_GETSTATS, "Q_V2_GETSTATS"},
{Q_SYNC, "Q_SYNC"},
{Q_QUOTAON, "Q_QUOTAON"},
{Q_QUOTAOFF, "Q_QUOTAOFF"},
{Q_GETFMT, "Q_GETFMT"},
{Q_GETINFO, "Q_GETINFO"},
{Q_SETINFO, "Q_SETINFO"},
{Q_GETQUOTA, "Q_GETQUOTA"},
{Q_SETQUOTA, "Q_SETQUOTA"},
{Q_XQUOTAON, "Q_XQUOTAON"},
{Q_XQUOTAOFF, "Q_XQUOTAOFF"},
{Q_XGETQUOTA, "Q_XGETQUOTA"},
{Q_XSETQLIM, "Q_XSETQLIM"},
{Q_XGETQSTAT, "Q_XGETQSTAT"},
{Q_XQUOTARM, "Q_XQUOTARM"},
{Q_XQUOTASYNC, "Q_XQUOTASYNC"},
{0, NULL},
};
#define USRQUOTA 0
#define GRPQUOTA 1
static const struct xlat quotatypes[] = {
{USRQUOTA, "USRQUOTA"},
{GRPQUOTA, "GRPQUOTA"},
{0, NULL},
};
/* Quota format identifiers */
#define QFMT_VFS_OLD 1
#define QFMT_VFS_V0 2
static const struct xlat quota_formats[] = {
{QFMT_VFS_OLD, "QFMT_VFS_OLD"},
{QFMT_VFS_V0, "QFMT_VFS_V0"},
{0, NULL},
};
#define XFS_QUOTA_UDQ_ACCT (1<<0) /* user quota accounting */
#define XFS_QUOTA_UDQ_ENFD (1<<1) /* user quota limits enforcement */
#define XFS_QUOTA_GDQ_ACCT (1<<2) /* group quota accounting */
#define XFS_QUOTA_GDQ_ENFD (1<<3) /* group quota limits enforcement */
#define XFS_USER_QUOTA (1<<0) /* user quota type */
#define XFS_PROJ_QUOTA (1<<1) /* (IRIX) project quota type */
#define XFS_GROUP_QUOTA (1<<2) /* group quota type */
static const struct xlat xfs_quota_flags[] = {
{XFS_QUOTA_UDQ_ACCT, "XFS_QUOTA_UDQ_ACCT"},
{XFS_QUOTA_UDQ_ENFD, "XFS_QUOTA_UDQ_ENFD"},
{XFS_QUOTA_GDQ_ACCT, "XFS_QUOTA_GDQ_ACCT"},
{XFS_QUOTA_GDQ_ENFD, "XFS_QUOTA_GDQ_ENFD"},
{0, NULL}
};
static const struct xlat xfs_dqblk_flags[] = {
{XFS_USER_QUOTA, "XFS_USER_QUOTA"},
{XFS_PROJ_QUOTA, "XFS_PROJ_QUOTA"},
{XFS_GROUP_QUOTA, "XFS_GROUP_QUOTA"},
{0, NULL}
};
/*
* Following flags are used to specify which fields are valid
*/
#define QIF_BLIMITS 1
#define QIF_SPACE 2
#define QIF_ILIMITS 4
#define QIF_INODES 8
#define QIF_BTIME 16
#define QIF_ITIME 32
static const struct xlat if_dqblk_valid[] = {
{QIF_BLIMITS, "QIF_BLIMITS"},
{QIF_SPACE, "QIF_SPACE"},
{QIF_ILIMITS, "QIF_ILIMITS"},
{QIF_INODES, "QIF_INODES"},
{QIF_BTIME, "QIF_BTIME"},
{QIF_ITIME, "QIF_ITIME"},
{0, NULL}
};
struct if_dqblk
{
u_int64_t dqb_bhardlimit;
u_int64_t dqb_bsoftlimit;
u_int64_t dqb_curspace;
u_int64_t dqb_ihardlimit;
u_int64_t dqb_isoftlimit;
u_int64_t dqb_curinodes;
u_int64_t dqb_btime;
u_int64_t dqb_itime;
u_int32_t dqb_valid;
};
struct v1_dqblk
{
u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
u_int32_t dqb_bsoftlimit; /* preferred limit on disk blks */
u_int32_t dqb_curblocks; /* current block count */
u_int32_t dqb_ihardlimit; /* maximum # allocated inodes */
u_int32_t dqb_isoftlimit; /* preferred inode limit */
u_int32_t dqb_curinodes; /* current # allocated inodes */
time_t dqb_btime; /* time limit for excessive disk use */
time_t dqb_itime; /* time limit for excessive files */
};
struct v2_dqblk
{
unsigned int dqb_ihardlimit;
unsigned int dqb_isoftlimit;
unsigned int dqb_curinodes;
unsigned int dqb_bhardlimit;
unsigned int dqb_bsoftlimit;
u_int64_t dqb_curspace;
time_t dqb_btime;
time_t dqb_itime;
};
struct xfs_dqblk
{
int8_t d_version; /* version of this structure */
int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
u_int16_t d_fieldmask; /* field specifier */
u_int32_t d_id; /* user, project, or group ID */
u_int64_t d_blk_hardlimit; /* absolute limit on disk blks */
u_int64_t d_blk_softlimit; /* preferred limit on disk blks */
u_int64_t d_ino_hardlimit; /* maximum # allocated inodes */
u_int64_t d_ino_softlimit; /* preferred inode limit */
u_int64_t d_bcount; /* # disk blocks owned by the user */
u_int64_t d_icount; /* # inodes owned by the user */
int32_t d_itimer; /* zero if within inode limits */
int32_t d_btimer; /* similar to above; for disk blocks */
u_int16_t d_iwarns; /* # warnings issued wrt num inodes */
u_int16_t d_bwarns; /* # warnings issued wrt disk blocks */
int32_t d_padding2; /* padding2 - for future use */
u_int64_t d_rtb_hardlimit; /* absolute limit on realtime blks */
u_int64_t d_rtb_softlimit; /* preferred limit on RT disk blks */
u_int64_t d_rtbcount; /* # realtime blocks owned */
int32_t d_rtbtimer; /* similar to above; for RT disk blks */
u_int16_t d_rtbwarns; /* # warnings issued wrt RT disk blks */
int16_t d_padding3; /* padding3 - for future use */
char d_padding4[8]; /* yet more padding */
};
/*
* Following flags are used to specify which fields are valid
*/
#define IIF_BGRACE 1
#define IIF_IGRACE 2
#define IIF_FLAGS 4
static const struct xlat if_dqinfo_valid[] = {
{IIF_BGRACE, "IIF_BGRACE"},
{IIF_IGRACE, "IIF_IGRACE"},
{IIF_FLAGS, "IIF_FLAGS"},
{0, NULL}
};
struct if_dqinfo
{
u_int64_t dqi_bgrace;
u_int64_t dqi_igrace;
u_int32_t dqi_flags;
u_int32_t dqi_valid;
};
struct v2_dqinfo
{
unsigned int dqi_bgrace;
unsigned int dqi_igrace;
unsigned int dqi_flags;
unsigned int dqi_blocks;
unsigned int dqi_free_blk;
unsigned int dqi_free_entry;
};
struct v1_dqstats
{
u_int32_t lookups;
u_int32_t drops;
u_int32_t reads;
u_int32_t writes;
u_int32_t cache_hits;
u_int32_t allocated_dquots;
u_int32_t free_dquots;
u_int32_t syncs;
};
struct v2_dqstats
{
u_int32_t lookups;
u_int32_t drops;
u_int32_t reads;
u_int32_t writes;
u_int32_t cache_hits;
u_int32_t allocated_dquots;
u_int32_t free_dquots;
u_int32_t syncs;
u_int32_t version;
};
typedef struct fs_qfilestat
{
u_int64_t qfs_ino; /* inode number */
u_int64_t qfs_nblks; /* number of BBs 512-byte-blks */
u_int32_t qfs_nextents; /* number of extents */
} fs_qfilestat_t;
struct xfs_dqstats
{
int8_t qs_version; /* version number for future changes */
u_int16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
int8_t qs_pad; /* unused */
fs_qfilestat_t qs_uquota; /* user quota storage information */
fs_qfilestat_t qs_gquota; /* group quota storage information */
u_int32_t qs_incoredqs; /* number of dquots incore */
int32_t qs_btimelimit; /* limit for blks timer */
int32_t qs_itimelimit; /* limit for inodes timer */
int32_t qs_rtbtimelimit; /* limit for rt blks timer */
u_int16_t qs_bwarnlimit; /* limit for num warnings */
u_int16_t qs_iwarnlimit; /* limit for num warnings */
};
static void
decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
switch (cmd) {
case Q_GETQUOTA:
case Q_SETQUOTA:
{
struct if_dqblk dq;
if (cmd == Q_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
if (!abbrev(tcp)) {
tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
tprints("valid=");
printflags(if_dqblk_valid,
dq.dqb_valid, "QIF_???");
tprints("}");
} else
tprints("...}");
break;
}
case Q_V1_GETQUOTA:
case Q_V1_SETQUOTA:
{
struct v1_dqblk dq;
if (cmd == Q_V1_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit);
tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
tprintf("curblocks=%u, ", dq.dqb_curblocks);
tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit);
tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
tprintf("curinodes=%u, ", dq.dqb_curinodes);
tprintf("btime=%lu, ", (long) dq.dqb_btime);
tprintf("itime=%lu}", (long) dq.dqb_itime);
break;
}
case Q_V2_GETQUOTA:
case Q_V2_SETQUOTA:
{
struct v2_dqblk dq;
if (cmd == Q_V2_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit);
tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
tprintf("curinodes=%u, ", dq.dqb_curinodes);
tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit);
tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
tprintf("btime=%lu, ", (long) dq.dqb_btime);
tprintf("itime=%lu}", (long) dq.dqb_itime);
break;
}
case Q_XGETQUOTA:
case Q_XSETQLIM:
{
struct xfs_dqblk dq;
if (cmd == Q_XGETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{version=%d, ", dq.d_version);
tprints("flags=");
printflags(xfs_dqblk_flags,
dq.d_flags, "XFS_???_QUOTA");
tprintf(", fieldmask=%#x, ", dq.d_fieldmask);
tprintf("id=%u, ", dq.d_id);
tprintf("blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit);
tprintf("blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit);
tprintf("ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit);
tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
tprintf("bcount=%" PRIu64 ", ", dq.d_bcount);
tprintf("icount=%" PRIu64 ", ", dq.d_icount);
if (!abbrev(tcp)) {
tprintf("itimer=%d, ", dq.d_itimer);
tprintf("btimer=%d, ", dq.d_btimer);
tprintf("iwarns=%u, ", dq.d_iwarns);
tprintf("bwarns=%u, ", dq.d_bwarns);
tprintf("rtbcount=%" PRIu64 ", ", dq.d_rtbcount);
tprintf("rtbtimer=%d, ", dq.d_rtbtimer);
tprintf("rtbwarns=%u}", dq.d_rtbwarns);
} else
tprints("...}");
break;
}
case Q_GETFMT:
{
u_int32_t fmt;
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &fmt) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprints("{");
printxval(quota_formats, fmt, "QFMT_VFS_???");
tprints("}");
break;
}
case Q_GETINFO:
case Q_SETINFO:
{
struct if_dqinfo dq;
if (cmd == Q_GETINFO && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
tprintf("igrace=%" PRIu64 ", ", dq.dqi_igrace);
tprintf("flags=%#x, ", dq.dqi_flags);
tprints("valid=");
printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???");
tprints("}");
break;
}
case Q_V2_GETINFO:
case Q_V2_SETINFO:
{
struct v2_dqinfo dq;
if (cmd == Q_V2_GETINFO && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{bgrace=%u, ", dq.dqi_bgrace);
tprintf("igrace=%u, ", dq.dqi_igrace);
tprintf("flags=%#x, ", dq.dqi_flags);
tprintf("blocks=%u, ", dq.dqi_blocks);
tprintf("free_blk=%u, ", dq.dqi_free_blk);
tprintf("free_entry=%u}", dq.dqi_free_entry);
break;
}
case Q_V1_GETSTATS:
{
struct v1_dqstats dq;
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{lookups=%u, ", dq.lookups);
tprintf("drops=%u, ", dq.drops);
tprintf("reads=%u, ", dq.reads);
tprintf("writes=%u, ", dq.writes);
tprintf("cache_hits=%u, ", dq.cache_hits);
tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
tprintf("free_dquots=%u, ", dq.free_dquots);
tprintf("syncs=%u}", dq.syncs);
break;
}
case Q_V2_GETSTATS:
{
struct v2_dqstats dq;
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{lookups=%u, ", dq.lookups);
tprintf("drops=%u, ", dq.drops);
tprintf("reads=%u, ", dq.reads);
tprintf("writes=%u, ", dq.writes);
tprintf("cache_hits=%u, ", dq.cache_hits);
tprintf("allocated_dquots=%u, ", dq.allocated_dquots);
tprintf("free_dquots=%u, ", dq.free_dquots);
tprintf("syncs=%u, ", dq.syncs);
tprintf("version=%u}", dq.version);
break;
}
case Q_XGETQSTAT:
{
struct xfs_dqstats dq;
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{version=%d, ", dq.qs_version);
if (abbrev(tcp)) {
tprints("...}");
break;
}
tprints("flags=");
printflags(xfs_quota_flags,
dq.qs_flags, "XFS_QUOTA_???");
tprintf(", incoredqs=%u, ", dq.qs_incoredqs);
tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents);
tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents);
tprintf("btimelimit=%d, ", dq.qs_btimelimit);
tprintf("itimelimit=%d, ", dq.qs_itimelimit);
tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit);
tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit);
break;
}
case Q_XQUOTAON:
{
u_int32_t flag;
if (umove(tcp, data, &flag) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprints("{");
printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
tprints("}");
break;
}
default:
tprintf("%#lx", data);
break;
}
}
int
sys_quotactl(struct tcb *tcp)
{
/*
* The Linux kernel only looks at the low 32 bits of command and id
* arguments, but on some 64-bit architectures (s390x) this word
* will have been sign-extended when we see it. The high 1 bits
* don't mean anything, so don't confuse the output with them.
*/
u_int32_t qcmd = tcp->u_arg[0];
u_int32_t cmd = QCMD_CMD(qcmd);
u_int32_t type = QCMD_TYPE(qcmd);
u_int32_t id = tcp->u_arg[2];
if (!verbose(tcp))
return printargs(tcp);
if (entering(tcp)) {
printxval(quotacmds, cmd, "Q_???");
tprints("|");
printxval(quotatypes, type, "???QUOTA");
tprints(", ");
printstr(tcp, tcp->u_arg[1], -1);
tprints(", ");
switch (cmd) {
case Q_V1_QUOTAON:
case Q_QUOTAON:
printxval(quota_formats, id, "QFMT_VFS_???");
break;
case Q_V1_GETQUOTA:
case Q_V2_GETQUOTA:
case Q_GETQUOTA:
case Q_V1_SETQUOTA:
case Q_V2_SETQUOTA:
case Q_V1_SETUSE:
case Q_V2_SETUSE:
case Q_SETQLIM:
case Q_SETQUOTA:
case Q_XGETQUOTA:
case Q_XSETQLIM:
tprintf("%u", id);
break;
default:
tprintf("%#lx", tcp->u_arg[2]);
break;
}
tprints(", ");
} else {
if (!tcp->u_arg[3])
tprints("NULL");
else
decode_cmd_data(tcp, cmd, tcp->u_arg[3]);
}
return 0;
}