Now:
adjkerntz -i writes kernel clock only, don't touch RTC clock adjkerntz -a writes RTC clock only, don't touch kernel clock
This commit is contained in:
parent
0c8e8c63a8
commit
0835483992
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4039
@ -65,6 +65,7 @@ int main(argc, argv)
|
|||||||
long offset, utcsec, localsec, diff;
|
long offset, utcsec, localsec, diff;
|
||||||
time_t initial_sec, final_sec;
|
time_t initial_sec, final_sec;
|
||||||
int ch, init = -1, verbose = 0;
|
int ch, init = -1, verbose = 0;
|
||||||
|
int disrtcset, need_restore = 0;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "aiv")) != EOF)
|
while ((ch = getopt(argc, argv, "aiv")) != EOF)
|
||||||
switch((char)ch) {
|
switch((char)ch) {
|
||||||
@ -181,17 +182,6 @@ int main(argc, argv)
|
|||||||
else
|
else
|
||||||
stv = NULL;
|
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) {
|
if (tz.tz_dsttime != 0 || tz.tz_minuteswest != 0) {
|
||||||
tz.tz_dsttime = tz.tz_minuteswest = 0; /* zone info is garbage */
|
tz.tz_dsttime = tz.tz_minuteswest = 0; /* zone info is garbage */
|
||||||
stz = &tz;
|
stz = &tz;
|
||||||
@ -200,8 +190,6 @@ int main(argc, argv)
|
|||||||
stz = NULL;
|
stz = NULL;
|
||||||
|
|
||||||
if (stz != NULL || stv != NULL) {
|
if (stz != NULL || stv != NULL) {
|
||||||
int disrtcset, need_restore = 0;
|
|
||||||
|
|
||||||
if (init && stv != NULL) {
|
if (init && stv != NULL) {
|
||||||
mib[0] = CTL_MACHDEP;
|
mib[0] = CTL_MACHDEP;
|
||||||
mib[1] = CPU_DISRTCSET;
|
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");
|
perror("settimeofday");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (need_restore) {
|
}
|
||||||
disrtcset = 0;
|
|
||||||
if (sysctl(mib, 2, NULL, NULL, &disrtcset, len) == -1) {
|
if (kern_offset != offset) {
|
||||||
perror("sysctl(restore_disrtcset)");
|
kern_offset = offset;
|
||||||
return 1;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user