Re: [PATCH] [v3] y2038: introduce struct __kernel_old_timeval

From: Thomas Gleixner
Date: Thu Mar 15 2018 - 20:02:13 EST


On Thu, 15 Mar 2018, Arnd Bergmann wrote:
> + * legacy timeval structure, only embedded in structures that
> + * traditionally used 'timeval' to pass time intervals (not absolute
> + * times). Do not add new users. If user space fails to compile
> + * here, this is probably because it is not y2038 safe and needs to
> + * be changed to use another interface.
> + */
> +struct __kernel_old_timeval {
> + __kernel_long_t tv_sec;
> + __kernel_long_t tv_usec;
> +};
> +
> +/*
> * The IDs of the various system clocks (for POSIX.1b interval timers):
> */
> #define CLOCK_REALTIME 0
> diff --git a/kernel/time/time.c b/kernel/time/time.c
> index 5db8f15ec056..6fa99213fc72 100644
> --- a/kernel/time/time.c
> +++ b/kernel/time/time.c
> @@ -486,6 +486,18 @@ struct timeval ns_to_timeval(const s64 nsec)
> }
> EXPORT_SYMBOL(ns_to_timeval);
>
> +struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64 nsec)
> +{
> + struct timespec64 ts = ns_to_timespec64(nsec);
> + struct __kernel_old_timeval tv;
> +
> + tv.tv_sec = ts.tv_sec;

We might think about adding some debug aid here which yells when ts.tv_sec
is > than the cutoff.

Hmm?

tglx