diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-09-07 20:50:25 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-09-07 20:50:25 +0000 |
commit | bbd34987cd98fa78f8e96d9f066182d6bbfce051 (patch) | |
tree | 444a53bb5bc56b42c45eccfc11e9e2e811cf4e4b /sys/arch/hppa/dev | |
parent | f6cd6520d044cceae323da9db3392c122b6143d0 (diff) |
make inittodr() whine some sane things
Diffstat (limited to 'sys/arch/hppa/dev')
-rw-r--r-- | sys/arch/hppa/dev/clock.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c index 5feeab70369..ea011c7be4f 100644 --- a/sys/arch/hppa/dev/clock.c +++ b/sys/arch/hppa/dev/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.5 1999/08/14 03:56:12 mickey Exp $ */ +/* $OpenBSD: clock.c,v 1.6 1999/09/07 20:50:24 mickey Exp $ */ /* * Copyright (c) 1998,1999 Michael Shalayeff @@ -107,7 +107,15 @@ void inittodr(t) time_t t; { - static struct pdc_tod tod; + struct pdc_tod tod PDC_ALIGNMENT; + int tbad = 0; + long dt; + + if (t < 5*SECYR) { + printf ("WARNING: preposterous time in file system"); + t = 6*SECYR + 186*SECDAY + SECDAY/2; + tbad = 1; + } pdc_call((iodcio_t)PAGE0->mem_pdc, 1, PDC_TOD, PDC_TOD_READ, &tod, 0, 0, 0, 0, 0); @@ -115,10 +123,19 @@ inittodr(t) time.tv_sec = tod.sec; time.tv_usec = tod.usec; - if ((long)time.tv_sec < 0) { - time.tv_sec = SECYR * (1990 - 1970); - printf("WARNING: clock not initialized -- check and reset\n"); + if (!tbad) { + dt = time.tv_sec - t; + + if (dt < 0) + dt = -dt; + + if (dt < 2 * SECDAY) + return; + printf ("WARNING: clock %s %d days", + time.tv_sec < t? "lost" : "gained", dt / SECDAY); } + + printf (" -- CHECK AND RESET THE DATE!\n"); } /* |