From d3c36882dc5bc5fcede9a45a6bc7a39570fba7d0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Dec 2020 20:55:30 +0100 Subject: hwclock: improve --help (-l is a compatible shortcut for --localtime) function old new delta packed_usage 33605 33568 -37 Signed-off-by: Denys Vlasenko --- util-linux/hwclock.c | 69 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to 'util-linux') diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 44cb4794e..77aa2d7c3 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -153,14 +153,12 @@ static void set_kernel_tz(const struct timezone *tz) * then system time is wrong - it is offset by timezone. * --systz option corrects system time if RTC is in local time, * and (always) sets in-kernel timezone. - * - * This is an alternate option to --hctosys that does not read the - * hardware clock. + * (Unlike --hctosys, it does not read the RTC). * * util-linux's code has this comment: * RTC | settimeofday calls * ------|------------------------------------------------- - * Local | 1) warps system time*, sets PCIL* and kernel tz + * Local | 1st) warps system time*, sets PCIL* and kernel tz * UTC | 1st) locks warp_clock 2nd) sets kernel tz * * only on first call after boot * (PCIL is "persistent_clock_is_local" kernel internal flag, @@ -177,6 +175,9 @@ static void set_kernel_timezone_and_clock(int utc, const struct timeval *hctosys set_kernel_tz(&tz); /* Set kernel's timezone offset based on userspace one */ +//It's tempting to call tzset() and use libc global "timezone" variable +//...but it does NOT include DST shift (IOW: it's WRONG, usually by one hour, +//if DST is in effect!) Thus this ridiculous dance: cur = time(NULL); broken = localtime(&cur); tz.tz_minuteswest = -broken->tm_gmtoff / 60; @@ -321,30 +322,58 @@ static void from_sys_clock(const char **pp_rtcname, int utc) close(rtc); } +// hwclock from util-linux 2.36.1 +// hwclock [function] [option...] +//Functions: +// -r, --show display the RTC time +// --get display drift corrected RTC time +// --set set the RTC according to --date +// -s, --hctosys set the system time from the RTC +// -w, --systohc set the RTC from the system time +// --systz send timescale configurations to the kernel +// -a, --adjust adjust the RTC to account for systematic drift +// --predict predict the drifted RTC time according to --date +//Options: +// -u, --utc the RTC timescale is UTC +// -l, --localtime the RTC timescale is Local +// -f, --rtc use an alternate file to /dev/rtc0 +// --directisa use the ISA bus instead of /dev/rtc0 access +// --date