mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
rtc: restore time from driftfile if later than RTC time
This is useful on computers that have an RTC, but there is no battery to keep the time when they are turned off and start with the same time on each boot.
This commit is contained in:
@@ -974,7 +974,7 @@ RTC_Linux_WriteParameters(void)
|
||||
RTC behaviour than we do for the rest of the module. */
|
||||
|
||||
int
|
||||
RTC_Linux_TimePreInit(void)
|
||||
RTC_Linux_TimePreInit(time_t driftfile_time)
|
||||
{
|
||||
int fd, status;
|
||||
struct rtc_time rtc_raw, rtc_raw_retry;
|
||||
@@ -1039,6 +1039,11 @@ RTC_Linux_TimePreInit(void)
|
||||
|
||||
UTI_AddDoubleToTimeval(&new_sys_time, -accumulated_error, &new_sys_time);
|
||||
|
||||
if (new_sys_time.tv_sec < driftfile_time) {
|
||||
LOG(LOGS_WARN, LOGF_RtcLinux, "RTC time before last driftfile modification (ignored)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
UTI_DiffTimevalsToDouble(&sys_offset, &old_sys_time, &new_sys_time);
|
||||
|
||||
/* Set system time only if the step is larger than 1 second */
|
||||
|
||||
Reference in New Issue
Block a user