aboutsummaryrefslogtreecommitdiff
path: root/sbin/adjkerntz/adjkerntz.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-10-04 19:15:13 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-10-04 19:15:13 +0000
commit025dc829715990d1847ffc0882813d1198e97929 (patch)
treee59ccfe94e709ec335e6f09db065432605588232 /sbin/adjkerntz/adjkerntz.c
parent03e4d516a4cc1d2518695dd0e0fba673d71857b4 (diff)
downloadsrc-025dc829715990d1847ffc0882813d1198e97929.tar.gz
src-025dc829715990d1847ffc0882813d1198e97929.zip
Modify adjkerntz to not write RTC clock per initial call,
suggested by Bruce
Notes
Notes: svn path=/head/; revision=3368
Diffstat (limited to 'sbin/adjkerntz/adjkerntz.c')
-rw-r--r--sbin/adjkerntz/adjkerntz.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c
index 7da39af03b67..c804f3dff908 100644
--- a/sbin/adjkerntz/adjkerntz.c
+++ b/sbin/adjkerntz/adjkerntz.c
@@ -101,8 +101,8 @@ int main(argc, argv)
len = sizeof(kern_offset);
if (sysctl(mib, 2, &kern_offset, &len, NULL, 0) == -1) {
perror("sysctl(get_offset)");
- return 1;
- }
+ return 1;
+ }
/****** Critical section, do all things as fast as possible ******/
@@ -200,10 +200,36 @@ 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;
+ len = sizeof(disrtcset);
+ if (sysctl(mib, 2, &disrtcset, &len, NULL, 0) == -1) {
+ perror("sysctl(get_disrtcset)");
+ return 1;
+ }
+ if (disrtcset == 0) {
+ disrtcset = 1;
+ need_restore = 1;
+ if (sysctl(mib, 2, NULL, NULL, &disrtcset, len) == -1) {
+ perror("sysctl(set_disrtcset)");
+ return 1;
+ }
+ }
+ }
if (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;
+ }
+ }
}
/****** End of critical section ******/