Revert "resolved: apply epoch to system time from PID 1" 59/182759/1 accepted/tizen/unified/20180704.154010 submit/tizen/20180704.010647
authorHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 27 Jun 2018 10:47:30 +0000 (19:47 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 28 Jun 2018 00:25:50 +0000 (00:25 +0000)
This reverts commit 021dd87bc055a5bfb2dcef83fc868fe24648b959.

In Tizen Watch products, users can set the RTC as they want, even to the past.
Here, it has been observed that the system clock is reset every booting.

For instance,
1) After a boot, Kernel RTC is 2018-01-02.

2) Since the system clock initialized by RTC is 2018-01-02 is less than 2018-06-27 (TIME_EPOCH_USEC),
Systemd resets the system clock as TIME_EPOCH_USEC, but does not modify RTC.
Although the system clock shown to users is not an intended value, the time goes by to 2018-06-28.

3) After another reboot, the system clock is restored to 2018-06-27 (TIME_EPOCH_USEC)
because RTC is still less than TIME_EPOCH_USEC.

Change-Id: Ib2c61e9b1fd9d4b0d33f99868dda1daaec21878d
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/basic/clock-util.c
src/basic/clock-util.h
src/core/main.c

index 7fe8d35..3b617c0 100644 (file)
@@ -149,17 +149,3 @@ int clock_reset_timewarp(void) {
 
         return 0;
 }
-
-#define TIME_EPOCH_USEC ((usec_t) TIME_EPOCH * USEC_PER_SEC)
-
-int clock_apply_epoch(void) {
-        struct timespec ts;
-
-        if (now(CLOCK_REALTIME) >= TIME_EPOCH_USEC)
-                return 0;
-
-        if (clock_settime(CLOCK_REALTIME, timespec_store(&ts, TIME_EPOCH_USEC)) < 0)
-                return -errno;
-
-        return 1;
-}
index 8830cd2..facf933 100644 (file)
@@ -26,4 +26,3 @@ int clock_set_timezone(int *min);
 int clock_reset_timewarp(void);
 int clock_get_hwclock(struct tm *tm);
 int clock_set_hwclock(const struct tm *tm);
-int clock_apply_epoch(void);
index f2adca7..9c9d073 100644 (file)
@@ -1461,14 +1461,8 @@ int main(int argc, char *argv[]) {
                                  * saving time change. All kernel local time concepts will be treated
                                  * as UTC that way.
                                  */
-                                (void) clock_reset_timewarp();
+                                clock_reset_timewarp();
                         }
-
-                        r = clock_apply_epoch();
-                        if (r < 0)
-                                log_error_errno(r, "Current system time is before build time, but cannot correct: %m");
-                        else if (r > 0)
-                                log_info("System time before build time, advancing clock.");
                 }
 
                 /* Set the default for later on, but don't actually