* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
- * Copyright (c) 2005, 2006 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#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}
-};
+#define QCMD_CMD(cmd) ((uint32_t)(cmd) >> SUBCMDSHIFT)
+#define QCMD_TYPE(cmd) ((uint32_t)(cmd) & SUBCMDMASK)
+
+#define OLD_CMD(cmd) ((uint32_t)(cmd) << SUBCMDSHIFT)
+#define NEW_CMD(cmd) ((uint32_t)(cmd) | 0x800000)
+#define XQM_CMD(cmd) ((uint32_t)(cmd) | ('X' << SUBCMDSHIFT))
+
+#include "xlat/quotacmds.h"
+#include "xlat/quotatypes.h"
+#include "xlat/quota_formats.h"
+#include "xlat/xfs_quota_flags.h"
+#include "xlat/xfs_dqblk_flags.h"
+#include "xlat/if_dqblk_valid.h"
+#include "xlat/if_dqinfo_flags.h"
+#include "xlat/if_dqinfo_valid.h"
/*
- * Following flags are used to specify which fields are valid
+ * 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.
*/
-#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;
+ uint64_t dqb_bhardlimit;
+ uint64_t dqb_bsoftlimit;
+ uint64_t dqb_curspace;
+ uint64_t dqb_ihardlimit;
+ uint64_t dqb_isoftlimit;
+ uint64_t dqb_curinodes;
+ uint64_t dqb_btime;
+ uint64_t dqb_itime;
+ uint32_t dqb_valid;
+} ATTRIBUTE_PACKED;
+
+struct if_nextdqblk {
+ uint64_t dqb_bhardlimit;
+ uint64_t dqb_bsoftlimit;
+ uint64_t dqb_curspace;
+ uint64_t dqb_ihardlimit;
+ uint64_t dqb_isoftlimit;
+ uint64_t dqb_curinodes;
+ uint64_t dqb_btime;
+ uint64_t dqb_itime;
+ uint32_t dqb_valid;
+ uint32_t dqb_id;
};
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}
+ int8_t d_version; /* version of this structure */
+ int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */
+ uint16_t d_fieldmask; /* field specifier */
+ uint32_t d_id; /* user, project, or group ID */
+ uint64_t d_blk_hardlimit; /* absolute limit on disk blks */
+ uint64_t d_blk_softlimit; /* preferred limit on disk blks */
+ uint64_t d_ino_hardlimit; /* maximum # allocated inodes */
+ uint64_t d_ino_softlimit; /* preferred inode limit */
+ uint64_t d_bcount; /* # disk blocks owned by the user */
+ uint64_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 */
+ uint16_t d_iwarns; /* # warnings issued wrt num inodes */
+ uint16_t d_bwarns; /* # warnings issued wrt disk blocks */
+ int32_t d_padding2; /* padding2 - for future use */
+ uint64_t d_rtb_hardlimit; /* absolute limit on realtime blks */
+ uint64_t d_rtb_softlimit; /* preferred limit on RT disk blks */
+ uint64_t d_rtbcount; /* # realtime blocks owned */
+ int32_t d_rtbtimer; /* similar to above; for RT disk blks */
+ uint16_t d_rtbwarns; /* # warnings issued wrt RT disk blks */
+ int16_t d_padding3; /* padding3 - for future use */
+ char d_padding4[8]; /* yet more padding */
};
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;
+ uint64_t dqi_bgrace;
+ uint64_t dqi_igrace;
+ uint32_t dqi_flags;
+ uint32_t dqi_valid;
};
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 */
+ uint64_t qfs_ino; /* inode number */
+ uint64_t qfs_nblks; /* number of BBs 512-byte-blks */
+ uint32_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 */
+ int8_t qs_version; /* version number for future changes */
+ uint16_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 */
+ uint32_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 */
+ uint16_t qs_bwarnlimit; /* limit for num warnings */
+ uint16_t qs_iwarnlimit; /* limit for num warnings */
+};
+
+struct fs_qfilestatv {
+ uint64_t qfs_ino, qfs_nblks;
+ uint32_t qfs_nextents, qfs_pad;
};
-static void
-decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
+struct fs_quota_statv {
+ int8_t qs_version;
+ uint8_t qs_pad1;
+ uint16_t qs_flags;
+ uint32_t qs_incoredqs;
+ struct fs_qfilestatv qs_uquota;
+ struct fs_qfilestatv qs_gquota;
+ struct fs_qfilestatv qs_pquota;
+ int32_t qs_btimelimit;
+ int32_t qs_itimelimit;
+ int32_t qs_rtbtimelimit;
+ uint16_t qs_bwarnlimit;
+ uint16_t qs_iwarnlimit;
+ 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, kernel_ulong_t 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_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)) {
+ printuid(", ", id);
+ tprints(", ");
+
+ return 0;
}
- 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;
+
+ /* Fall-through */
+ case Q_SETQUOTA:
+ {
+ struct if_dqblk dq;
+
+ if (entering(tcp)) {
+ printuid(", ", id);
+ tprints(", ");
}
- 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);
+
+ if (umove_or_printaddr(tcp, data, &dq))
break;
+ 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)) {
+ PRINT_FIELD_U(", ", dq, dqb_btime);
+ PRINT_FIELD_U(", ", dq, dqb_itime);
+ tprints(", dqb_valid=");
+ printflags(if_dqblk_valid,
+ dq.dqb_valid, "QIF_???");
+ } else {
+ tprints(", ...");
}
- 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;
+ tprints("}");
+ break;
+ }
+ case Q_GETNEXTQUOTA:
+ {
+ struct if_nextdqblk dq;
+
+ if (entering(tcp)) {
+ printuid(", ", id);
+ tprints(", ");
+
+ return 0;
}
- 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("}");
+
+ if (umove_or_printaddr(tcp, data, &dq))
break;
+ 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)) {
+ PRINT_FIELD_U(", ", dq, dqb_btime);
+ PRINT_FIELD_U(", ", dq, dqb_itime);
+ tprints(", dqb_valid=");
+ printflags(if_dqblk_valid,
+ dq.dqb_valid, "QIF_???");
+ PRINT_FIELD_U(", ", dq, dqb_id);
+ } else {
+ PRINT_FIELD_U(", ", dq, dqb_id);
+ tprints(", ...");
}
- 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;
+ tprints("}");
+ break;
+ }
+ case Q_XGETQUOTA:
+ case Q_XGETNEXTQUOTA:
+ if (entering(tcp)) {
+ printuid(", ", id);
+ tprints(", ");
+
+ return 0;
}
- 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);
+
+ /* Fall-through */
+ case Q_XSETQLIM:
+ {
+ struct xfs_dqblk dq;
+
+ if (entering(tcp)) {
+ printuid(", ", id);
+ tprints(", ");
+ }
+
+ if (umove_or_printaddr(tcp, data, &dq))
break;
+ PRINT_FIELD_D("{", dq, d_version);
+ tprints(", d_flags=");
+ printflags(xfs_dqblk_flags,
+ (uint8_t) dq.d_flags, "XFS_???_QUOTA");
+ 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)) {
+ 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:
+ {
+ uint32_t fmt;
+
+ if (entering(tcp)) {
+ tprints(", ");
+
+ return 0;
}
- 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);
+
+ if (umove_or_printaddr(tcp, data, &fmt))
break;
+ tprints("[");
+ printxval(quota_formats, fmt, "QFMT_VFS_???");
+ tprints("]");
+ break;
+ }
+ case Q_GETINFO:
+ if (entering(tcp)) {
+ tprints(", ");
+
+ return 0;
}
- 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);
+
+ /* Fall-through */
+ case Q_SETINFO:
+ {
+ struct if_dqinfo dq;
+
+ if (entering(tcp))
+ tprints(", ");
+
+ if (umove_or_printaddr(tcp, data, &dq))
break;
+ 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_XGETQSTAT:
+ {
+ struct xfs_dqstats dq;
+
+ if (entering(tcp)) {
+ tprints(", ");
+
+ return 0;
}
- 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=");
+
+ if (umove_or_printaddr(tcp, data, &dq))
+ break;
+ PRINT_FIELD_D("{", dq, qs_version);
+ if (!abbrev(tcp)) {
+ tprints(", qs_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;
+ 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(", ...");
}
- 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("}");
+ tprints("}");
+ break;
+ }
+ case Q_XGETQSTATV:
+ {
+ struct fs_quota_statv dq;
+
+ if (entering(tcp)) {
+ tprints(", ");
+
+ return 0;
+ }
+
+ if (umove_or_printaddr(tcp, data, &dq))
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(", ...");
}
- default:
- tprintf("%#lx", data);
+ tprints("}");
+ break;
+ }
+ case Q_XQUOTAON:
+ case Q_XQUOTAOFF:
+ {
+ uint32_t flag;
+
+ tprints(", ");
+
+ if (umove_or_printaddr(tcp, data, &flag))
+ break;
+ tprints("[");
+ printflags(xfs_quota_flags, flag, "XFS_QUOTA_???");
+ 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(", ");
+ printaddr(data);
+ break;
}
+ return RVAL_DECODED;
}
-int
-sys_quotactl(struct tcb *tcp)
+SYS_FUNC(quotactl)
{
/*
* The Linux kernel only looks at the low 32 bits of command and id
* 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);
+ uint32_t qcmd = tcp->u_arg[0];
+ uint32_t cmd = QCMD_CMD(qcmd);
+ uint32_t type = QCMD_TYPE(qcmd);
+ uint32_t id = tcp->u_arg[2];
if (entering(tcp)) {
+ tprints("QCMD(");
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]);
+ printxval(quotatypes, type, "???QUOTA");
+ tprints("), ");
+ printpath(tcp, tcp->u_arg[1]);
}
- return 0;
+ return decode_cmd_data(tcp, id, cmd, tcp->u_arg[3]);
}