[PATCH v1 1/4] Mpersify decoder of struct xfs_dqstats

Dmitry V. Levin ldv at altlinux.org
Tue Jul 10 11:38:22 UTC 2018


On Mon, Jul 09, 2018 at 12:11:29AM +0800, Zhibin Li wrote:
> * xfs_quota_stat.h: New file.
> * fetch_struct_xfs_quotastat.c: Likewise.
> * Makefile.am: Add them.

* Makefile.am (strace_SOURCES): Add them.

> * quota.c: Include xfs_quota_stat.h.
> Move struct fs_qfilestat and struct xfs_dqstats to xfs_quota_stat.h

(struct fs_qfilestat, struct xfs_dqstats): Move to xfs_quota_stat.h.

> <case Q_XGETQSTAT>: Use fetch_struct_quotastat.

(decode_cmd_data) <case Q_XGETQSTAT>: Use fetch_struct_quotastat.

> ---
>  Makefile.am                  |  2 ++
>  fetch_struct_xfs_quotastat.c | 35 ++++++++++++++++++++++++
>  quota.c                      | 63 ++++++++++++++++----------------------------
>  xfs_quota_stat.h             | 22 ++++++++++++++++
>  4 files changed, 81 insertions(+), 41 deletions(-)
>  create mode 100644 fetch_struct_xfs_quotastat.c
>  create mode 100644 xfs_quota_stat.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 5f3f50a7..9e5eef27 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -144,6 +144,7 @@ strace_SOURCES =	\
>  	fetch_struct_stat.c \
>  	fetch_struct_stat64.c \
>  	fetch_struct_statfs.c \
> +	fetch_struct_xfs_quotastat.c \
>  	file_handle.c	\
>  	file_ioctl.c	\
>  	filter_qualify.c \
> @@ -348,6 +349,7 @@ strace_SOURCES =	\
>  	v4l2.c		\
>  	wait.c		\
>  	xattr.c		\
> +	xfs_quota_stat.h \
>  	xlat.c		\
>  	xlat.h		\
>  	xmalloc.c	\
> diff --git a/fetch_struct_xfs_quotastat.c b/fetch_struct_xfs_quotastat.c
> new file mode 100644
> index 00000000..b2631fd1
> --- /dev/null
> +++ b/fetch_struct_xfs_quotastat.c
> @@ -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_incoredqs = dqstat.qs_incoredqs;

Note that struct xfs_dqstats.qs_incoredqs follows qs_gquota.  Although
it's not necessary, we prefer to initialize members in the order of their
definition.

Besides that, the change looks OK.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180710/ae3cbc4d/attachment.bin>


More information about the Strace-devel mailing list