Deleted Added
full compact
kern_ntptime.c (146722) kern_ntptime.c (164033)
1/*-
2 ***********************************************************************
3 * *
4 * Copyright (c) David L. Mills 1993-2001 *
5 * *
6 * Permission to use, copy, modify, and distribute this software and *
7 * its documentation for any purpose and without fee is hereby *
8 * granted, provided that the above copyright notice appears in all *

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

26 * in this file.
27 *
28 * Only minor changes done to interface with the timecounters over in
29 * sys/kern/kern_clock.c. Some of the comments below may be (even more)
30 * confusing and/or plain wrong in that context.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 ***********************************************************************
3 * *
4 * Copyright (c) David L. Mills 1993-2001 *
5 * *
6 * Permission to use, copy, modify, and distribute this software and *
7 * its documentation for any purpose and without fee is hereby *
8 * granted, provided that the above copyright notice appears in all *

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

26 * in this file.
27 *
28 * Only minor changes done to interface with the timecounters over in
29 * sys/kern/kern_clock.c. Some of the comments below may be (even more)
30 * confusing and/or plain wrong in that context.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/kern/kern_ntptime.c 146722 2005-05-28 14:34:41Z rwatson $");
34__FBSDID("$FreeBSD: head/sys/kern/kern_ntptime.c 164033 2006-11-06 13:42:10Z rwatson $");
35
36#include "opt_ntp.h"
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/sysproto.h>
41#include <sys/kernel.h>
35
36#include "opt_ntp.h"
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/sysproto.h>
41#include <sys/kernel.h>
42#include <sys/priv.h>
42#include <sys/proc.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/time.h>
46#include <sys/timex.h>
47#include <sys/timetc.h>
48#include <sys/timepps.h>
49#include <sys/syscallsubr.h>

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

328 * Note that either the time constant or TAI offset are loaded
329 * from the ntv.constant member, depending on the mode bits. If
330 * the STA_PLL bit in the status word is cleared, the state and
331 * status words are reset to the initial values at boot.
332 */
333 mtx_lock(&Giant);
334 modes = ntv.modes;
335 if (modes)
43#include <sys/proc.h>
44#include <sys/lock.h>
45#include <sys/mutex.h>
46#include <sys/time.h>
47#include <sys/timex.h>
48#include <sys/timetc.h>
49#include <sys/timepps.h>
50#include <sys/syscallsubr.h>

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

329 * Note that either the time constant or TAI offset are loaded
330 * from the ntv.constant member, depending on the mode bits. If
331 * the STA_PLL bit in the status word is cleared, the state and
332 * status words are reset to the initial values at boot.
333 */
334 mtx_lock(&Giant);
335 modes = ntv.modes;
336 if (modes)
336 error = suser(td);
337 error = priv_check(td, PRIV_NTP_ADJTIME);
337 if (error)
338 goto done2;
339 s = splclock();
340 if (modes & MOD_MAXERROR)
341 time_maxerror = ntv.maxerror;
342 if (modes & MOD_ESTERROR)
343 time_esterror = ntv.esterror;
344 if (modes & MOD_STATUS) {

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

949}
950
951int
952kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta)
953{
954 struct timeval atv;
955 int error;
956
338 if (error)
339 goto done2;
340 s = splclock();
341 if (modes & MOD_MAXERROR)
342 time_maxerror = ntv.maxerror;
343 if (modes & MOD_ESTERROR)
344 time_esterror = ntv.esterror;
345 if (modes & MOD_STATUS) {

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

950}
951
952int
953kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta)
954{
955 struct timeval atv;
956 int error;
957
957 if ((error = suser(td)))
958 if ((error = priv_check(td, PRIV_ADJTIME)))
958 return (error);
959
960 mtx_lock(&Giant);
961 if (olddelta) {
962 atv.tv_sec = time_adjtime / 1000000;
963 atv.tv_usec = time_adjtime % 1000000;
964 if (atv.tv_usec < 0) {
965 atv.tv_usec += 1000000;
966 atv.tv_sec--;
967 }
968 *olddelta = atv;
969 }
970 if (delta)
971 time_adjtime = (int64_t)delta->tv_sec * 1000000 +
972 delta->tv_usec;
973 mtx_unlock(&Giant);
974 return (error);
975}
976
959 return (error);
960
961 mtx_lock(&Giant);
962 if (olddelta) {
963 atv.tv_sec = time_adjtime / 1000000;
964 atv.tv_usec = time_adjtime % 1000000;
965 if (atv.tv_usec < 0) {
966 atv.tv_usec += 1000000;
967 atv.tv_sec--;
968 }
969 *olddelta = atv;
970 }
971 if (delta)
972 time_adjtime = (int64_t)delta->tv_sec * 1000000 +
973 delta->tv_usec;
974 mtx_unlock(&Giant);
975 return (error);
976}
977