[PATCH 2/2] printrusage: Correctly print the long types from the rusage struct
Dmitry V. Levin
ldv at altlinux.org
Thu Mar 5 02:04:36 UTC 2020
On Wed, Mar 04, 2020 at 05:30:34PM -0800, Alistair Francis wrote:
> The kernel's rusage struct uses the kernel's __kernel_old_timeval which
> means that even for 32-bit archs with 64-bit time_t (like RV32) the time
> values are 32-bit.
>
> There are two possible options here:
> 1. Use the glibc getrusage() function. Which takes a struct rusage with
> a 64-bit time_t but does a syscall with a 32-bit time_t and handles
> the conversion internally.
> 2. Specify our own rusage struct that uses a long for the time.
>
> This patch fixes the failure useing option 2 above as we then get to
> call the raw syscall.
>
> Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
> ---
> print_timeval.c | 16 ++++++++++++++++
> printrusage.c | 4 ++--
> tests/getrusage.c | 28 ++++++++++++++++++++++++++--
> 3 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/print_timeval.c b/print_timeval.c
> index ff87b27b..36bc843e 100644
> --- a/print_timeval.c
> +++ b/print_timeval.c
> @@ -11,6 +11,10 @@
> #include DEF_MPERS_TYPE(timeval_t)
>
> typedef struct timeval timeval_t;
> +typedef struct old_timeval_t {
> + long tv_sec;
> + long tv_usec;
> +} old_timeval_t;
Sorry but this definition doesn't match the definition of struct
__kernel_old_timeval in include/uapi/linux/time_types.h and
arch/sparc/include/uapi/asm/posix_types.h files.
--
ldv
More information about the Strace-devel
mailing list