[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCHv2] hwclock: use settimeofday syscall directly
From:       Rosen Penev <rosenp () gmail ! com>
Date:       2020-08-31 22:38:37
Message-ID: CAKxU2N8OJ2nFWUNacnWpWJ+bAZdHtvPSSg2RXWb9Bt2S0-jDxA () mail ! gmail ! com
[Download RAW message or body]

On Mon, Aug 31, 2020 at 9:22 AM Walter Harms <wharms@bfs.de> wrote:
>
> maybe its a bit late but ...
> doing syscall() is always last resort, IMHO it would
> be better to separate this into a bb_set_tod() and
> put all the strings here ... and replace it when the
> libc guys have a single standard.
There will not be a standard for this. settimeofday is deprecated.
>
> jm2c,
>  re,
>  wh
>
> ________________________________________
> Von: busybox [busybox-bounces@busybox.net] im Auftrag von Rosen Penev [rosenp@gmail.com]
> Gesendet: Montag, 31. August 2020 03:51
> An: busybox@busybox.net
> Betreff: [PATCHv2] hwclock: use settimeofday syscall directly
>
> musl's settimeofday implementation completely ignores the tz parameter.
> While this is perfectly valid, it causes problems when wanting to set
> the kernel timezone.
>
> Added comments.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  v2: don't use __NR. It's not correct to do so.
>  util-linux/hwclock.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
> index e85bca2b2..cf7c58507 100644
> --- a/util-linux/hwclock.c
> +++ b/util-linux/hwclock.c
> @@ -33,6 +33,7 @@
>
>  #include "libbb.h"
>  /* After libbb.h, since it needs sys/types.h on some systems */
> +#include <sys/syscall.h>
>  #include <sys/utsname.h>
>  #include "rtc_.h"
>
> @@ -48,6 +49,10 @@
>   */
>  #define SHOW_HWCLOCK_DIFF 0
>
> +/* musl 1.2.0+ does not have SYS_settimeofday */
> +#ifndef SYS_settimeofday
> +#define SYS_settimeofday SYS_settimeofday_time32
> +#endif
>
>  #if !SHOW_HWCLOCK_DIFF
>  # define read_rtc(pp_rtcname, sys_tv, utc) read_rtc(pp_rtcname, utc)
> @@ -128,8 +133,10 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
>          */
>         tz.tz_dsttime = 0;
>
> -       /* glibc v2.31+ returns an error if both args are non-NULL */
> -       if (settimeofday(NULL, &tz))
> +       /* glibc v2.31+ returns an error if both args are non-NULL
> +        * musl completely ignores the tz parameter
> +        */
> +       if (syscall(SYS_settimeofday, NULL, &tz))
>                 bb_simple_perror_msg_and_die("settimeofday");
>
>         tv.tv_sec = read_rtc(pp_rtcname, NULL, utc);
> @@ -287,8 +294,10 @@ static void set_system_clock_timezone(int utc)
>         if (!utc)
>                 tv.tv_sec += tz.tz_minuteswest * 60;
>
> -       /* glibc v2.31+ returns an error if both args are non-NULL */
> -       if (settimeofday(NULL, &tz))
> +       /* glibc v2.31+ returns an error if both args are non-NULL
> +        * musl completely ignores the tz parameter
> +        */
> +       if (syscall(SYS_settimeofday, NULL, &tz))
>                 bb_simple_perror_msg_and_die("settimeofday");
>         if (settimeofday(&tv, NULL))
>                 bb_simple_perror_msg_and_die("settimeofday");
> --
> 2.26.2
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic