summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2019-08-21 20:44:10 +0000
committercheloha <cheloha@cvs.openbsd.org>2019-08-21 20:44:10 +0000
commit88189cd37e490ab9c99c014fc44132efceaa8868 (patch)
treeb20b7feea2832be528f34e5bcec9cbb6cdc8bf26 /sys/arch/i386
parent5e13514aef36d7e3e10f623e4512aab59b10e521 (diff)
sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)
The DST and TIMEZONE options(4) are incompatible with KARL, so we need some other way to compensate for an RTC running with a known offset. Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has always been minutes West, but this is inconsistent with how everyone else talks about timezones, hence the flip. TIMEZONE has the advantage of being compiled into the binary. Our new sysctl(2) has no such luck, so it needs to be set as early as possible in boot, from sysctl.conf(5), so we can correct the kernel clock from the RTC's local time to UTC before daemons like ntpd(8) and cron(8) start. To encourage this, kern.utc_offset is made immutable after the securelevel(7) is raised to 1. Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@. Additional testing by yasuoka@. ok deraadt@, yasuoka@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/isa/clock.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c
index f1307741ff7..14e9897b062 100644
--- a/sys/arch/i386/isa/clock.c
+++ b/sys/arch/i386/isa/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.54 2019/05/23 19:00:52 jasper Exp $ */
+/* $OpenBSD: clock.c,v 1.55 2019/08/21 20:44:09 cheloha Exp $ */
/* $NetBSD: clock.c,v 1.39 1996/05/12 23:11:54 mycroft Exp $ */
/*-
@@ -619,9 +619,7 @@ inittodr(time_t base)
dt.dt_mon = hexdectodec(rtclk[MC_MONTH]);
dt.dt_year = clock_expandyear(hexdectodec(rtclk[MC_YEAR]));
- ts.tv_sec = clock_ymdhms_to_secs(&dt) + tz.tz_minuteswest * 60;
- if (tz.tz_dsttime)
- ts.tv_sec -= 3600;
+ ts.tv_sec = clock_ymdhms_to_secs(&dt) - utc_offset;
if (base < ts.tv_sec - 5*SECYR)
printf("WARNING: file system time much less than clock time\n");
@@ -666,10 +664,7 @@ resettodr(void)
bzero(&rtclk, sizeof(rtclk));
splx(s);
- diff = tz.tz_minuteswest * 60;
- if (tz.tz_dsttime)
- diff -= 3600;
- clock_secs_to_ymdhms(time_second - diff, &dt);
+ clock_secs_to_ymdhms(time_second + utc_offset, &dt);
rtclk[MC_SEC] = dectohexdec(dt.dt_sec);
rtclk[MC_MIN] = dectohexdec(dt.dt_min);