Package: adjtimex Version: 1.29-2.2 Severity: normal Tags: patch Dear Maintainer,
while "adjtimex" runs, the command "hwclock --show" does not work. The command keeps the device "/dev/rtc" open the whole time. It does not need to be open while the command sleeps, which is most of the time it is running. Necessary changes: a) Open the device inside the while loop (not in front of it) b) Close it before the program goes to sleep before the end of the while loop Other changes a) Fixed some code to eliminate warnings from the compiler b) Some cosmetic changes. Patch: --- adjtimex.c.original 2010-04-17 00:06:34.000000000 +0000 +++ adjtimex.c 2013-09-28 21:16:04.000000000 +0000 @@ -178,14 +178,14 @@ static void usage(void); static inline void outb (short port, char val); static inline void outb (short port, char val); static inline unsigned char inb (short port); -static void cmos_init (); -static void cmos_init_directisa (); +static void cmos_init (void); +static void cmos_init_directisa (void); static inline int cmos_read_bcd (int addr); static void cmos_read_time (time_t *cmos_timep, double *sysp); static void busywait_uip_fall(struct timeval *timestamp); static void busywait_second_change(struct tm *cmos, struct timeval *timestamp); static void compare(void); -static void failntpdate(); +static void failntpdate(char *); static void reset_time_status(void); static struct cmos_adj *get_cmos_adjustment(void); static void log_times(void); @@ -571,7 +571,7 @@ inb (short port) * Failing that, select and initialize direct I/O ports mode. */ static -void cmos_init () +void cmos_init (void) { /* following explanation taken from hwclock sources: @@ -630,7 +630,7 @@ void cmos_init () * second and following times). */ static -void cmos_init_directisa () +void cmos_init_directisa (void) { #ifdef USE_INLINE_ASM_IO if (verbose) @@ -680,7 +680,7 @@ cmos_read_bcd (int addr) static int timeout; /* An alarm signal has occurred */ static void -alarm_handler (int const dummy) { +alarm_handler (int const dummy __attribute__ ((unused)) ) { timeout = 1; } @@ -726,7 +726,7 @@ cmos_read_time (time_t *cmos_timep, doub int noint_fallback = 1; /* detect tick by 0 => uip, 1 => time change */ int got_tick = 0; int got_time = 0; - int saveerr; +/* int saveerr; */ int type_uie, count; double update_delay; @@ -797,13 +797,13 @@ cmos_read_time (time_t *cmos_timep, doub } } rc = read(cmos_fd, &interrupt_info, sizeof(interrupt_info)); - saveerr = errno; +/* saveerr = errno; */ gettimeofday(&now, NULL); if (rc == -1) { /* no timeout, but read(/dev/rtc) failed for another reason */ - char message[128]; + char message[BUFLEN]; snprintf(message, sizeof(message), "adjtimex: " "read() from %s to wait for clock tick failed", @@ -874,7 +874,7 @@ cmos_read_time (time_t *cmos_timep, doub Or: UIE interrupts do beat, but RTC is invalid. */ if (rc == -1) { - char message[128]; + char message[BUFLEN]; snprintf(message, sizeof(message), "adjtimex: " "ioctl(%s, RTC_RD_TIME) to read the CMOS clock failed", @@ -1072,7 +1072,7 @@ busywait_second_change(struct tm *cmos, that the RTC isn't running or contains invalid data */ if (rc == -1) { - char message[128]; + char message[BUFLEN]; snprintf(message, sizeof(message), "adjtimex: " "ioctl(%s, RTC_RD_TIME) to read the CMOS clock failed", @@ -1165,10 +1165,10 @@ cmos clock last adjusted at Tue Aug 26 1 } #endif - cmos_init (); - while (count != 0) { + cmos_init (); + if (count > 0) count--; cmos_read_time (&cmos_time, &system_sec); @@ -1244,6 +1244,8 @@ cmos time system-cmos error_ppm t printf ("%10ld %13.6f", (long) cmos_sec, dif); + if (loops == 0) + printf ("%11s %6ld %9ld", " ", txc.tick, txc.freq); if (++loops > 1) { /* print difference in rates */ #define SHIFT (1<<16) @@ -1264,7 +1266,7 @@ cmos time system-cmos error_ppm t txc.tick + tick_delta, txc.freq + freq_delta); if (loops > 4 && adjusting) { - if (abs(error_ppm)>10000) + if (abs(error_ppm) > 10000) { if (!force_adjust) { @@ -1298,6 +1300,10 @@ cmos time system-cmos error_ppm t dif_prev = dif; if (interval == 0) break; +/* Release read access to cmos clock (/dev/rtc) while sleeping */ +/* Otherwise others can't access the clock ("hwclock --show" does not work) */ + close(cmos_fd); + using_dev_rtc = -1; if (count) /* if it is not the last round */ xusleep (interval*1000000L - 500000); /* reading RTC takes 1 sec */ } @@ -1335,8 +1341,8 @@ static void log_times() struct hostent he; #endif double sigma_ref; - char ch, buf[64], *s; - int n, ret; + char ch __attribute__ ((unused)), buf[64], *s; + int n, ret __attribute__ ((unused)); struct timeval tv_sys; struct tm bdt; time_t when, tref; @@ -1397,9 +1403,10 @@ static void log_times() else if (timeserver) { FILE *ifile; - char command[128]; + char command[BUFLEN]; char buf[BUFLEN]; - int i, j; + unsigned int i; + int j; double d, mean=0, val, var=0, num=0; /* for finding statistics */ struct stat filestat; @@ -2154,7 +2161,7 @@ void review() error_ppm += tick_delta*hz; printf(" suggested tick = %5ld freq = %9.0f\n", tick_mid + tick_delta, -error_ppm*SHIFT); - if (abs(error_ppm)>500) + if (abs(error_ppm) > 500) printf ("WARNING: required correction is greater " "than plus/minus 500 parts per million.\n"); } @@ -2171,7 +2178,7 @@ void review() "least squares solution has a bigger error than estimated here\n"); if (sigma_ppm < 100 && adjusting) { - if (abs(error_ppm)>500) + if (abs(error_ppm) > 500) { if (force_adjust) printf ( -- System Information: Debian Release: 7.1 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable') Architecture: i386 (i586) Kernel: Linux 3.2.46-1-rt67-1 Locale: LANG=is_IS, LC_CTYPE=is_IS (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/dash Versions of packages adjtimex depends on: ii debconf [debconf-2.0] 1.5.49 ii libc6 2.13-38 adjtimex recommends no packages. Versions of packages adjtimex suggests: ii ntpdate 1:4.2.6.p5+dfsg-2 -- Configuration Files: /etc/init.d/adjtimex changed [not included] -- debconf information: adjtimex/run_daemon: true adjtimex/compare_rtc: true -- Bjarni I. Gislason -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org