Subject: clock -w writes bogus date

From: Bill Wohler <[email-masked]>
Date: Wed, 28 Aug 1996 01:05:06 -0700

Package: util-linux
Version: 2.5-5
  
  "clock -w" is screwing up the CMOS clock.  See:

	# cat /etc/timezone
	US/Pacific
	# clock -r
	Wed Aug 28 00:52:27 1996
	# date
	Wed Aug 28 00:51:54 PDT 1996
	# clock -w
	# clock -r
	Mon Aug 11 00:07:58 2031
	# clock -wu
	Segmentation fault (core dumped)
	# clock -r
	<hangs: goes into tight loop>

  Is there anything here I'm missing (e.g., related
  programs/packages/settings)?  The segmentation violation and hanging
  of clock -r is worth a bug report to be sure, but could the -w
  failure be a mis-configuration of the timezone or Universal time on
  my part?  I had answered "no" to the Universal time question at
  install (due to !@#$# DOS).  I just ran tzconfig to change
  /etc/timezone from Factory to US/Pacific thinking that was my
  problem.

Bill Wohler <[email-masked]>   ph: +1-415-854-1857  fax: +1-415-854-3195
Say it with MIME.  Maintainer of comp.mail.mh and news.software.nn FAQs.
If you're passed on the right, you're in the wrong lane.

---

From: [email-masked] (Ervin D. Walter)
Date: Wed, 28 Aug 1996 09:47:12 -0500

>   "clock -w" is screwing up the CMOS clock.  See:

You are not alone.  clock has not worked for me at all with this
release.  I had the same symptoms and I had do downgrade to 2.5-4.

Erv

-- 
                                ____
----==-- _                     / /  \         
---==---(_)__  __ ____  __    / / /\ \	                  - Erv Walter
--==---/ / _ \/ // /\ \/ /   / /_/\ \ \             - [email-masked]
-=====/_/_//_/\_,_/ /_/\_\  /______\ \ \  - [email-masked]
   http://www.linux.org     \_________\/

---

From: [email-masked] (David Engel)
Date: Wed, 28 Aug 1996 10:38:27 -0500 (CDT)

Bill Wohler writes:
> ...

This has already been reported in Bug#4265.  Here is a quick patch to
clock.c in util-linux that fixed it for me:

David
-- 
David Engel                        Optical Data Systems, Inc.
[email-masked]                      1101 E. Arapaho Road
(214) 234-6400                     Richardson, TX  75081

--- clock.c.orig        Mon Aug 26 10:26:53 1996
+++ clock.c     Mon Aug 26 10:31:38 1996
@@ -365,7 +365,7 @@
     }

     /* Read the RTC time/date */
-    retval = ioctl(cmos_fd, RTC_RD_TIME, &tm);
+    retval = ioctl(cmos_fd, RTC_RD_TIME, tm);
     if (retval == -1) {
       perror("ioctl");
       exit(errno);
@@ -463,7 +463,7 @@

     int retval;

-    retval = ioctl(cmos_fd, RTC_SET_TIME, tmp);
+    retval = ioctl(cmos_fd, RTC_SET_TIME, tm);
     if (retval == -1) {
       perror("ioctl");
       exit(errno);

---

From: "Larry 'Daffy' Daffner" <[email-masked]>
Date: Wed, 28 Aug 1996 19:03:57 -0500

Bill Wohler writes:
-> Package: util-linux
-> Version: 2.5-5
->   
->   "clock -w" is screwing up the CMOS clock.  See:
-> 
-> 	# cat /etc/timezone
-> 	US/Pacific
-> 	# clock -r
-> 	Wed Aug 28 00:52:27 1996
-> 	# date
-> 	Wed Aug 28 00:51:54 PDT 1996
-> 	# clock -w
-> 	# clock -r
-> 	Mon Aug 11 00:07:58 2031
-> 	# clock -wu
-> 	Segmentation fault (core dumped)
-> 	# clock -r
-> 	<hangs: goes into tight loop>
-> 
->   Is there anything here I'm missing (e.g., related
->   programs/packages/settings)?  The segmentation violation and hanging
->   of clock -r is worth a bug report to be sure, but could the -w
->   failure be a mis-configuration of the timezone or Universal time on
->   my part?  I had answered "no" to the Universal time question at
->   install (due to !@#$# DOS).  I just ran tzconfig to change
->   /etc/timezone from Factory to US/Pacific thinking that was my
->   problem.
-> 

This appears to be a bug in clock from util-linux.  Using "clock" from
this package with the Real time clock enabled in the kernel will cause
a segfault.  I ran into this same problem, and worked around it by
building a hernel with the RTC disabled. Hadn't gotten around to
submitting a bug report yet.  The workarounds seem to be:

1) set the system clock to UTC.
2) downgrade util-linux, or
3) build a kernel with the RTC disabled

-Larry

--
  Larry Daffner        |  Linux: Unleash the workstation in your PC!
  [email-masked] / http://web2.airmail.net/vizzie/
Whenever you find yourself on the side of the majority, it is time to
pause and reflect." - Mark Twain