Deleted Added
full compact
2c2
< * Copyright (C) 1993, 1994, 1995 by Andrey A. Chernov, Moscow, Russia.
---
> * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.
29c29
< "@(#)Copyright (C) 1993, 1994, 1995 by Andrey A. Chernov, Moscow, Russia.\n\
---
> "@(#)Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.\n\
56a57,61
>
> #define True (1)
> #define False (0)
> #define Unknown (-1)
>
68c73
< int kern_offset;
---
> int kern_offset, wall_clock, disrtcset;
74,76c79,82
< int ch, init = -1;
< int initial_isdst = -1, final_isdst, looping;
< int disrtcset, need_restore = 0;
---
> int ch;
> int initial_isdst = -1, final_isdst;
> int need_restore = False, sleep_mode = False, looping,
> init = Unknown;
79c85
< while ((ch = getopt(argc, argv, "ai")) != EOF)
---
> while ((ch = getopt(argc, argv, "ais")) != EOF)
82c88
< if (init != -1)
---
> if (init != Unknown)
84c90
< init = 1;
---
> init = True;
87c93
< if (init != -1)
---
> if (init != Unknown)
89c95
< init = 0;
---
> init = False;
90a97,99
> case 's':
> sleep_mode = True;
> break;
94,95c103,104
< \tadjkerntz -i\t(initial call from /etc/rc)\n\
< \tadjkerntz -a\t(adjustment call from crontab)\n");
---
> \tadjkerntz -i\t\t(initial call from /etc/rc)\n\
> \tadjkerntz -a [-s]\t(adjustment call, -s for sleep/retry mode)\n");
98c107
< if (init == -1)
---
> if (init == Unknown)
99a109,110
> if (init)
> sleep_mode = True;
101,103d111
< if (access(_PATH_CLOCK, F_OK))
< return 0;
<
117c125,135
< again:
---
> if (init)
> wall_clock = (access(_PATH_CLOCK, F_OK) == 0);
> else {
> mib[0] = CTL_MACHDEP;
> mib[1] = CPU_WALLCLOCK;
> len = sizeof(wall_clock);
> if (sysctl(mib, 2, &wall_clock, &len, NULL, 0) == -1) {
> syslog(LOG_ERR, "sysctl(get_wallclock): %m");
> return 1;
> }
> }
118a137
> again:
125c144
< looping = 0;
---
> looping = False;
164c183,191
< "Nonexistent local time -- will retry after %d secs", REPORT_PERIOD);
---
> "Warning: nonexistent %s time.",
> utcsec == -1 && localsec == -1 ? "UTC time and local" :
> utcsec == -1 ? "UTC" : "local");
> if (!sleep_mode) {
> syslog(LOG_WARNING, "Giving up.");
> return 1;
> }
> syslog(LOG_WARNING, "Will retry after %d minutes.",
> REPORT_PERIOD / 60);
194c221
< looping++;
---
> looping = True;
210c237,245
< "Nonexistent (final) local time -- will retry after %d secs", REPORT_PERIOD);
---
> "Warning: nonexistent final %s time.",
> utcsec == -1 && localsec == -1 ? "UTC time and local" :
> utcsec == -1 ? "UTC" : "local");
> if (!sleep_mode) {
> syslog(LOG_WARNING, "Giving up.");
> return 1;
> }
> syslog(LOG_WARNING, "Will retry after %d minutes.",
> REPORT_PERIOD / 60);
239a275,276
> if (!wall_clock && stz == NULL)
> stv = NULL;
241,242c278,283
< /* if init and something will be changed, don't touch RTC at all */
< if (init && (stv != NULL || kern_offset != offset)) {
---
> /* if init or UTC clock and offset/date will be changed, */
> /* disable RTC modification for a while. */
>
> if ( (init && stv != NULL)
> || ((init || !wall_clock) && kern_offset != offset)
> ) {
252c293
< need_restore = 1;
---
> need_restore = True;
260,262c301,303
< if (( (init && (stv != NULL || stz != NULL))
< || (stz != NULL && stv == NULL)
< )
---
> if ( ( (init && (stv != NULL || stz != NULL))
> || (stz != NULL && stv == NULL)
> )
269c310,313
< /* init: don't write RTC, !init: write RTC */
---
> /* setting CPU_ADJKERNTZ have a side effect: resettodr(), which */
> /* can be disabled by CPU_DISRTCSET, so if init or UTC clock */
> /* -- don't write RTC, else write RTC. */
>
280a325,334
> if (init) {
> mib[0] = CTL_MACHDEP;
> mib[1] = CPU_WALLCLOCK;
> len = sizeof(wall_clock);
> if (sysctl(mib, 2, NULL, NULL, &wall_clock, len) == -1) {
> syslog(LOG_ERR, "sysctl(put_wallclock): %m");
> return 1;
> }
> }
>
282c336
< need_restore = 0;
---
> need_restore = False;
295,296c349,350
< if (init) {
< init = 0;
---
> if (init && wall_clock) {
> init = False;