summaryrefslogtreecommitdiffstats
path: root/sys-utils/hwclock.c
diff options
context:
space:
mode:
authorJ William Piggott2017-08-06 17:39:33 +0200
committerJ William Piggott2017-08-25 00:30:39 +0200
commit404fdd2ca44af56e7074ea9324aea550087a1df6 (patch)
tree2c01308e88e00f9c58ba243b9086c35dda4b830a /sys-utils/hwclock.c
parentfdisk: add missing include (diff)
downloadkernel-qcow2-util-linux-404fdd2ca44af56e7074ea9324aea550087a1df6.tar.gz
kernel-qcow2-util-linux-404fdd2ca44af56e7074ea9324aea550087a1df6.tar.xz
kernel-qcow2-util-linux-404fdd2ca44af56e7074ea9324aea550087a1df6.zip
hwclock: move systz into hctosys
The set_system_clock_timezone() function is nearly identical to set_system_clock(). Three additional statements are required to include systz in hctosys. This patch is intentionally incomplete to make reviewing the actual required changes easier. Other patches in this set will: * remove set_system_clock_timezone() * fix messages and debugging * fix comments * and finally refactor set_system_clock() Signed-off-by: J William Piggott <elseifthen@gmx.com>
Diffstat (limited to 'sys-utils/hwclock.c')
-rw-r--r--sys-utils/hwclock.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 910e39f1c..e49f1a153 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -594,6 +594,7 @@ set_system_clock(const struct hwclock_control *ctl,
struct tm *broken;
int minuteswest;
int rc = 0;
+ const struct timezone tz_utc = { 0 };
broken = localtime(&newtime.tv_sec);
#ifdef HAVE_TM_GMTOFF
@@ -621,10 +622,15 @@ set_system_clock(const struct hwclock_control *ctl,
* mode does not clobber the Hardware Clock with UTC. This
* is only available on first call of settimeofday after boot.
*/
- if (!ctl->universal)
+ if (ctl->hctosys && !ctl->universal) /* set PCIL */
rc = settimeofday(tv_null, &tz);
- if (!rc)
+ if (ctl->systz && ctl->universal) /* lock warp_clock */
+ rc = settimeofday(tv_null, &tz_utc);
+ if (!rc && ctl->hctosys)
rc = settimeofday(&newtime, &tz);
+ else if (!rc)
+ rc = settimeofday(NULL, &tz);
+
if (rc) {
warn(_("settimeofday() failed"));
retcode = 1;
@@ -1024,7 +1030,7 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
}
if (ctl->systz)
- return set_system_clock_timezone(ctl);
+ return set_system_clock(ctl, startup_time);
if (ur->get_permissions())
return EX_NOPERM;