[PATCH] hwclock: Just give up on timezones for new ports

Palmer Dabbelt palmer at rivosinc.com
Wed Apr 10 00:23:01 UTC 2024


As far as I can tell the kernel no longer suppports timezones on 32-bit
ports without time32_t (ie, rv32).  I have no idea what the right thing
to do is here, but as far as I can tell all we can really do is to
ignore the timezone.

Signed-off-by: Palmer Dabbelt <palmer at rivosinc.com>
---
Sorry for the resend, I wasn't subscribed this morning so the mail
bounced.
---
 util-linux/hwclock.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index e6f0043d0..597715de9 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -137,10 +137,24 @@ static void set_kernel_tz(const struct timezone *tz)
 	 * because "it's deprecated by POSIX, therefore it's fine
 	 * if we gratuitously break stuff" :(
 	 */
-#if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
-# define SYS_settimeofday SYS_settimeofday_time32
-#endif
+# if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
+#  define SYS_settimeofday SYS_settimeofday_time32
+# endif
+# if defined(SYS_settimeofday)
 	int ret = syscall(SYS_settimeofday, NULL, tz);
+# else
+	/* Some new architectures have neither settimeofday nor
+	 * settimeofday_time32, and the whole kernel timezone handling appears
+	 * to have been dropped due to some oddities in the API.  See:
+	 *
+	 *   - glibc's commit c3f9aef063 ("Use clock_settime to implement settimeofday.")
+	 *   - https://github.com/systemd/systemd/issues/13305
+	 *   - https://inbox.sourceware.org/libc-alpha/cb015d0d1d29e4b948c7118c5b12ff2bed83a6ec.1561421042.git.alistair.francis@wdc.com/
+	 *
+	 * So instead just silently drop these calls.
+	 */
+	int ret = -ENOSYS;
+# endif
 #else
 	int ret = settimeofday(NULL, tz);
 #endif
-- 
2.44.0



More information about the busybox mailing list