diff options
author | ache <ache@FreeBSD.org> | 1994-11-01 06:20:52 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-11-01 06:20:52 +0000 |
commit | d6c1596a6362147a682b9a908480d91cfbaa1104 (patch) | |
tree | b3137c22884118a25ce069cffdba7d9cd258fa20 /sbin/adjkerntz | |
parent | 3a85bbd3dd0da461d4cd5101620c0a5e08002ecd (diff) | |
download | FreeBSD-src-d6c1596a6362147a682b9a908480d91cfbaa1104.zip FreeBSD-src-d6c1596a6362147a682b9a908480d91cfbaa1104.tar.gz |
Now:
adjkerntz -i writes kernel clock only, don't touch RTC clock
adjkerntz -a writes RTC clock only, don't touch kernel clock
Diffstat (limited to 'sbin/adjkerntz')
-rw-r--r-- | sbin/adjkerntz/adjkerntz.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c index c804f3d..0e19bad 100644 --- a/sbin/adjkerntz/adjkerntz.c +++ b/sbin/adjkerntz/adjkerntz.c @@ -65,6 +65,7 @@ int main(argc, argv) long offset, utcsec, localsec, diff; time_t initial_sec, final_sec; int ch, init = -1, verbose = 0; + int disrtcset, need_restore = 0; while ((ch = getopt(argc, argv, "aiv")) != EOF) switch((char)ch) { @@ -181,17 +182,6 @@ int main(argc, argv) else stv = NULL; - if (kern_offset != offset) { - kern_offset = offset; - mib[0] = CTL_MACHDEP; - mib[1] = CPU_ADJKERNTZ; - len = sizeof(kern_offset); - if (sysctl(mib, 2, NULL, NULL, &kern_offset, len) == -1) { - perror("sysctl(update_offset)"); - return 1; - } - } - if (tz.tz_dsttime != 0 || tz.tz_minuteswest != 0) { tz.tz_dsttime = tz.tz_minuteswest = 0; /* zone info is garbage */ stz = &tz; @@ -200,8 +190,6 @@ int main(argc, argv) stz = NULL; if (stz != NULL || stv != NULL) { - int disrtcset, need_restore = 0; - if (init && stv != NULL) { mib[0] = CTL_MACHDEP; mib[1] = CPU_DISRTCSET; @@ -219,16 +207,28 @@ int main(argc, argv) } } } - if (settimeofday(stv, stz)) { + if ((init || stv == NULL) && settimeofday(stv, stz)) { perror("settimeofday"); return 1; } - if (need_restore) { - disrtcset = 0; - if (sysctl(mib, 2, NULL, NULL, &disrtcset, len) == -1) { - perror("sysctl(restore_disrtcset)"); - return 1; - } + } + + if (kern_offset != offset) { + kern_offset = offset; + mib[0] = CTL_MACHDEP; + mib[1] = CPU_ADJKERNTZ; + len = sizeof(kern_offset); + if (sysctl(mib, 2, NULL, NULL, &kern_offset, len) == -1) { + perror("sysctl(update_offset)"); + return 1; + } + } + + if (need_restore) { + disrtcset = 0; + if (sysctl(mib, 2, NULL, NULL, &disrtcset, len) == -1) { + perror("sysctl(restore_disrtcset)"); + return 1; } } |