Welcome, Guest. Please login or register.

Author Topic: Amiga UNIX Y2K problem...no problem?  (Read 2251 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline a_petri

  • Newbie
  • *
  • Join Date: Sep 2007
  • Posts: 1
    • Show all replies
Re: Amiga UNIX Y2K problem...no problem?
« on: September 27, 2007, 10:15:43 PM »
Dear Failure and Piru,

I have stumbled to this topic accidentally, as I had the same problem: after a long, arduous, but finally successful fight, I could install AMIX 2.1 to my Amiga 2000, and it worked, but it reset the date on every reboot.

I investigated the problem, and I found some interesting facts:

- The setclk command is able to handle the "three-digit" year format (e.g. 107 for 2007), but not the normal four-digit year format. It seems to be an internal limitation of the RTC device driver in the kernel (or the RTC chip itself).

- The date command is able to handle the four-digit year format, but not the three-digit format.

- The two commands call each other in a tricky way: setclk without arguments call date with an argument decoded from reading the RTC, and date with a single date argument calls setclk with the -s argument.

Therefore I tried to modify the argument passed to the date command in setclk.c to the four-digit year format.

My patch is the following (against Piru's version published here):

*** setclk.c.piru    Feb 11 10:41:14 2006
--- setclk.c      Thu Sep 27 02:56:26 2007
**************
*** 81,87 ****
--- 81,87 ----
      if (argc == 1)
      {
        time_t thetime = read_from_clock_device();
-       char buffer[BUFSIZ*2], tmpbuf[sizeof("MMDDhhmmYYY")];
+       char buffer[BUFSIZ*2], tmpbuf[sizeof("MMDDhhmmYYYY")];
 
        /*
        ** Set the system time to what the hardware thinks is correct.
***************
*** 96,101 ****
--- 96,109 ----
        }
 
        convert_time(thetime, tmpbuf);
+       if (tmpbuf[8] == '1')
+       {
+           tmpbuf[12] = tmpbuf[11];
+           tmpbuf[11] = tmpbuf[10];
+           tmpbuf[10] = tmpbuf[9];
+           tmpbuf[9] = '0';
+           tmpbuf[8] = '2';
+       }
        sprintf(buffer, "%s /usr/bin/date %s", bexleyTZ, tmpbuf);
        system(buffer);


With this patch, the compiled setclk binary seems to work correctly with both pre-Y2K and post-Y2K dates.