Deleted Added
full compact
adjkerntz.c (158444) adjkerntz.c (158516)
1/*
2 * Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27#if 0
28#ifndef lint
29static const char copyright[] =
30"@(#)Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.\n\
31 All rights reserved.\n";
32#endif /* not lint */
33#endif
34#include <sys/cdefs.h>
1/*
2 * Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27#if 0
28#ifndef lint
29static const char copyright[] =
30"@(#)Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.\n\
31 All rights reserved.\n";
32#endif /* not lint */
33#endif
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sbin/adjkerntz/adjkerntz.c 158444 2006-05-11 17:25:36Z phk $");
35__FBSDID("$FreeBSD: head/sbin/adjkerntz/adjkerntz.c 158516 2006-05-13 11:58:58Z pjd $");
36
37/*
38 * Andrey A. Chernov <ache@astral.msk.su> Dec 20 1993
39 *
40 * Fix kernel time value if machine run wall CMOS clock
41 * (and /etc/wall_cmos_clock file present)
42 * using zoneinfo rules or direct TZ environment variable set.
43 * Use Joerg Wunsch idea for seconds accurate offset calculation

--- 236 unchanged lines hidden (view full) ---

280 /* if init or UTC clock and offset/date will be changed, */
281 /* disable RTC modification for a while. */
282
283 if ( (init && stv != NULL)
284 || ((init || !wall_clock) && kern_offset != offset)
285 ) {
286 len = sizeof(disrtcset);
287 if (sysctlbyname("machdep.disable_rtc_set", &disrtcset, &len, NULL, 0) == -1) {
36
37/*
38 * Andrey A. Chernov <ache@astral.msk.su> Dec 20 1993
39 *
40 * Fix kernel time value if machine run wall CMOS clock
41 * (and /etc/wall_cmos_clock file present)
42 * using zoneinfo rules or direct TZ environment variable set.
43 * Use Joerg Wunsch idea for seconds accurate offset calculation

--- 236 unchanged lines hidden (view full) ---

280 /* if init or UTC clock and offset/date will be changed, */
281 /* disable RTC modification for a while. */
282
283 if ( (init && stv != NULL)
284 || ((init || !wall_clock) && kern_offset != offset)
285 ) {
286 len = sizeof(disrtcset);
287 if (sysctlbyname("machdep.disable_rtc_set", &disrtcset, &len, NULL, 0) == -1) {
288 syslog(LOG_ERR, "sysctl(get: \"disable_rtc_set\"): %m");
288 syslog(LOG_ERR, "sysctl(get: \"machdep.disable_rtc_set\"): %m");
289 return 1;
290 }
291 if (disrtcset == 0) {
292 disrtcset = 1;
293 need_restore = True;
289 return 1;
290 }
291 if (disrtcset == 0) {
292 disrtcset = 1;
293 need_restore = True;
294 if (sysctlbyname("disable_rtc_set", NULL, NULL, &disrtcset, len) == -1) {
295 syslog(LOG_ERR, "sysctl(set: \"disable_rtc_set\"): %m");
294 if (sysctlbyname("machdep.disable_rtc_set", NULL, NULL, &disrtcset, len) == -1) {
295 syslog(LOG_ERR, "sysctl(set: \"machdep.disable_rtc_set\"): %m");
296 return 1;
297 }
298 }
299 }
300
301 if ( (init && (stv != NULL || stz != NULL))
302 || (stz != NULL && stv == NULL)
303 ) {

--- 21 unchanged lines hidden (view full) ---

325 /* setting machdep.adjkerntz have a side effect: resettodr(), which */
326 /* can be disabled by machdep.disable_rtc_set, so if init or UTC clock */
327 /* -- don't write RTC, else write RTC. */
328
329 if (kern_offset != offset) {
330 kern_offset = offset;
331 len = sizeof(kern_offset);
332 if (sysctlbyname("machdep.adjkerntz", NULL, NULL, &kern_offset, len) == -1) {
296 return 1;
297 }
298 }
299 }
300
301 if ( (init && (stv != NULL || stz != NULL))
302 || (stz != NULL && stv == NULL)
303 ) {

--- 21 unchanged lines hidden (view full) ---

325 /* setting machdep.adjkerntz have a side effect: resettodr(), which */
326 /* can be disabled by machdep.disable_rtc_set, so if init or UTC clock */
327 /* -- don't write RTC, else write RTC. */
328
329 if (kern_offset != offset) {
330 kern_offset = offset;
331 len = sizeof(kern_offset);
332 if (sysctlbyname("machdep.adjkerntz", NULL, NULL, &kern_offset, len) == -1) {
333 syslog(LOG_ERR, "sysctl(set: \"disable_rtc_set\"): %m");
333 syslog(LOG_ERR, "sysctl(set: \"machdep.adjkerntz\"): %m");
334 return 1;
335 }
336 }
337
338 len = sizeof(wall_clock);
339 if (sysctlbyname("machdep.wall_cmos_clock", NULL, NULL, &wall_clock, len) == -1) {
340 syslog(LOG_ERR, "sysctl(set: \"machdep.wall_cmos_clock\"): %m");
341 return 1;

--- 34 unchanged lines hidden ---
334 return 1;
335 }
336 }
337
338 len = sizeof(wall_clock);
339 if (sysctlbyname("machdep.wall_cmos_clock", NULL, NULL, &wall_clock, len) == -1) {
340 syslog(LOG_ERR, "sysctl(set: \"machdep.wall_cmos_clock\"): %m");
341 return 1;

--- 34 unchanged lines hidden ---