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>
6 * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
33 #include "print_fields.h"
35 #define SUBCMDMASK 0x00ff
37 #define QCMD_CMD(cmd) ((uint32_t)(cmd) >> SUBCMDSHIFT)
38 #define QCMD_TYPE(cmd) ((uint32_t)(cmd) & SUBCMDMASK)
40 #define OLD_CMD(cmd) ((uint32_t)(cmd) << SUBCMDSHIFT)
41 #define NEW_CMD(cmd) ((uint32_t)(cmd) | 0x800000)
42 #define XQM_CMD(cmd) ((uint32_t)(cmd) | ('X' << SUBCMDSHIFT))
44 #include "xlat/quotacmds.h"
45 #include "xlat/quotatypes.h"
46 #include "xlat/quota_formats.h"
47 #include "xlat/xfs_quota_flags.h"
48 #include "xlat/xfs_dqblk_flags.h"
49 #include "xlat/if_dqblk_valid.h"
50 #include "xlat/if_dqinfo_flags.h"
51 #include "xlat/if_dqinfo_valid.h"
54 * We add attribute packed due to the fact that the structure is 8-byte aligned
55 * on 64-bit systems and therefore has additional 4 bytes of padding, which
56 * leads to problems when it is used on 32-bit tracee which does not have such
60 uint64_t dqb_bhardlimit;
61 uint64_t dqb_bsoftlimit;
62 uint64_t dqb_curspace;
63 uint64_t dqb_ihardlimit;
64 uint64_t dqb_isoftlimit;
65 uint64_t dqb_curinodes;
72 uint64_t dqb_bhardlimit;
73 uint64_t dqb_bsoftlimit;
74 uint64_t dqb_curspace;
75 uint64_t dqb_ihardlimit;
76 uint64_t dqb_isoftlimit;
77 uint64_t dqb_curinodes;
85 int8_t d_version; /* version of this structure */
86 uint8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
87 uint16_t d_fieldmask; /* field specifier */
88 uint32_t d_id; /* user, project, or group ID */
89 uint64_t d_blk_hardlimit; /* absolute limit on disk blks */
90 uint64_t d_blk_softlimit; /* preferred limit on disk blks */
91 uint64_t d_ino_hardlimit; /* maximum # allocated inodes */
92 uint64_t d_ino_softlimit; /* preferred inode limit */
93 uint64_t d_bcount; /* # disk blocks owned by the user */
94 uint64_t d_icount; /* # inodes owned by the user */
95 int32_t d_itimer; /* zero if within inode limits */
96 int32_t d_btimer; /* similar to above; for disk blocks */
97 uint16_t d_iwarns; /* # warnings issued wrt num inodes */
98 uint16_t d_bwarns; /* # warnings issued wrt disk blocks */
99 int32_t d_padding2; /* padding2 - for future use */
100 uint64_t d_rtb_hardlimit; /* absolute limit on realtime blks */
101 uint64_t d_rtb_softlimit; /* preferred limit on RT disk blks */
102 uint64_t d_rtbcount; /* # realtime blocks owned */
103 int32_t d_rtbtimer; /* similar to above; for RT disk blks */
104 uint16_t d_rtbwarns; /* # warnings issued wrt RT disk blks */
105 int16_t d_padding3; /* padding3 - for future use */
106 char d_padding4[8]; /* yet more padding */
116 typedef struct fs_qfilestat {
117 uint64_t qfs_ino; /* inode number */
118 uint64_t qfs_nblks; /* number of BBs 512-byte-blks */
119 uint32_t qfs_nextents; /* number of extents */
123 int8_t qs_version; /* version number for future changes */
124 uint16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
125 int8_t qs_pad; /* unused */
126 fs_qfilestat_t qs_uquota; /* user quota storage information */
127 fs_qfilestat_t qs_gquota; /* group quota storage information */
128 uint32_t qs_incoredqs; /* number of dquots incore */
129 int32_t qs_btimelimit; /* limit for blks timer */
130 int32_t qs_itimelimit; /* limit for inodes timer */
131 int32_t qs_rtbtimelimit; /* limit for rt blks timer */
132 uint16_t qs_bwarnlimit; /* limit for num warnings */
133 uint16_t qs_iwarnlimit; /* limit for num warnings */
136 struct fs_qfilestatv {
137 uint64_t qfs_ino, qfs_nblks;
138 uint32_t qfs_nextents, qfs_pad;
141 struct fs_quota_statv {
145 uint32_t qs_incoredqs;
146 struct fs_qfilestatv qs_uquota;
147 struct fs_qfilestatv qs_gquota;
148 struct fs_qfilestatv qs_pquota;
149 int32_t qs_btimelimit;
150 int32_t qs_itimelimit;
151 int32_t qs_rtbtimelimit;
152 uint16_t qs_bwarnlimit;
153 uint16_t qs_iwarnlimit;
158 decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, kernel_ulong_t data)
167 printxval(quota_formats, id, "QFMT_VFS_???");
169 printpath(tcp, data);
189 if (umove_or_printaddr(tcp, data, &dq))
191 PRINT_FIELD_U("{", dq, dqb_bhardlimit);
192 PRINT_FIELD_U(", ", dq, dqb_bsoftlimit);
193 PRINT_FIELD_U(", ", dq, dqb_curspace);
194 PRINT_FIELD_U(", ", dq, dqb_ihardlimit);
195 PRINT_FIELD_U(", ", dq, dqb_isoftlimit);
196 PRINT_FIELD_U(", ", dq, dqb_curinodes);
198 PRINT_FIELD_U(", ", dq, dqb_btime);
199 PRINT_FIELD_U(", ", dq, dqb_itime);
200 PRINT_FIELD_FLAGS(", ", dq, dqb_valid,
201 if_dqblk_valid, "QIF_???");
210 struct if_nextdqblk dq;
219 if (umove_or_printaddr(tcp, data, &dq))
221 PRINT_FIELD_U("{", dq, dqb_bhardlimit);
222 PRINT_FIELD_U(", ", dq, dqb_bsoftlimit);
223 PRINT_FIELD_U(", ", dq, dqb_curspace);
224 PRINT_FIELD_U(", ", dq, dqb_ihardlimit);
225 PRINT_FIELD_U(", ", dq, dqb_isoftlimit);
226 PRINT_FIELD_U(", ", dq, dqb_curinodes);
228 PRINT_FIELD_U(", ", dq, dqb_btime);
229 PRINT_FIELD_U(", ", dq, dqb_itime);
230 PRINT_FIELD_FLAGS(", ", dq, dqb_valid,
231 if_dqblk_valid, "QIF_???");
232 PRINT_FIELD_U(", ", dq, dqb_id);
234 PRINT_FIELD_U(", ", dq, dqb_id);
241 case Q_XGETNEXTQUOTA:
259 if (umove_or_printaddr(tcp, data, &dq))
261 PRINT_FIELD_D("{", dq, d_version);
262 PRINT_FIELD_FLAGS(", ", dq, d_flags,
263 xfs_dqblk_flags, "XFS_???_QUOTA");
264 PRINT_FIELD_X(", ", dq, d_fieldmask);
265 PRINT_FIELD_U(", ", dq, d_id);
266 PRINT_FIELD_U(", ", dq, d_blk_hardlimit);
267 PRINT_FIELD_U(", ", dq, d_blk_softlimit);
268 PRINT_FIELD_U(", ", dq, d_ino_hardlimit);
269 PRINT_FIELD_U(", ", dq, d_ino_softlimit);
270 PRINT_FIELD_U(", ", dq, d_bcount);
271 PRINT_FIELD_U(", ", dq, d_icount);
273 PRINT_FIELD_D(", ", dq, d_itimer);
274 PRINT_FIELD_D(", ", dq, d_btimer);
275 PRINT_FIELD_U(", ", dq, d_iwarns);
276 PRINT_FIELD_U(", ", dq, d_bwarns);
277 PRINT_FIELD_U(", ", dq, d_rtb_hardlimit);
278 PRINT_FIELD_U(", ", dq, d_rtb_softlimit);
279 PRINT_FIELD_U(", ", dq, d_rtbcount);
280 PRINT_FIELD_D(", ", dq, d_rtbtimer);
281 PRINT_FIELD_U(", ", dq, d_rtbwarns);
298 if (umove_or_printaddr(tcp, data, &fmt))
301 printxval(quota_formats, fmt, "QFMT_VFS_???");
320 if (umove_or_printaddr(tcp, data, &dq))
322 PRINT_FIELD_U("{", dq, dqi_bgrace);
323 PRINT_FIELD_U(", ", dq, dqi_igrace);
324 PRINT_FIELD_FLAGS(", ", dq, dqi_flags, if_dqinfo_flags, "DQF_???");
325 PRINT_FIELD_FLAGS(", ", dq, dqi_valid, if_dqinfo_valid, "IIF_???");
331 struct xfs_dqstats dq;
339 if (umove_or_printaddr(tcp, data, &dq))
341 PRINT_FIELD_D("{", dq, qs_version);
343 PRINT_FIELD_FLAGS(", ", dq, qs_flags,
344 xfs_quota_flags, "XFS_QUOTA_???");
345 PRINT_FIELD_U(", ", dq, qs_incoredqs);
346 PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino);
347 PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks);
348 PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents);
349 PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino);
350 PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks);
351 PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents);
352 PRINT_FIELD_D("}, ", dq, qs_btimelimit);
353 PRINT_FIELD_D(", ", dq, qs_itimelimit);
354 PRINT_FIELD_D(", ", dq, qs_rtbtimelimit);
355 PRINT_FIELD_U(", ", dq, qs_bwarnlimit);
356 PRINT_FIELD_U(", ", dq, qs_iwarnlimit);
365 struct fs_quota_statv dq;
373 if (umove_or_printaddr(tcp, data, &dq))
375 PRINT_FIELD_D("{", dq, qs_version);
377 PRINT_FIELD_FLAGS(", ", dq, qs_flags,
378 xfs_quota_flags, "XFS_QUOTA_???");
379 PRINT_FIELD_U(", ", dq, qs_incoredqs);
380 PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino);
381 PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks);
382 PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents);
383 PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino);
384 PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks);
385 PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents);
386 PRINT_FIELD_U("}, qs_pquota={", dq.qs_pquota, qfs_ino);
387 PRINT_FIELD_U(", ", dq.qs_pquota, qfs_nblks);
388 PRINT_FIELD_U(", ", dq.qs_pquota, qfs_nextents);
389 PRINT_FIELD_D("}, ", dq, qs_btimelimit);
390 PRINT_FIELD_D(", ", dq, qs_itimelimit);
391 PRINT_FIELD_D(", ", dq, qs_rtbtimelimit);
392 PRINT_FIELD_U(", ", dq, qs_bwarnlimit);
393 PRINT_FIELD_U(", ", dq, qs_iwarnlimit);
407 if (umove_or_printaddr(tcp, data, &flag))
410 printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
420 if (umove_or_printaddr(tcp, data, &flag))
423 printflags(xfs_dqblk_flags, flag, "XFS_???_QUOTA");
439 * The Linux kernel only looks at the low 32 bits of command and id
440 * arguments, but on some 64-bit architectures (s390x) this word
441 * will have been sign-extended when we see it. The high 1 bits
442 * don't mean anything, so don't confuse the output with them.
444 uint32_t qcmd = tcp->u_arg[0];
445 uint32_t cmd = QCMD_CMD(qcmd);
446 uint32_t type = QCMD_TYPE(qcmd);
447 uint32_t id = tcp->u_arg[2];
451 printxval(quotacmds, cmd, "Q_???");
453 printxval(quotatypes, type, "???QUOTA");
455 printpath(tcp, tcp->u_arg[1]);
457 return decode_cmd_data(tcp, id, cmd, tcp->u_arg[3]);