#include "xlat/if_dqinfo_flags.h"
#include "xlat/if_dqinfo_valid.h"
+/*
+ * We add attribute packed due to the fact that the structure is 8-byte aligned
+ * on 64-bit systems and therefore has additional 4 bytes of padding, which
+ * leads to problems when it is used on 32-bit tracee which does not have such
+ * padding.
+ */
struct if_dqblk
{
uint64_t dqb_bhardlimit;
uint64_t dqb_btime;
uint64_t dqb_itime;
uint32_t dqb_valid;
-};
+} ATTRIBUTE_PACKED;
struct if_nextdqblk {
uint64_t dqb_bhardlimit;
uint32_t dqb_id;
};
-struct v1_dqblk
-{
- uint32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
- uint32_t dqb_bsoftlimit; /* preferred limit on disk blks */
- uint32_t dqb_curblocks; /* current block count */
- uint32_t dqb_ihardlimit; /* maximum # allocated inodes */
- uint32_t dqb_isoftlimit; /* preferred inode limit */
- uint32_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;
- uint64_t dqb_curspace;
- time_t dqb_btime;
- time_t dqb_itime;
-};
-
struct xfs_dqblk
{
int8_t d_version; /* version of this structure */
uint32_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
-{
- uint32_t lookups;
- uint32_t drops;
- uint32_t reads;
- uint32_t writes;
- uint32_t cache_hits;
- uint32_t allocated_dquots;
- uint32_t free_dquots;
- uint32_t syncs;
-};
-
-struct v2_dqstats
-{
- uint32_t lookups;
- uint32_t drops;
- uint32_t reads;
- uint32_t writes;
- uint32_t cache_hits;
- uint32_t allocated_dquots;
- uint32_t free_dquots;
- uint32_t syncs;
- uint32_t version;
-};
-
typedef struct fs_qfilestat
{
uint64_t qfs_ino; /* inode number */
uint64_t qs_pad2[8];
};
+#define PRINT_FIELD_D(prefix, where, field) \
+ tprintf("%s%s=%lld", (prefix), #field, \
+ sign_extend_unsigned_to_ll((where).field))
+
+#define PRINT_FIELD_U(prefix, where, field) \
+ tprintf("%s%s=%llu", (prefix), #field, \
+ zero_extend_signed_to_ull((where).field))
+
+#define PRINT_FIELD_X(prefix, where, field) \
+ tprintf("%s%s=%#llx", (prefix), #field, \
+ zero_extend_signed_to_ull((where).field))
+
static int
decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, unsigned long data)
{
switch (cmd) {
case Q_QUOTAOFF:
+ case Q_SYNC:
+ case Q_XQUOTASYNC:
+ break;
+ case Q_QUOTAON:
+ tprints(", ");
+ printxval(quota_formats, id, "QFMT_VFS_???");
+ tprints(", ");
+ printpath(tcp, data);
break;
case Q_GETQUOTA:
if (entering(tcp)) {
if (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{dqb_bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
- tprintf("dqb_bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
- tprintf("dqb_curspace=%" PRIu64 ", ", dq.dqb_curspace);
- tprintf("dqb_ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
- tprintf("dqb_isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
- tprintf("dqb_curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
+ PRINT_FIELD_U("{", dq, dqb_bhardlimit);
+ PRINT_FIELD_U(", ", dq, dqb_bsoftlimit);
+ PRINT_FIELD_U(", ", dq, dqb_curspace);
+ PRINT_FIELD_U(", ", dq, dqb_ihardlimit);
+ PRINT_FIELD_U(", ", dq, dqb_isoftlimit);
+ PRINT_FIELD_U(", ", dq, dqb_curinodes);
if (!abbrev(tcp)) {
- tprintf("dqb_btime=%" PRIu64 ", ", dq.dqb_btime);
- tprintf("dqb_itime=%" PRIu64 ", ", dq.dqb_itime);
- tprints("dqb_valid=");
+ PRINT_FIELD_U(", ", dq, dqb_btime);
+ PRINT_FIELD_U(", ", dq, dqb_itime);
+ tprints(", dqb_valid=");
printflags(if_dqblk_valid,
dq.dqb_valid, "QIF_???");
- tprints("}");
- } else
- tprints("...}");
+ } else {
+ tprints(", ...");
+ }
+ tprints("}");
break;
}
case Q_GETNEXTQUOTA:
if (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{dqb_bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
- tprintf("dqb_bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
- tprintf("dqb_curspace=%" PRIu64 ", ", dq.dqb_curspace);
- tprintf("dqb_ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
- tprintf("dqb_isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
- tprintf("dqb_curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
+ PRINT_FIELD_U("{", dq, dqb_bhardlimit);
+ PRINT_FIELD_U(", ", dq, dqb_bsoftlimit);
+ PRINT_FIELD_U(", ", dq, dqb_curspace);
+ PRINT_FIELD_U(", ", dq, dqb_ihardlimit);
+ PRINT_FIELD_U(", ", dq, dqb_isoftlimit);
+ PRINT_FIELD_U(", ", dq, dqb_curinodes);
if (!abbrev(tcp)) {
- tprintf("dqb_btime=%" PRIu64 ", ", dq.dqb_btime);
- tprintf("dqb_itime=%" PRIu64 ", ", dq.dqb_itime);
- tprints("dqb_valid=");
+ PRINT_FIELD_U(", ", dq, dqb_btime);
+ PRINT_FIELD_U(", ", dq, dqb_itime);
+ tprints(", dqb_valid=");
printflags(if_dqblk_valid,
dq.dqb_valid, "QIF_???");
- tprintf(", dqb_id=%u}", dq.dqb_id);
- } else
- tprintf("dqb_id=%u, ...}", dq.dqb_id);
- break;
- }
- case Q_V1_GETQUOTA:
- if (entering(tcp)) {
- printuid(", ", id);
- tprints(", ");
-
- return 0;
- }
-
- /* Fall-through */
- case Q_V1_SETQUOTA:
- {
- struct v1_dqblk dq;
-
- if (entering(tcp)) {
- printuid(", ", id);
- tprints(", ");
+ PRINT_FIELD_U(", ", dq, dqb_id);
+ } else {
+ PRINT_FIELD_U(", ", dq, dqb_id);
+ tprints(", ...");
}
-
- if (umove_or_printaddr(tcp, data, &dq))
- break;
- tprintf("{dqb_bhardlimit=%u, ", dq.dqb_bhardlimit);
- tprintf("dqb_bsoftlimit=%u, ", dq.dqb_bsoftlimit);
- tprintf("dqb_curblocks=%u, ", dq.dqb_curblocks);
- tprintf("dqb_ihardlimit=%u, ", dq.dqb_ihardlimit);
- tprintf("dqb_isoftlimit=%u, ", dq.dqb_isoftlimit);
- tprintf("dqb_curinodes=%u, ", dq.dqb_curinodes);
- tprintf("dqb_btime=%lu, ", (long) dq.dqb_btime);
- tprintf("dqb_itime=%lu}", (long) dq.dqb_itime);
- break;
- }
- case Q_V2_GETQUOTA:
- if (entering(tcp)) {
- printuid(", ", id);
- tprints(", ");
-
- return 0;
- }
-
- /* Fall-through */
- case Q_V2_SETQUOTA:
- {
- struct v2_dqblk dq;
-
- if (entering(tcp)) {
- printuid(", ", id);
- tprints(", ");
- }
-
- if (umove_or_printaddr(tcp, data, &dq))
- break;
- tprintf("{dqb_ihardlimit=%u, ", dq.dqb_ihardlimit);
- tprintf("dqb_isoftlimit=%u, ", dq.dqb_isoftlimit);
- tprintf("dqb_curinodes=%u, ", dq.dqb_curinodes);
- tprintf("dqb_bhardlimit=%u, ", dq.dqb_bhardlimit);
- tprintf("dqb_bsoftlimit=%u, ", dq.dqb_bsoftlimit);
- tprintf("dqb_curspace=%" PRIu64 ", ", dq.dqb_curspace);
- tprintf("dqb_btime=%lu, ", (long) dq.dqb_btime);
- tprintf("dqb_itime=%lu}", (long) dq.dqb_itime);
+ tprints("}");
break;
}
case Q_XGETQUOTA:
if (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{d_version=%d, ", dq.d_version);
- tprints("d_flags=");
+ PRINT_FIELD_D("{", dq, d_version);
+ tprints(", d_flags=");
printflags(xfs_dqblk_flags,
(uint8_t) dq.d_flags, "XFS_???_QUOTA");
- tprintf(", d_fieldmask=%#x, ", dq.d_fieldmask);
- tprintf("d_id=%u, ", dq.d_id);
- tprintf("d_blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit);
- tprintf("d_blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit);
- tprintf("d_ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit);
- tprintf("d_ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
- tprintf("d_bcount=%" PRIu64 ", ", dq.d_bcount);
- tprintf("d_icount=%" PRIu64 ", ", dq.d_icount);
+ PRINT_FIELD_X(", ", dq, d_fieldmask);
+ PRINT_FIELD_U(", ", dq, d_id);
+ PRINT_FIELD_U(", ", dq, d_blk_hardlimit);
+ PRINT_FIELD_U(", ", dq, d_blk_softlimit);
+ PRINT_FIELD_U(", ", dq, d_ino_hardlimit);
+ PRINT_FIELD_U(", ", dq, d_ino_softlimit);
+ PRINT_FIELD_U(", ", dq, d_bcount);
+ PRINT_FIELD_U(", ", dq, d_icount);
if (!abbrev(tcp)) {
- tprintf("d_itimer=%d, ", dq.d_itimer);
- tprintf("d_btimer=%d, ", dq.d_btimer);
- tprintf("d_iwarns=%u, ", dq.d_iwarns);
- tprintf("d_bwarns=%u, ", dq.d_bwarns);
- tprintf("d_rtbcount=%" PRIu64 ", ", dq.d_rtbcount);
- tprintf("d_rtbtimer=%d, ", dq.d_rtbtimer);
- tprintf("d_rtbwarns=%u}", dq.d_rtbwarns);
- } else
- tprints("...}");
+ PRINT_FIELD_D(", ", dq, d_itimer);
+ PRINT_FIELD_D(", ", dq, d_btimer);
+ PRINT_FIELD_U(", ", dq, d_iwarns);
+ PRINT_FIELD_U(", ", dq, d_bwarns);
+ PRINT_FIELD_U(", ", dq, d_rtb_hardlimit);
+ PRINT_FIELD_U(", ", dq, d_rtb_softlimit);
+ PRINT_FIELD_U(", ", dq, d_rtbcount);
+ PRINT_FIELD_D(", ", dq, d_rtbtimer);
+ PRINT_FIELD_U(", ", dq, d_rtbwarns);
+ } else {
+ tprints(", ...");
+ }
+ tprints("}");
break;
}
case Q_GETFMT:
if (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{dqi_bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
- tprintf("dqi_igrace=%" PRIu64 ", ", dq.dqi_igrace);
- tprints("dqi_flags=");
+ PRINT_FIELD_U("{", dq, dqi_bgrace);
+ PRINT_FIELD_U(", ", dq, dqi_igrace);
+ tprints(", dqi_flags=");
printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
tprints(", dqi_valid=");
printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???");
tprints("}");
break;
}
- case Q_V2_GETINFO:
- if (entering(tcp)) {
- tprints(", ");
-
- return 0;
- }
-
- /* Fall-through */
- case Q_V2_SETINFO:
- {
- struct v2_dqinfo dq;
-
- if (entering(tcp))
- tprints(", ");
-
- if (umove_or_printaddr(tcp, data, &dq))
- break;
- tprintf("{dqi_bgrace=%u, ", dq.dqi_bgrace);
- tprintf("dqi_igrace=%u, ", dq.dqi_igrace);
- tprints("dqi_flags=");
- printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???");
- tprintf(", dqi_blocks=%u, ", dq.dqi_blocks);
- tprintf("dqi_free_blk=%u, ", dq.dqi_free_blk);
- tprintf("dqi_free_entry=%u}", dq.dqi_free_entry);
- break;
- }
- case Q_V1_GETSTATS:
- {
- struct v1_dqstats dq;
-
- if (entering(tcp)) {
- tprints(", ");
-
- return 0;
- }
-
- if (umove_or_printaddr(tcp, data, &dq))
- 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 (entering(tcp)) {
- tprints(", ");
-
- return 0;
- }
-
- if (umove_or_printaddr(tcp, data, &dq))
- 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 (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{qs_version=%d, ", dq.qs_version);
- if (abbrev(tcp)) {
- tprints("...}");
- break;
+ PRINT_FIELD_D("{", dq, qs_version);
+ if (!abbrev(tcp)) {
+ tprints(", qs_flags=");
+ printflags(xfs_quota_flags,
+ dq.qs_flags, "XFS_QUOTA_???");
+ PRINT_FIELD_U(", ", dq, qs_incoredqs);
+ PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino);
+ PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks);
+ PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents);
+ PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino);
+ PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks);
+ PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents);
+ PRINT_FIELD_D("}, ", dq, qs_btimelimit);
+ PRINT_FIELD_D(", ", dq, qs_itimelimit);
+ PRINT_FIELD_D(", ", dq, qs_rtbtimelimit);
+ PRINT_FIELD_U(", ", dq, qs_bwarnlimit);
+ PRINT_FIELD_U(", ", dq, qs_iwarnlimit);
+ } else {
+ tprints(", ...");
}
- tprints("qs_flags=");
- printflags(xfs_quota_flags,
- dq.qs_flags, "XFS_QUOTA_???");
- tprintf(", qs_incoredqs=%u, ", dq.qs_incoredqs);
- tprints("qs_uquota={");
- tprintf("qfs_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
- tprintf("qfs_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
- tprintf("qfs_nextents=%u}, ", dq.qs_uquota.qfs_nextents);
- tprints("qs_gquota={");
- tprintf("qfs_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
- tprintf("qfs_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
- tprintf("qfs_nextents=%u}, ", dq.qs_gquota.qfs_nextents);
- tprintf("qs_btimelimit=%d, ", dq.qs_btimelimit);
- tprintf("qs_itimelimit=%d, ", dq.qs_itimelimit);
- tprintf("qs_rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
- tprintf("qs_bwarnlimit=%u, ", dq.qs_bwarnlimit);
- tprintf("qs_iwarnlimit=%u}", dq.qs_iwarnlimit);
+ tprints("}");
break;
}
case Q_XGETQSTATV:
if (umove_or_printaddr(tcp, data, &dq))
break;
- tprintf("{qs_version=%d, ", dq.qs_version);
- if (abbrev(tcp)) {
- tprints("...}");
- break;
+ PRINT_FIELD_D("{", dq, qs_version);
+ if (!abbrev(tcp)) {
+ tprints(", qs_flags=");
+ printflags(xfs_quota_flags,
+ dq.qs_flags, "XFS_QUOTA_???");
+ PRINT_FIELD_U(", ", dq, qs_incoredqs);
+ PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino);
+ PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks);
+ PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents);
+ PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino);
+ PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks);
+ PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents);
+ PRINT_FIELD_U("}, qs_pquota={", dq.qs_pquota, qfs_ino);
+ PRINT_FIELD_U(", ", dq.qs_pquota, qfs_nblks);
+ PRINT_FIELD_U(", ", dq.qs_pquota, qfs_nextents);
+ PRINT_FIELD_D("}, ", dq, qs_btimelimit);
+ PRINT_FIELD_D(", ", dq, qs_itimelimit);
+ PRINT_FIELD_D(", ", dq, qs_rtbtimelimit);
+ PRINT_FIELD_U(", ", dq, qs_bwarnlimit);
+ PRINT_FIELD_U(", ", dq, qs_iwarnlimit);
+ } else {
+ tprints(", ...");
}
- tprints("qs_flags=");
- printflags(xfs_quota_flags,
- dq.qs_flags, "XFS_QUOTA_???");
- tprintf(", qs_incoredqs=%u, ", dq.qs_incoredqs);
- tprints("qs_uquota={");
- tprintf("qfs_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino);
- tprintf("qfs_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks);
- tprintf("qfs_nextents=%u}, ", dq.qs_uquota.qfs_nextents);
- tprints("qs_gquota={");
- tprintf("qfs_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino);
- tprintf("qfs_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks);
- tprintf("qfs_nextents=%u}, ", dq.qs_gquota.qfs_nextents);
- tprints("qs_pquota={");
- tprintf("qfs_ino=%" PRIu64 ", ", dq.qs_pquota.qfs_ino);
- tprintf("qfs_nblks=%" PRIu64 ", ", dq.qs_pquota.qfs_nblks);
- tprintf("qfs_nextents=%u}, ", dq.qs_pquota.qfs_nextents);
- tprintf("qs_btimelimit=%d, ", dq.qs_btimelimit);
- tprintf("qs_itimelimit=%d, ", dq.qs_itimelimit);
- tprintf("qs_rtbtimelimit=%d, ", dq.qs_rtbtimelimit);
- tprintf("qs_bwarnlimit=%u, ", dq.qs_bwarnlimit);
- tprintf("qs_iwarnlimit=%u}", dq.qs_iwarnlimit);
+ tprints("}");
break;
}
case Q_XQUOTAON:
tprints("]");
break;
}
+ case Q_XQUOTARM:
+ {
+ uint32_t flag;
+
+ tprints(", ");
+
+ if (umove_or_printaddr(tcp, data, &flag))
+ break;
+ tprints("[");
+ printflags(xfs_dqblk_flags, flag, "XFS_???_QUOTA");
+ tprints("]");
+ break;
+ }
default:
printuid(", ", id);
tprints(", ");
printxval(quotatypes, type, "???QUOTA");
tprints("), ");
printpath(tcp, tcp->u_arg[1]);
- switch (cmd) {
- case Q_QUOTAON:
- case Q_V1_QUOTAON:
- tprints(", ");
- printxval(quota_formats, id, "QFMT_VFS_???");
- tprints(", ");
- printpath(tcp, tcp->u_arg[3]);
- return RVAL_DECODED;
- }
}
return decode_cmd_data(tcp, id, cmd, tcp->u_arg[3]);
}