diff options
author | J William Piggott | 2017-07-30 22:22:49 +0200 |
---|---|---|
committer | J William Piggott | 2017-08-04 14:53:44 +0200 |
commit | 1ef6feb533ec7f45e6264189ad7ed93f616564ea (patch) | |
tree | 739ca4ad16b112f715a58aef914fc490ef57e57d /sys-utils | |
parent | hwclock: fix RTC read logic (diff) | |
download | kernel-qcow2-util-linux-1ef6feb533ec7f45e6264189ad7ed93f616564ea.tar.gz kernel-qcow2-util-linux-1ef6feb533ec7f45e6264189ad7ed93f616564ea.tar.xz kernel-qcow2-util-linux-1ef6feb533ec7f45e6264189ad7ed93f616564ea.zip |
hwclock: correlate hclocktime instead of set_time.
Correlate hclocktime with set_time instead of the other way around,
because set_time is used for timestamps in the adjtime file so it needs
to be unadulterated.
Also create var startup_hclocktime for correlated time.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/hwclock.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index e172fb1bf..df6b59e86 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1029,9 +1029,14 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, bool hclock_valid = FALSE; /* * Tick synchronized time read from the Hardware Clock and - * then drift correct for all operations except --show. + * then drift corrected for all operations except --show. */ - struct timeval hclocktime = { 0, 0 }; + struct timeval hclocktime = { 0 }; + /* + * hclocktime correlated to startup_time. That is, what drift + * corrected Hardware Clock time would have been at start up. + */ + struct timeval startup_hclocktime = { 0 }; /* Total Hardware Clock drift correction needed. */ struct timeval tdrift; @@ -1096,18 +1101,17 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, hclocktime.tv_sec, &tdrift); if (!ctl->show) hclocktime = time_inc(tdrift, hclocktime.tv_sec); + + startup_hclocktime = + time_inc(hclocktime, time_diff(startup_time, read_time)); } if (ctl->show || ctl->get) { - display_time(hclock_valid, - time_inc(hclocktime, -time_diff - (read_time, startup_time))); + display_time(hclock_valid, startup_hclocktime); } else if (ctl->set) { set_hardware_clock_exact(ctl, set_time, startup_time); if (!ctl->noadjfile) - adjust_drift_factor(ctl, adjtime, - time_inc(t2tv(set_time), time_diff - (read_time, startup_time)), - hclock_valid, hclocktime); + adjust_drift_factor(ctl, adjtime, t2tv(set_time), + hclock_valid, startup_hclocktime); } else if (ctl->adjust) { if (tdrift.tv_sec > 0 || tdrift.tv_sec < -1) do_adjustment(ctl, adjtime, hclock_valid, |