Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.sys.dec Subject: Re: Resetting the Clock Message-ID: <7142@mimsy.UUCP> Date: Fri, 19-Jun-87 14:18:30 EDT Article-I.D.: mimsy.7142 Posted: Fri Jun 19 14:18:30 1987 Date-Received: Sat, 20-Jun-87 09:59:33 EDT References: <132@hal.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 149 Keywords: vax clock set In article <132@hal.UUCP> ane@hal.UUCP (Aydin "Bif" Edguer) writes: >How can I get the [Vax 11/750 running 4.3BSD] to reset the realtime >clock using the time-of-year clock without taking down the system? Without changing the kernel, you cannot. But why would you want to? 4.3BSD resets the time-of-year clock to track the realtime clock, since that is the one you adjust with `adjtime' and `date'. Incidentally, here is an adjtime command for 4.3BSD. #include #include #include #include struct timeval delta, olddelta; main(argc, argv) int argc; char **argv; { if (argc < 2) { timerclear(&delta); if (adjtime(&delta, &olddelta)) error(1, -1, "adjtime"); if (adjtime(&olddelta, &delta)) { showdelta("current adjustment", &olddelta); error(1, -1, "adjtime (readjust)"); } showdelta("current adjustment", &olddelta); exit(0); } if (convtime(&delta, argv[1])) error(1, 0, "invalid time spec %s (should be sec.usec)\n", argv[1]); if (adjtime(&delta, &olddelta)) error(1, -1, "adjtime"); showdelta("old adjustment", &olddelta); showdelta("new adjustment", &delta); exit(0); } convtime(tvp, s) register struct timeval *tvp; register char *s; { char *usec, *index(); int neg = 0; if (*s == '-') { neg++; s++; } usec = index(s, '.'); if (usec != NULL) { *usec++ = 0; if (convone(&tvp->tv_usec, usec)) return (-1); if (tvp->tv_usec > 999999) return (-1); } else tvp->tv_usec = 0; if (convone(&tvp->tv_sec, s)) return (-1); if (neg) { tvp->tv_usec = -tvp->tv_usec; tvp->tv_sec = -tvp->tv_sec; } return (0); } convone(lp, s) long *lp; register char *s; { register long l = 0; register int c; while ((c = *s++) != 0) { if (!isdigit(c)) return (-1); l *= 10; if (l < 0) return (-1); l += c - '0'; if (l < 0) return (-1); } *lp = l; return (0); } showdelta(what, tvp) char *what; struct timeval *tvp; { char *p = ""; if (tvp->tv_usec < 0) { tvp->tv_usec = -tvp->tv_usec; if (tvp->tv_sec == 0) p = "-"; } printf("%s: %s%ld.%06ld seconds\n", what, p, tvp->tv_sec, tvp->tv_usec); } #include char *_argv0; /* argv[0], set by C startup code */ /* * error - University of Maryland specific (sigh) * * Useful for printing error messages. Will print the program name * and (optionally) the system error associated with the values in * . */ error(quit, e, fmt, va_alist) int quit; register int e; char *fmt; va_dcl { extern char *sys_errlist[]; extern int sys_nerr, errno; va_list l; register char *p = _argv0; if (e < 0) e = errno; (void) fflush(stdout); /* somewhat gratuitous */ if (p != NULL) (void) fprintf(stderr, "%s: ", p); (void) vfprintf(stderr, fmt, l); if (e > 0) { if (e < sys_nerr) (void) fprintf(stderr, ": %s", sys_errlist[e]); else (void) fprintf(stderr, ": unknown error number %d", e); } (void) putc('\n', stderr); (void) fflush(stderr); if (quit) exit(quit); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris