In current versions of util-linux 2.13.1.1, the hwclock.sh script allows for
a single boolean degree of freedom to determine one of two behaviors:

A)

HWCLOCKACCESS can be set to "no" to prevent hardware-clock (HC) to system-clock
(Sys) time transfer on startup and likewise prevent Sys to HC time transfer on
shutdown.

B)

HWCLOCKACCESS can be set to anything else and it causes both HC to Sys time
transfer on startup and likewise ensures Sys to HC time transfer on shutdown.

--

This may be inflexible in certain situations.  For example, some users
may want to load their system clock from the hardware clock on startup,
but might not want to save the time on shutdown each time.  This can be
useful when working with other operating systems that might run ntp type
daemons (or other utilities) to control the system clock.

In the bug reported here, the user claims that there is no effect from
changing the UTC setting from no to yes as per the Debian documentation.
I think that perhaps there is, indeed, an effect, but it is invisible.
This can be demonstrated by trying both settings but using the command

sudo hwclock --show

in the two configurations, UTC=no and UTC=yes and verifying that the
output is different for people outside the +0 timezone.

pcman probably thinks the option has no effect because when the timezone
setting is changed, the system clock gets saved to the CMOS with the new
setting and then when the system reboots it will load the saved time and
cause the system time to appear continuous despite the naive expectation
that it should appear different because the user did not expect the hardware
clock to be modified.  This assumption can often interfere with other operating
systems use of the hardware clock and therefore we should allow for the common
case where people want to load from the hardware clock on startup but not save.
The attached one-line patch modifies hwclock.sh to allow for another optional
configuration variable to be added to /etc/default/rcS so that this new
behavior, hctosys transfer allowed but systohc disallowed, so that one can
optionally set

HWCLOCKSYSTOHC=no

so that even though HWCLOCKACCESS=yes there is no Sys to HC saving on shutdown.
Thus, this patch is fully backward compatible with existing defined
interpretations but allows for an easy fix to this common temporal problem.

diff -u util-linux-2.13.1.1/debian/hwclock.sh 
util-linux-2.13.1.1/debian/hwclock.sh
--- util-linux-2.13.1.1/debian/hwclock.sh
+++ util-linux-2.13.1.1/debian/hwclock.sh
@@ -122,7 +122,7 @@
            # WARNING: If you disable this, any changes to the system
            #          clock will not be carried across reboots.
            #
-           if [ "$HWCLOCKACCESS" != no ]; then
+           if [ "$HWCLOCKACCESS" != no -a "$HWCLOCKSYSTOHC" != no ]; then
                log_action_msg "Saving the system clock"
                if [ "$GMT" = "-u" ]; then
                    GMT="--utc"

Attachment: signature.asc
Description: Digital signature

Reply via email to