Mpersify decoder of struct xfs_dqstats

* xfs_quota_stat.h: New file.
* fetch_struct_xfs_quotastat.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* quota.c: Include xfs_quota_stat.h
(struct fs_qfilestat, struct xfs_dqstats): Moved to xfs_quota_stat.h.
(decode_cmd_data) <case Q_XGETQSTAT>: Use fetch_struct_quotastat.
This commit is contained in:
Zhibin Li 2018-07-12 17:32:09 +08:00 committed by Dmitry V. Levin
parent 44a99c878b
commit de6e322986
4 changed files with 81 additions and 42 deletions

View File

@ -144,6 +144,7 @@ strace_SOURCES = \
fetch_struct_stat.c \ fetch_struct_stat.c \
fetch_struct_stat64.c \ fetch_struct_stat64.c \
fetch_struct_statfs.c \ fetch_struct_statfs.c \
fetch_struct_xfs_quotastat.c \
file_handle.c \ file_handle.c \
file_ioctl.c \ file_ioctl.c \
filter_qualify.c \ filter_qualify.c \
@ -348,6 +349,7 @@ strace_SOURCES = \
v4l2.c \ v4l2.c \
wait.c \ wait.c \
xattr.c \ xattr.c \
xfs_quota_stat.h \
xlat.c \ xlat.c \
xlat.h \ xlat.h \
xmalloc.c \ xmalloc.c \

View File

@ -0,0 +1,35 @@
#include "defs.h"
#include DEF_MPERS_TYPE(struct_xfs_dqstats)
#include "xfs_quota_stat.h"
typedef struct xfs_dqstats struct_xfs_dqstats;
#include MPERS_DEFS
MPERS_PRINTER_DECL(bool, fetch_struct_quotastat, struct tcb *const tcp,
const kernel_ulong_t data, void *p)
{
struct xfs_dqstats *dq = p;
struct_xfs_dqstats dqstat;
if (umove_or_printaddr(tcp, data, &dqstat))
return false;
dq->qs_version = dqstat.qs_version;
dq->qs_flags = dqstat.qs_flags;
dq->qs_pad = dqstat.qs_pad;
dq->qs_uquota.qfs_ino = dqstat.qs_uquota.qfs_ino;
dq->qs_uquota.qfs_nblks = dqstat.qs_uquota.qfs_nblks;
dq->qs_uquota.qfs_nextents = dqstat.qs_uquota.qfs_nextents;
dq->qs_gquota.qfs_ino = dqstat.qs_gquota.qfs_ino;
dq->qs_gquota.qfs_nblks = dqstat.qs_gquota.qfs_nblks;
dq->qs_gquota.qfs_nextents = dqstat.qs_gquota.qfs_nextents;
dq->qs_incoredqs = dqstat.qs_incoredqs;
dq->qs_btimelimit = dqstat.qs_btimelimit;
dq->qs_itimelimit = dqstat.qs_itimelimit;
dq->qs_rtbtimelimit = dqstat.qs_rtbtimelimit;
dq->qs_bwarnlimit = dqstat.qs_bwarnlimit;
dq->qs_iwarnlimit = dqstat.qs_iwarnlimit;
return true;
}

64
quota.c
View File

@ -32,6 +32,7 @@
#include "defs.h" #include "defs.h"
#include "print_fields.h" #include "print_fields.h"
#include "xfs_quota_stat.h"
#define SUBCMDMASK 0x00ff #define SUBCMDMASK 0x00ff
#define SUBCMDSHIFT 8 #define SUBCMDSHIFT 8
@ -114,26 +115,6 @@ struct if_dqinfo {
uint32_t dqi_valid; uint32_t dqi_valid;
}; };
typedef struct fs_qfilestat {
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 */
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 */
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 */
uint16_t qs_bwarnlimit; /* limit for num warnings */
uint16_t qs_iwarnlimit; /* limit for num warnings */
};
struct fs_qfilestatv { struct fs_qfilestatv {
uint64_t qfs_ino, qfs_nblks; uint64_t qfs_ino, qfs_nblks;
uint32_t qfs_nextents, qfs_pad; uint32_t qfs_nextents, qfs_pad;
@ -336,29 +317,28 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, kernel_ulong_t data)
return 0; return 0;
} }
if (fetch_struct_quotastat(tcp, data, &dq)) {
if (umove_or_printaddr(tcp, data, &dq)) PRINT_FIELD_D("{", dq, qs_version);
break; if (!abbrev(tcp)) {
PRINT_FIELD_D("{", dq, qs_version); PRINT_FIELD_FLAGS(", ", dq, qs_flags,
if (!abbrev(tcp)) { xfs_quota_flags, "XFS_QUOTA_???");
PRINT_FIELD_FLAGS(", ", dq, qs_flags, PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino);
xfs_quota_flags, "XFS_QUOTA_???"); PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks);
PRINT_FIELD_U(", qs_uquota={", dq.qs_uquota, qfs_ino); PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents);
PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nblks); PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino);
PRINT_FIELD_U(", ", dq.qs_uquota, qfs_nextents); PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks);
PRINT_FIELD_U("}, qs_gquota={", dq.qs_gquota, qfs_ino); PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents);
PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nblks); PRINT_FIELD_U("}, ", dq, qs_incoredqs);
PRINT_FIELD_U(", ", dq.qs_gquota, qfs_nextents); PRINT_FIELD_D(", ", dq, qs_btimelimit);
PRINT_FIELD_U("}, ", dq, qs_incoredqs); PRINT_FIELD_D(", ", dq, qs_itimelimit);
PRINT_FIELD_D(", ", dq, qs_btimelimit); PRINT_FIELD_D(", ", dq, qs_rtbtimelimit);
PRINT_FIELD_D(", ", dq, qs_itimelimit); PRINT_FIELD_U(", ", dq, qs_bwarnlimit);
PRINT_FIELD_D(", ", dq, qs_rtbtimelimit); PRINT_FIELD_U(", ", dq, qs_iwarnlimit);
PRINT_FIELD_U(", ", dq, qs_bwarnlimit); } else {
PRINT_FIELD_U(", ", dq, qs_iwarnlimit); tprints(", ...");
} else { }
tprints(", ..."); tprints("}");
} }
tprints("}");
break; break;
} }
case Q_XGETQSTATV: case Q_XGETQSTATV:

22
xfs_quota_stat.h Normal file
View File

@ -0,0 +1,22 @@
#include <stdint.h>
#include "kernel_types.h"
typedef struct fs_qfilestat {
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 */
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 */
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 */
uint16_t qs_bwarnlimit; /* limit for num warnings */
uint16_t qs_iwarnlimit; /* limit for num warnings */
};