[PATCH 4/4] Implement decoding of ustat syscall

Dmitry V. Levin ldv at altlinux.org
Fri Jan 6 13:01:45 UTC 2017


On Fri, Jan 06, 2017 at 03:16:30PM +0800, JingPiao Chen wrote:
[...]
> +#include "defs.h"
> +#include <ustat.h>
> +
> +SYS_FUNC(ustat)
> +{
> +	if (entering(tcp))
> +		print_dev_t(tcp->u_arg[0]);
> +	else {
> +		struct ustat ust;

This structure is personality specific and therefore must be mpersified.

> +		tprints(", ");
> +		if (umoven_or_printaddr(tcp, tcp->u_arg[1], sizeof(ust), &ust))
> +			return 0;

Use umove_or_printaddr.

> +		tprintf("{f_tfree=%lld, f_tinode=%llu",
> +				sign_extend_unsigned_to_ll(ust.f_tfree));

Why sign extend it and print it as signed?  It's the number of free blocks,
it cannot be negative.  Inside the kernel, struct kstatfs.f_bfree is
of type u64.

> +				zero_extend_signed_to_ull(ust.f_tinode),
> +		tprints(", f_fname=");
> +		print_quoted_string(ust.f_fname, sizeof(ust.f_fname),
> +				QUOTE_0_TERMINATED);
> +		tprints(", f_fpack=");
> +		print_quoted_string(ust.f_fpack, sizeof(ust.f_fpack),
> +				QUOTE_0_TERMINATED);

These fields are guaranteed by kernel to be zero, why bother printing
them at all?


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


More information about the Strace-devel mailing list