summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-07-27 00:11:08 +0200
committerKay Sievers <kay@vrfy.org>2014-07-27 10:44:31 +0200
commitc264aeab4b0e7b69f469e12e78d4a48b3ed7a66e (patch)
treea99191d8ebde57537e362f6053074609bf19d7cc /src/core
parentc6a373a26348544d944b08bf0c5dea4f72f6980b (diff)
core: only set the kernel's timezone when the RTC runs in local time
We can not reliably manage any notion of local time. Every daylight saving time change or time zone change by traveling will make the time jump, and the local time might jump backwards which creates unsolvable problems with file timestamps. We will no longer tell the kernel our local time zone and leave everything set to UTC. This will effectively turn FAT timestamps into UTC timestamps. If and only if the machine is configured to read the RTC in local time mode, the kernel's time zone will be configured, but systemd-timesysnc will disable the kernel's system time to RTC syncing. In this mode, the RTC will not be managed, and external tools like Windows bootups are expected to manage the RTC's time. https://bugs.freedesktop.org/show_bug.cgi?id=81538
Diffstat (limited to 'src/core')
-rw-r--r--src/core/main.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 29f97364a4..f67c003941 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1358,7 +1358,14 @@ int main(int argc, char *argv[]) {
if (clock_is_localtime() > 0) {
int min;
- /* The first-time call to settimeofday() does a time warp in the kernel */
+ /*
+ * The very first call of settimeofday() also does a time warp in the kernel.
+ *
+ * In the rtc-in-local time mode, we set the kernel's timezone, and rely on
+ * external tools to take care of maintaining the RTC and do all adjustments.
+ * This matches the behavior of Windows, which leaves the RTC alone if the
+ * registry tells that the RTC runs in UTC.
+ */
r = clock_set_timezone(&min);
if (r < 0)
log_error("Failed to apply local time delta, ignoring: %s", strerror(-r));
@@ -1366,19 +1373,19 @@ int main(int argc, char *argv[]) {
log_info("RTC configured in localtime, applying delta of %i minutes to system time.", min);
} else if (!in_initrd()) {
/*
- * Do dummy first-time call to seal the kernel's time warp magic
+ * Do a dummy very first call to seal the kernel's time warp magic.
*
* Do not call this this from inside the initrd. The initrd might not
* carry /etc/adjtime with LOCAL, but the real system could be set up
* that way. In such case, we need to delay the time-warp or the sealing
* until we reach the real system.
+ *
+ * Do no set the kernel's timezone. The concept of local time cannot
+ * be supported reliably, the time will jump or be incorrect at every daylight
+ * saving time change. All kernel local time concepts will be treated
+ * as UTC that way.
*/
- clock_reset_timezone();
-
- /* Tell the kernel our timezone */
- r = clock_set_timezone(NULL);
- if (r < 0)
- log_error("Failed to set the kernel's timezone, ignoring: %s", strerror(-r));
+ clock_reset_timewarp();
}
}