]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: move systz into hctosys
authorJ William Piggott <elseifthen@gmx.com>
Sun, 6 Aug 2017 15:39:33 +0000 (11:39 -0400)
committerJ William Piggott <elseifthen@gmx.com>
Thu, 24 Aug 2017 22:30:39 +0000 (18:30 -0400)
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>
sys-utils/hwclock.c

index 910e39f1cd57b464416d9456e54b6014bc22f120..e49f1a153f5060d45004e6259e5bba31373d03ae 100644 (file)
@@ -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;