summaryrefslogtreecommitdiffstats
path: root/sbin/adjkerntz
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-10-04 19:15:13 +0000
committerache <ache@FreeBSD.org>1994-10-04 19:15:13 +0000
commitff7b200770876c0d9812237ebebb6f4e48ea2c23 (patch)
treee59ccfe94e709ec335e6f09db065432605588232 /sbin/adjkerntz
parent9372070b25c0c5c21b56fcc0aa3cf2a3e17158e8 (diff)
downloadFreeBSD-src-ff7b200770876c0d9812237ebebb6f4e48ea2c23.zip
FreeBSD-src-ff7b200770876c0d9812237ebebb6f4e48ea2c23.tar.gz
Modify adjkerntz to not write RTC clock per initial call,
suggested by Bruce
Diffstat (limited to 'sbin/adjkerntz')
-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 7da39af..c804f3d 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 ******/
OpenPOWER on IntegriCloud