/FreeBSD/mac_settime/trunk/src/mac_settime.c |
---|
0,0 → 1,526 |
/*- |
* Copyright 2005, Anatoli Klassen <anatoli@aksoft.net> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD$ |
*/ |
/* |
* "allow uid 1,2,4-5" - any of specified users in main machine or any jail |
* "allow gid 123 jail 1-10" - a group in any of specified jail |
* "allow nojail" - any user on main machine |
* "deny not jail 3" - any user in jail 3 |
* |
* rules are applied in given order, first match wins; |
* if some specification is omit it means "any", last rule is always "deny" |
* |
* #sysctl security.mac.settime.rules="rule1; rule2; ruleN" |
* |
* rules := *([:rule:] *([;|\n] *[:rule:] *)*)? |
* rule := (allow|deny) +((not)? +(uid|gid) +[:digits-range:])? |
* ((not)? +(nojail|(jail +[:digits-range:]))? |
* digits-range := (\d+|(\d+-\d+))(,(\d+|(\d+-\d+)))* |
* tab and underscore can be used instead of space |
* |
*/ |
#include <sys/param.h> |
#include <sys/conf.h> |
#include <sys/jail.h> |
#include <sys/kernel.h> |
#include <sys/libkern.h> |
#include <sys/mac.h> |
#include <sys/malloc.h> |
#include <sys/mount.h> |
#include <sys/mutex.h> |
#include <sys/queue.h> |
#include <sys/sysctl.h> |
#include <sys/mac_policy.h> |
SYSCTL_DECL(_security_mac); |
SYSCTL_NODE(_security_mac, OID_AUTO, settime, CTLFLAG_RW, 0, |
"mac_settime policy controls"); |
static int mac_settime_enabled = 1; |
SYSCTL_INT(_security_mac_settime, OID_AUTO, enabled, CTLFLAG_RW, |
&mac_settime_enabled, 0, "Enforce settime policy"); |
TUNABLE_INT("security.mac.settime.enabled", &mac_settime_enabled); |
static MALLOC_DEFINE(M_SETTIME, "settime rule", "Rules for mac_settime"); |
#define MAC_RULE_STRING_LEN 10240 |
#define RULE_NONE 0 |
#define RULE_UID 1 |
#define RULE_GID 2 |
#define RULE_NOJAIL 1 |
#define RULE_JAIL 2 |
struct rule { |
int allow; /* 0 == "deny", 1 == "allow" */ |
int id_not; /* 0 == "", 1 == "not" */ |
int id_type; /* 0 == "" - no check, RULE_UID == "uid", RULE_GID == "gid" */ |
int id_count; /* number of id ranges */ |
int *id; /* uid or gid ranges */ |
int jail_not; /* 0 == "", 1 == "not" */ |
int jail_type; /* 0 == "" - no check, RULE_NOJAIL == "nojail", |
RULE_JAIL == "jail" */ |
int jailid_count; /* number of jail id ranges */ |
int *jailid; /* jail id ranges */ |
TAILQ_ENTRY(rule) r_entries; |
}; |
#define ALLOW_STRING "allow" |
#define DENY_STRING "deny" |
#define NOT_STRING "not" |
#define GID_STRING "gid" |
#define UID_STRING "uid" |
#define NOJAIL_STRING "nojail" |
#define JAIL_STRING "jail" |
static struct mtx rule_mtx; |
static TAILQ_HEAD(rulehead, rule) rule_head; |
static char rule_string[MAC_RULE_STRING_LEN]; |
static void |
delete_rules(struct rulehead *head) |
{ |
struct rule *rule; |
while ((rule = TAILQ_FIRST(head)) != NULL) { |
TAILQ_REMOVE(head, rule, r_entries); |
free(rule->id, M_SETTIME); |
free(rule->jailid, M_SETTIME); |
free(rule, M_SETTIME); |
} |
} |
static void |
destroy(struct mac_policy_conf *mpc) |
{ |
mtx_destroy(&rule_mtx); |
delete_rules(&rule_head); |
} |
static void |
init(struct mac_policy_conf *mpc) |
{ |
mtx_init(&rule_mtx, "rule_mtx", NULL, MTX_DEF); |
TAILQ_INIT(&rule_head); |
} |
static int |
parse_range_step(char *token, int *count, int **array) |
{ |
long n1, n2; |
int error; |
int end; |
error = 0; |
end = 0; |
*count = 0; |
while (!end && !error) { |
/* not start with digit - to avoid +/- recognition */ |
if (*token < '0' || *token > '9') { |
error = EINVAL; |
break; |
} |
n1 = strtol(token, &token, 10); |
switch (*token) { |
case '\0': /* end of string */ |
n2 = n1; |
end = 1; |
break; |
case ',': /* single value */ |
token++; |
n2 = n1; |
break; |
case '-': /* interval */ |
token++; |
/* not start with digit */ |
if (*token < '0' || *token > '9') |
error = EINVAL; |
else { |
n2 = strtol(token, &token, 10); |
switch (*token) { |
case '\0': /* end of string */ |
end = 1; |
break; |
case ',': /* continue */ |
token++; |
break; |
default: |
error = EINVAL; |
} |
} |
break; |
default: |
error = EINVAL; |
} |
if (!error) { |
if (array != NULL) { |
(*array)[*count * 2] = (int)n1; |
(*array)[*count * 2 + 1] = (int)n2; |
} |
(*count)++; |
} |
} |
return (error); |
} |
static int |
parse_range(char *token, int *count, int **array) |
{ |
int error; |
/* parse first time to determine number of intervals */ |
error = parse_range_step(token, count, NULL); |
if (error) { |
*array = NULL; |
return (error); |
} |
*array = malloc(*count * 2 * sizeof(int), M_SETTIME, M_WAITOK); |
/* parse once again - to fill the array */ |
error = parse_range_step(token, count, array); |
if (error) { |
free(*array, M_SETTIME); |
*array = NULL; |
} |
return (error); |
} |
static int |
parse_rule(char *s, struct rule **rule) |
{ |
enum parse_state { |
STATE_BEFORE_ACTION, |
STATE_AFTER_ACTION, |
STATE_AFTER_NOT1, |
STATE_AFTER_IDTYPE, |
STATE_AFTER_ID, |
STATE_AFTER_NOT2, |
STATE_AFTER_JAIL, |
STATE_END |
}; |
int error; |
int not; |
char *token; |
struct rule *r; |
enum parse_state state; |
r = malloc(sizeof(*r), M_SETTIME, M_ZERO | M_WAITOK); |
r->id = NULL; /* some arch where (pointer)0 != (binary)0 ? */ |
r->jailid = NULL; |
error = 0; |
not = 0; |
state = STATE_BEFORE_ACTION; |
while (!error && (token = strsep(&s, " \t_")) != NULL) { |
if (strlen(token) == 0) |
continue; |
switch(state) { |
case STATE_BEFORE_ACTION: |
not = 0; |
if (strcmp(token, ALLOW_STRING) == 0) { |
r->allow = 1; |
state = STATE_AFTER_ACTION; |
} else if (strcmp(token, DENY_STRING) == 0) { |
r->allow = 0; |
state = STATE_AFTER_ACTION; |
} else |
error = EINVAL; |
break; |
case STATE_AFTER_ACTION: |
if (strcmp(token, NOT_STRING) == 0) { |
state = STATE_AFTER_NOT1; |
not = 1; |
break; |
} |
/* FALLTHROUGH */ |
case STATE_AFTER_NOT1: |
if (strcmp(token, UID_STRING) == 0) { |
r->id_type = RULE_UID; |
r->id_not = not; |
state = STATE_AFTER_IDTYPE; |
break; |
} else if (strcmp(token, GID_STRING) == 0) { |
r->id_type = RULE_GID; |
r->id_not = not; |
state = STATE_AFTER_IDTYPE; |
break; |
} |
/* FALLTHROUGH */ |
/* attention: order of cases doesn't match order of tokens */ |
case STATE_AFTER_ID: |
if (strcmp(token, NOT_STRING) == 0) { |
if (STATE_AFTER_NOT1 == state) |
error = EINVAL; /* double 'not' */ |
else { |
state = STATE_AFTER_NOT2; |
not = 1; |
} |
break; |
} |
/* FALLTHROUGH */ |
case STATE_AFTER_NOT2: |
if (strcmp(token, NOJAIL_STRING) == 0) { |
r->jail_type = RULE_NOJAIL; |
r->jail_not = not; |
state = STATE_END; |
} else if(strcmp(token, JAIL_STRING) == 0) { |
r->jail_type = RULE_JAIL; |
r->jail_not = not; |
state = STATE_AFTER_JAIL; |
} else |
error = EINVAL; |
break; |
case STATE_AFTER_IDTYPE: |
error = parse_range(token, &(r->id_count), &(r->id)); |
state = STATE_AFTER_ID; |
break; |
case STATE_AFTER_JAIL: |
error = parse_range(token, &(r->jailid_count), &(r->jailid)); |
state = STATE_END; |
break; |
case STATE_END: |
error = EINVAL; /* something after end of rule */ |
break; |
} |
} |
/* check for unexpected end of rule */ |
if (STATE_BEFORE_ACTION != state && STATE_AFTER_ACTION != state && |
STATE_END != state && STATE_AFTER_ID != state) |
error = EINVAL; |
if (error || STATE_BEFORE_ACTION == state) { /* error or spaces only */ |
free(r, M_SETTIME); |
*rule = NULL; |
} |
else |
*rule = r; |
return (error); |
} |
/* this will destroy the given string */ |
static int |
parse_rules(char *s, struct rulehead *head) |
{ |
int error; |
char *token; |
struct rule *r; |
error = 0; |
while (!error && (token = strsep(&s, ";\n")) != NULL) { |
if (strlen(token) == 0) |
continue; |
error = parse_rule(token, &r); |
if (error) |
break; |
if (r != NULL) |
TAILQ_INSERT_TAIL(head, r, r_entries); |
} |
if (error) |
delete_rules(head); |
return (error); |
} |
/* |
* Note: due to races, there is not a single serializable order |
* between parallel calls to the sysctl. |
*/ |
static int |
sysctl_rules(SYSCTL_HANDLER_ARGS) |
{ |
char *string, *copy_string, *new_string; |
struct rulehead head, save_head; |
int error; |
new_string = NULL; |
if (req->newptr == NULL) { |
new_string = malloc(MAC_RULE_STRING_LEN, M_SETTIME, |
M_WAITOK | M_ZERO); |
strcpy(new_string, rule_string); |
string = new_string; |
} else |
string = rule_string; |
error = sysctl_handle_string(oidp, string, MAC_RULE_STRING_LEN, req); |
if (error) |
goto out; |
if (req->newptr != NULL) { |
copy_string = strdup(string, M_SETTIME); |
TAILQ_INIT(&head); |
error = parse_rules(copy_string, &head); |
free(copy_string, M_SETTIME); |
if (error) |
goto out; |
TAILQ_INIT(&save_head); |
mtx_lock(&rule_mtx); |
TAILQ_CONCAT(&save_head, &rule_head, r_entries); |
TAILQ_CONCAT(&rule_head, &head, r_entries); |
strcpy(rule_string, string); |
mtx_unlock(&rule_mtx); |
delete_rules(&save_head); |
} |
out: |
if (new_string != NULL) |
free(new_string, M_SETTIME); |
return (error); |
} |
SYSCTL_PROC(_security_mac_settime, OID_AUTO, rules, |
CTLTYPE_STRING|CTLFLAG_RW, 0, 0, sysctl_rules, "A", "Rules"); |
static int |
range_match(int value, int ranges_count, int *ranges, int not) |
{ |
int i, match; |
match = 0; |
for (i = 0; i < ranges_count; i++) |
if (ranges[i * 2] <= value && value <= ranges[i * 2 + 1]) { |
match = 1; |
break; |
} |
if (not) |
match = !match; |
return (match); |
} |
static int |
rule_match(struct ucred *cred, struct rule *r) |
{ |
int match_id, match_jail; |
switch (r->id_type) { |
case RULE_NONE: |
match_id = 1; |
break; |
case RULE_UID: |
match_id = range_match(cred->cr_uid, r->id_count, r->id, r->id_not); |
break; |
case RULE_GID: |
/* FIXME implement for other groups */ |
match_id = range_match(cred->cr_gid, r->id_count, r->id, r->id_not); |
break; |
default: |
printf("Unknown rule id type: %d\n", r->id_type); |
match_id = 0; |
} |
switch(r->jail_type) { |
case RULE_NONE: |
match_jail = 1; |
break; |
case RULE_NOJAIL: |
match_jail = !jailed(cred); |
break; |
case RULE_JAIL: |
if (cred->cr_prison == NULL) |
match_jail = 0; |
else |
match_jail = range_match(cred->cr_prison->pr_id, |
r->jailid_count, r->jailid, r->jail_not); |
break; |
default: |
printf("Unknown rule jail type: %d\n", r->jail_type); |
match_jail = 0; |
} |
return (match_id && match_jail); |
} |
static int |
rules_check(struct ucred *cred) |
{ |
struct rule *rule; |
int error; |
error = EPERM; |
mtx_lock(&rule_mtx); |
for (rule = TAILQ_FIRST(&rule_head); |
rule != NULL; |
rule = TAILQ_NEXT(rule, r_entries)) { |
if (rule_match(cred, rule)) { |
if (rule->allow) |
error = 0; |
break; |
} |
} |
mtx_unlock(&rule_mtx); |
return (error); |
} |
static int |
check_system_settime(struct ucred *cred) |
{ |
if (mac_settime_enabled == 0) |
return (0); |
return (rules_check(cred)); |
} |
static struct mac_policy_ops mac_settime_ops = |
{ |
.mpo_destroy = destroy, |
.mpo_init = init, |
.mpo_check_system_settime = check_system_settime, |
}; |
MAC_POLICY_SET(&mac_settime_ops, mac_settime, |
"MAC/settime", MPC_LOADTIME_FLAG_UNLOADOK, NULL); |
/FreeBSD/mac_settime/trunk/src/Makefile |
---|
0,0 → 1,8 |
# $FreeBSD$ |
.PATH: ${.CURDIR}/../../security/mac_settime |
KMOD= mac_settime |
SRCS= mac_settime.c |
.include <bsd.kmod.mk> |
/FreeBSD/mac_settime/trunk/patches/kern/kern_time.c |
---|
0,0 → 1,791 |
/*- |
* Copyright (c) 1982, 1986, 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93 |
*/ |
#include <sys/cdefs.h> |
__FBSDID("$FreeBSD: src/sys/kern/kern_time.c,v 1.116 2005/03/31 22:51:18 jhb Exp $"); |
#include "opt_mac.h" |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/lock.h> |
#include <sys/mutex.h> |
#include <sys/sysproto.h> |
#include <sys/resourcevar.h> |
#include <sys/signalvar.h> |
#include <sys/jail.h> |
#include <sys/kernel.h> |
#include <sys/mac.h> |
#include <sys/syscallsubr.h> |
#include <sys/sysctl.h> |
#include <sys/sysent.h> |
#include <sys/proc.h> |
#include <sys/time.h> |
#include <sys/timetc.h> |
#include <sys/vnode.h> |
#include <vm/vm.h> |
#include <vm/vm_extern.h> |
int tz_minuteswest; |
int tz_dsttime; |
/* |
* Time of day and interval timer support. |
* |
* These routines provide the kernel entry points to get and set |
* the time-of-day and per-process interval timers. Subroutines |
* here provide support for adding and subtracting timeval structures |
* and decrementing interval timers, optionally reloading the interval |
* timers when they expire. |
*/ |
static int settime(struct thread *, struct timeval *); |
static void timevalfix(struct timeval *); |
static void no_lease_updatetime(int); |
static int cf_usersettime; |
static int cf_jailsettime; |
SYSCTL_INT(_kern, OID_AUTO, usersettime, CTLFLAG_RW, &cf_usersettime, 0, |
"Non-root is allowed to change system time"); |
SYSCTL_INT(_kern, OID_AUTO, jailsettime, CTLFLAG_RW, &cf_jailsettime, 0, |
"System time is allowed to be changed from jail"); |
static void |
no_lease_updatetime(deltat) |
int deltat; |
{ |
} |
void (*lease_updatetime)(int) = no_lease_updatetime; |
static int |
settime(struct thread *td, struct timeval *tv) |
{ |
struct timeval delta, tv1, tv2; |
static struct timeval maxtime, laststep; |
struct timespec ts; |
int s; |
s = splclock(); |
microtime(&tv1); |
delta = *tv; |
timevalsub(&delta, &tv1); |
/* |
* If the system is secure, we do not allow the time to be |
* set to a value earlier than 1 second less than the highest |
* time we have yet seen. The worst a miscreant can do in |
* this circumstance is "freeze" time. He couldn't go |
* back to the past. |
* |
* We similarly do not allow the clock to be stepped more |
* than one second, nor more than once per second. This allows |
* a miscreant to make the clock march double-time, but no worse. |
*/ |
if (securelevel_gt(td->td_ucred, 1) != 0) { |
if (delta.tv_sec < 0 || delta.tv_usec < 0) { |
/* |
* Update maxtime to latest time we've seen. |
*/ |
if (tv1.tv_sec > maxtime.tv_sec) |
maxtime = tv1; |
tv2 = *tv; |
timevalsub(&tv2, &maxtime); |
if (tv2.tv_sec < -1) { |
tv->tv_sec = maxtime.tv_sec - 1; |
printf("Time adjustment clamped to -1 second\n"); |
} |
} else { |
if (tv1.tv_sec == laststep.tv_sec) { |
splx(s); |
return (EPERM); |
} |
if (delta.tv_sec > 1) { |
tv->tv_sec = tv1.tv_sec + 1; |
printf("Time adjustment clamped to +1 second\n"); |
} |
laststep = *tv; |
} |
} |
ts.tv_sec = tv->tv_sec; |
ts.tv_nsec = tv->tv_usec * 1000; |
mtx_lock(&Giant); |
tc_setclock(&ts); |
(void) splsoftclock(); |
lease_updatetime(delta.tv_sec); |
splx(s); |
resettodr(); |
mtx_unlock(&Giant); |
return (0); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_gettime_args { |
clockid_t clock_id; |
struct timespec *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
clock_gettime(struct thread *td, struct clock_gettime_args *uap) |
{ |
struct timespec ats; |
struct timeval sys, user; |
struct proc *p; |
p = td->td_proc; |
switch (uap->clock_id) { |
case CLOCK_REALTIME: |
nanotime(&ats); |
break; |
case CLOCK_VIRTUAL: |
PROC_LOCK(p); |
calcru(p, &user, &sys); |
PROC_UNLOCK(p); |
TIMEVAL_TO_TIMESPEC(&user, &ats); |
break; |
case CLOCK_PROF: |
PROC_LOCK(p); |
calcru(p, &user, &sys); |
PROC_UNLOCK(p); |
timevaladd(&user, &sys); |
TIMEVAL_TO_TIMESPEC(&user, &ats); |
break; |
case CLOCK_MONOTONIC: |
nanouptime(&ats); |
break; |
default: |
return (EINVAL); |
} |
return (copyout(&ats, uap->tp, sizeof(ats))); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_settime_args { |
clockid_t clock_id; |
const struct timespec *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
clock_settime(struct thread *td, struct clock_settime_args *uap) |
{ |
struct timeval atv; |
struct timespec ats; |
int error; |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
return (error); |
#endif |
if (!cf_jailsettime && jailed(td->td_ucred)) |
return (EPERM); |
if (!cf_usersettime && (error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) != 0) |
return (error); /* jail is already checked */ |
if (uap->clock_id != CLOCK_REALTIME) |
return (EINVAL); |
if ((error = copyin(uap->tp, &ats, sizeof(ats))) != 0) |
return (error); |
if (ats.tv_nsec < 0 || ats.tv_nsec >= 1000000000) |
return (EINVAL); |
/* XXX Don't convert nsec->usec and back */ |
TIMESPEC_TO_TIMEVAL(&atv, &ats); |
error = settime(td, &atv); |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_getres_args { |
clockid_t clock_id; |
struct timespec *tp; |
}; |
#endif |
int |
clock_getres(struct thread *td, struct clock_getres_args *uap) |
{ |
struct timespec ts; |
ts.tv_sec = 0; |
switch (uap->clock_id) { |
case CLOCK_REALTIME: |
case CLOCK_MONOTONIC: |
/* |
* Round up the result of the division cheaply by adding 1. |
* Rounding up is especially important if rounding down |
* would give 0. Perfect rounding is unimportant. |
*/ |
ts.tv_nsec = 1000000000 / tc_getfrequency() + 1; |
break; |
case CLOCK_VIRTUAL: |
case CLOCK_PROF: |
/* Accurately round up here because we can do so cheaply. */ |
ts.tv_nsec = (1000000000 + hz - 1) / hz; |
break; |
default: |
return (EINVAL); |
} |
if (uap->tp == NULL) |
return (0); |
return (copyout(&ts, uap->tp, sizeof(ts))); |
} |
static int nanowait; |
int |
kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt) |
{ |
struct timespec ts, ts2, ts3; |
struct timeval tv; |
int error; |
if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000) |
return (EINVAL); |
if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec == 0)) |
return (0); |
getnanouptime(&ts); |
timespecadd(&ts, rqt); |
TIMESPEC_TO_TIMEVAL(&tv, rqt); |
for (;;) { |
error = tsleep(&nanowait, PWAIT | PCATCH, "nanslp", |
tvtohz(&tv)); |
getnanouptime(&ts2); |
if (error != EWOULDBLOCK) { |
if (error == ERESTART) |
error = EINTR; |
if (rmt != NULL) { |
timespecsub(&ts, &ts2); |
if (ts.tv_sec < 0) |
timespecclear(&ts); |
*rmt = ts; |
} |
return (error); |
} |
if (timespeccmp(&ts2, &ts, >=)) |
return (0); |
ts3 = ts; |
timespecsub(&ts3, &ts2); |
TIMESPEC_TO_TIMEVAL(&tv, &ts3); |
} |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct nanosleep_args { |
struct timespec *rqtp; |
struct timespec *rmtp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
nanosleep(struct thread *td, struct nanosleep_args *uap) |
{ |
struct timespec rmt, rqt; |
int error; |
error = copyin(uap->rqtp, &rqt, sizeof(rqt)); |
if (error) |
return (error); |
if (uap->rmtp && |
!useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) |
return (EFAULT); |
error = kern_nanosleep(td, &rqt, &rmt); |
if (error && uap->rmtp) { |
int error2; |
error2 = copyout(&rmt, uap->rmtp, sizeof(rmt)); |
if (error2) |
error = error2; |
} |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct gettimeofday_args { |
struct timeval *tp; |
struct timezone *tzp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
gettimeofday(struct thread *td, struct gettimeofday_args *uap) |
{ |
struct timeval atv; |
struct timezone rtz; |
int error = 0; |
if (uap->tp) { |
microtime(&atv); |
error = copyout(&atv, uap->tp, sizeof (atv)); |
} |
if (error == 0 && uap->tzp != NULL) { |
rtz.tz_minuteswest = tz_minuteswest; |
rtz.tz_dsttime = tz_dsttime; |
error = copyout(&rtz, uap->tzp, sizeof (rtz)); |
} |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct settimeofday_args { |
struct timeval *tv; |
struct timezone *tzp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
settimeofday(struct thread *td, struct settimeofday_args *uap) |
{ |
struct timeval atv, *tvp; |
struct timezone atz, *tzp; |
int error; |
if (uap->tv) { |
error = copyin(uap->tv, &atv, sizeof(atv)); |
if (error) |
return (error); |
tvp = &atv; |
} else |
tvp = NULL; |
if (uap->tzp) { |
error = copyin(uap->tzp, &atz, sizeof(atz)); |
if (error) |
return (error); |
tzp = &atz; |
} else |
tzp = NULL; |
return (kern_settimeofday(td, tvp, tzp)); |
} |
int |
kern_settimeofday(struct thread *td, struct timeval *tv, struct timezone *tzp) |
{ |
int error = 0; |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
return (error); |
#endif |
if (!cf_jailsettime && jailed(td->td_ucred)) |
return (EPERM); |
if (!cf_usersettime && (error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) != 0) |
return (error); /* jail is already checked */ |
/* Verify all parameters before changing time. */ |
if (tv) { |
if (tv->tv_usec < 0 || tv->tv_usec >= 1000000) |
return (EINVAL); |
error = settime(td, tv); |
} |
if (tzp && error == 0) { |
tz_minuteswest = tzp->tz_minuteswest; |
tz_dsttime = tzp->tz_dsttime; |
} |
return (error); |
} |
/* |
* Get value of an interval timer. The process virtual and |
* profiling virtual time timers are kept in the p_stats area, since |
* they can be swapped out. These are kept internally in the |
* way they are specified externally: in time until they expire. |
* |
* The real time interval timer is kept in the process table slot |
* for the process, and its value (it_value) is kept as an |
* absolute time rather than as a delta, so that it is easy to keep |
* periodic real-time signals from drifting. |
* |
* Virtual time timers are processed in the hardclock() routine of |
* kern_clock.c. The real time timer is processed by a timeout |
* routine, called from the softclock() routine. Since a callout |
* may be delayed in real time due to interrupt processing in the system, |
* it is possible for the real time timeout routine (realitexpire, given below), |
* to be delayed in real time past when it is supposed to occur. It |
* does not suffice, therefore, to reload the real timer .it_value from the |
* real time timers .it_interval. Rather, we compute the next time in |
* absolute time the timer should go off. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct getitimer_args { |
u_int which; |
struct itimerval *itv; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
getitimer(struct thread *td, struct getitimer_args *uap) |
{ |
struct itimerval aitv; |
int error; |
error = kern_getitimer(td, uap->which, &aitv); |
if (error != 0) |
return (error); |
return (copyout(&aitv, uap->itv, sizeof (struct itimerval))); |
} |
int |
kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv) |
{ |
struct proc *p = td->td_proc; |
struct timeval ctv; |
if (which > ITIMER_PROF) |
return (EINVAL); |
if (which == ITIMER_REAL) { |
/* |
* Convert from absolute to relative time in .it_value |
* part of real time timer. If time for real time timer |
* has passed return 0, else return difference between |
* current time and time for the timer to go off. |
*/ |
PROC_LOCK(p); |
*aitv = p->p_realtimer; |
PROC_UNLOCK(p); |
if (timevalisset(&aitv->it_value)) { |
getmicrouptime(&ctv); |
if (timevalcmp(&aitv->it_value, &ctv, <)) |
timevalclear(&aitv->it_value); |
else |
timevalsub(&aitv->it_value, &ctv); |
} |
} else { |
mtx_lock_spin(&sched_lock); |
*aitv = p->p_stats->p_timer[which]; |
mtx_unlock_spin(&sched_lock); |
} |
return (0); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct setitimer_args { |
u_int which; |
struct itimerval *itv, *oitv; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
setitimer(struct thread *td, struct setitimer_args *uap) |
{ |
struct itimerval aitv, oitv; |
int error; |
if (uap->itv == NULL) { |
uap->itv = uap->oitv; |
return (getitimer(td, (struct getitimer_args *)uap)); |
} |
if ((error = copyin(uap->itv, &aitv, sizeof(struct itimerval)))) |
return (error); |
error = kern_setitimer(td, uap->which, &aitv, &oitv); |
if (error != 0 || uap->oitv == NULL) |
return (error); |
return (copyout(&oitv, uap->oitv, sizeof(struct itimerval))); |
} |
int |
kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, |
struct itimerval *oitv) |
{ |
struct proc *p = td->td_proc; |
struct timeval ctv; |
if (aitv == NULL) |
return (kern_getitimer(td, which, oitv)); |
if (which > ITIMER_PROF) |
return (EINVAL); |
if (itimerfix(&aitv->it_value)) |
return (EINVAL); |
if (!timevalisset(&aitv->it_value)) |
timevalclear(&aitv->it_interval); |
else if (itimerfix(&aitv->it_interval)) |
return (EINVAL); |
if (which == ITIMER_REAL) { |
PROC_LOCK(p); |
if (timevalisset(&p->p_realtimer.it_value)) |
callout_stop(&p->p_itcallout); |
getmicrouptime(&ctv); |
if (timevalisset(&aitv->it_value)) { |
callout_reset(&p->p_itcallout, tvtohz(&aitv->it_value), |
realitexpire, p); |
timevaladd(&aitv->it_value, &ctv); |
} |
*oitv = p->p_realtimer; |
p->p_realtimer = *aitv; |
PROC_UNLOCK(p); |
if (timevalisset(&oitv->it_value)) { |
if (timevalcmp(&oitv->it_value, &ctv, <)) |
timevalclear(&oitv->it_value); |
else |
timevalsub(&oitv->it_value, &ctv); |
} |
} else { |
mtx_lock_spin(&sched_lock); |
*oitv = p->p_stats->p_timer[which]; |
p->p_stats->p_timer[which] = *aitv; |
mtx_unlock_spin(&sched_lock); |
} |
return (0); |
} |
/* |
* Real interval timer expired: |
* send process whose timer expired an alarm signal. |
* If time is not set up to reload, then just return. |
* Else compute next time timer should go off which is > current time. |
* This is where delay in processing this timeout causes multiple |
* SIGALRM calls to be compressed into one. |
* tvtohz() always adds 1 to allow for the time until the next clock |
* interrupt being strictly less than 1 clock tick, but we don't want |
* that here since we want to appear to be in sync with the clock |
* interrupt even when we're delayed. |
*/ |
void |
realitexpire(void *arg) |
{ |
struct proc *p; |
struct timeval ctv, ntv; |
p = (struct proc *)arg; |
PROC_LOCK(p); |
psignal(p, SIGALRM); |
if (!timevalisset(&p->p_realtimer.it_interval)) { |
timevalclear(&p->p_realtimer.it_value); |
if (p->p_flag & P_WEXIT) |
wakeup(&p->p_itcallout); |
PROC_UNLOCK(p); |
return; |
} |
for (;;) { |
timevaladd(&p->p_realtimer.it_value, |
&p->p_realtimer.it_interval); |
getmicrouptime(&ctv); |
if (timevalcmp(&p->p_realtimer.it_value, &ctv, >)) { |
ntv = p->p_realtimer.it_value; |
timevalsub(&ntv, &ctv); |
callout_reset(&p->p_itcallout, tvtohz(&ntv) - 1, |
realitexpire, p); |
PROC_UNLOCK(p); |
return; |
} |
} |
/*NOTREACHED*/ |
} |
/* |
* Check that a proposed value to load into the .it_value or |
* .it_interval part of an interval timer is acceptable, and |
* fix it to have at least minimal value (i.e. if it is less |
* than the resolution of the clock, round it up.) |
*/ |
int |
itimerfix(struct timeval *tv) |
{ |
if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || |
tv->tv_usec < 0 || tv->tv_usec >= 1000000) |
return (EINVAL); |
if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < tick) |
tv->tv_usec = tick; |
return (0); |
} |
/* |
* Decrement an interval timer by a specified number |
* of microseconds, which must be less than a second, |
* i.e. < 1000000. If the timer expires, then reload |
* it. In this case, carry over (usec - old value) to |
* reduce the value reloaded into the timer so that |
* the timer does not drift. This routine assumes |
* that it is called in a context where the timers |
* on which it is operating cannot change in value. |
*/ |
int |
itimerdecr(struct itimerval *itp, int usec) |
{ |
if (itp->it_value.tv_usec < usec) { |
if (itp->it_value.tv_sec == 0) { |
/* expired, and already in next interval */ |
usec -= itp->it_value.tv_usec; |
goto expire; |
} |
itp->it_value.tv_usec += 1000000; |
itp->it_value.tv_sec--; |
} |
itp->it_value.tv_usec -= usec; |
usec = 0; |
if (timevalisset(&itp->it_value)) |
return (1); |
/* expired, exactly at end of interval */ |
expire: |
if (timevalisset(&itp->it_interval)) { |
itp->it_value = itp->it_interval; |
itp->it_value.tv_usec -= usec; |
if (itp->it_value.tv_usec < 0) { |
itp->it_value.tv_usec += 1000000; |
itp->it_value.tv_sec--; |
} |
} else |
itp->it_value.tv_usec = 0; /* sec is already 0 */ |
return (0); |
} |
/* |
* Add and subtract routines for timevals. |
* N.B.: subtract routine doesn't deal with |
* results which are before the beginning, |
* it just gets very confused in this case. |
* Caveat emptor. |
*/ |
void |
timevaladd(struct timeval *t1, const struct timeval *t2) |
{ |
t1->tv_sec += t2->tv_sec; |
t1->tv_usec += t2->tv_usec; |
timevalfix(t1); |
} |
void |
timevalsub(struct timeval *t1, const struct timeval *t2) |
{ |
t1->tv_sec -= t2->tv_sec; |
t1->tv_usec -= t2->tv_usec; |
timevalfix(t1); |
} |
static void |
timevalfix(struct timeval *t1) |
{ |
if (t1->tv_usec < 0) { |
t1->tv_sec--; |
t1->tv_usec += 1000000; |
} |
if (t1->tv_usec >= 1000000) { |
t1->tv_sec++; |
t1->tv_usec -= 1000000; |
} |
} |
/* |
* ratecheck(): simple time-based rate-limit checking. |
*/ |
int |
ratecheck(struct timeval *lasttime, const struct timeval *mininterval) |
{ |
struct timeval tv, delta; |
int rv = 0; |
getmicrouptime(&tv); /* NB: 10ms precision */ |
delta = tv; |
timevalsub(&delta, lasttime); |
/* |
* check for 0,0 is so that the message will be seen at least once, |
* even if interval is huge. |
*/ |
if (timevalcmp(&delta, mininterval, >=) || |
(lasttime->tv_sec == 0 && lasttime->tv_usec == 0)) { |
*lasttime = tv; |
rv = 1; |
} |
return (rv); |
} |
/* |
* ppsratecheck(): packets (or events) per second limitation. |
* |
* Return 0 if the limit is to be enforced (e.g. the caller |
* should drop a packet because of the rate limitation). |
* |
* maxpps of 0 always causes zero to be returned. maxpps of -1 |
* always causes 1 to be returned; this effectively defeats rate |
* limiting. |
* |
* Note that we maintain the struct timeval for compatibility |
* with other bsd systems. We reuse the storage and just monitor |
* clock ticks for minimal overhead. |
*/ |
int |
ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps) |
{ |
int now; |
/* |
* Reset the last time and counter if this is the first call |
* or more than a second has passed since the last update of |
* lasttime. |
*/ |
now = ticks; |
if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) { |
lasttime->tv_sec = now; |
*curpps = 1; |
return (maxpps != 0); |
} else { |
(*curpps)++; /* NB: ignore potential overflow */ |
return (maxpps < 0 || *curpps < maxpps); |
} |
} |
/FreeBSD/mac_settime/trunk/patches/kern/kern_ntptime.c |
---|
0,0 → 1,1001 |
/*- |
*********************************************************************** |
* * |
* Copyright (c) David L. Mills 1993-2001 * |
* * |
* Permission to use, copy, modify, and distribute this software and * |
* its documentation for any purpose and without fee is hereby * |
* granted, provided that the above copyright notice appears in all * |
* copies and that both the copyright notice and this permission * |
* notice appear in supporting documentation, and that the name * |
* University of Delaware not be used in advertising or publicity * |
* pertaining to distribution of the software without specific, * |
* written prior permission. The University of Delaware makes no * |
* representations about the suitability this software for any * |
* purpose. It is provided "as is" without express or implied * |
* warranty. * |
* * |
**********************************************************************/ |
/* |
* Adapted from the original sources for FreeBSD and timecounters by: |
* Poul-Henning Kamp <phk@FreeBSD.org>. |
* |
* The 32bit version of the "LP" macros seems a bit past its "sell by" |
* date so I have retained only the 64bit version and included it directly |
* in this file. |
* |
* Only minor changes done to interface with the timecounters over in |
* sys/kern/kern_clock.c. Some of the comments below may be (even more) |
* confusing and/or plain wrong in that context. |
*/ |
#include <sys/cdefs.h> |
__FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); |
#include "opt_ntp.h" |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/sysproto.h> |
#include <sys/jail.h> |
#include <sys/kernel.h> |
#include <sys/proc.h> |
#include <sys/lock.h> |
#include <sys/mutex.h> |
#include <sys/time.h> |
#include <sys/timex.h> |
#include <sys/timetc.h> |
#include <sys/timepps.h> |
#include <sys/syscallsubr.h> |
#include <sys/sysctl.h> |
/* |
* Single-precision macros for 64-bit machines |
*/ |
typedef int64_t l_fp; |
#define L_ADD(v, u) ((v) += (u)) |
#define L_SUB(v, u) ((v) -= (u)) |
#define L_ADDHI(v, a) ((v) += (int64_t)(a) << 32) |
#define L_NEG(v) ((v) = -(v)) |
#define L_RSHIFT(v, n) \ |
do { \ |
if ((v) < 0) \ |
(v) = -(-(v) >> (n)); \ |
else \ |
(v) = (v) >> (n); \ |
} while (0) |
#define L_MPY(v, a) ((v) *= (a)) |
#define L_CLR(v) ((v) = 0) |
#define L_ISNEG(v) ((v) < 0) |
#define L_LINT(v, a) ((v) = (int64_t)(a) << 32) |
#define L_GINT(v) ((v) < 0 ? -(-(v) >> 32) : (v) >> 32) |
/* |
* Generic NTP kernel interface |
* |
* These routines constitute the Network Time Protocol (NTP) interfaces |
* for user and daemon application programs. The ntp_gettime() routine |
* provides the time, maximum error (synch distance) and estimated error |
* (dispersion) to client user application programs. The ntp_adjtime() |
* routine is used by the NTP daemon to adjust the system clock to an |
* externally derived time. The time offset and related variables set by |
* this routine are used by other routines in this module to adjust the |
* phase and frequency of the clock discipline loop which controls the |
* system clock. |
* |
* When the kernel time is reckoned directly in nanoseconds (NTP_NANO |
* defined), the time at each tick interrupt is derived directly from |
* the kernel time variable. When the kernel time is reckoned in |
* microseconds, (NTP_NANO undefined), the time is derived from the |
* kernel time variable together with a variable representing the |
* leftover nanoseconds at the last tick interrupt. In either case, the |
* current nanosecond time is reckoned from these values plus an |
* interpolated value derived by the clock routines in another |
* architecture-specific module. The interpolation can use either a |
* dedicated counter or a processor cycle counter (PCC) implemented in |
* some architectures. |
* |
* Note that all routines must run at priority splclock or higher. |
*/ |
/* |
* Phase/frequency-lock loop (PLL/FLL) definitions |
* |
* The nanosecond clock discipline uses two variable types, time |
* variables and frequency variables. Both types are represented as 64- |
* bit fixed-point quantities with the decimal point between two 32-bit |
* halves. On a 32-bit machine, each half is represented as a single |
* word and mathematical operations are done using multiple-precision |
* arithmetic. On a 64-bit machine, ordinary computer arithmetic is |
* used. |
* |
* A time variable is a signed 64-bit fixed-point number in ns and |
* fraction. It represents the remaining time offset to be amortized |
* over succeeding tick interrupts. The maximum time offset is about |
* 0.5 s and the resolution is about 2.3e-10 ns. |
* |
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 |
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |s s s| ns | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* | fraction | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |
* A frequency variable is a signed 64-bit fixed-point number in ns/s |
* and fraction. It represents the ns and fraction to be added to the |
* kernel time variable at each second. The maximum frequency offset is |
* about +-500000 ns/s and the resolution is about 2.3e-10 ns/s. |
* |
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 |
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |s s s s s s s s s s s s s| ns/s | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* | fraction | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
*/ |
/* |
* The following variables establish the state of the PLL/FLL and the |
* residual time and frequency offset of the local clock. |
*/ |
#define SHIFT_PLL 4 /* PLL loop gain (shift) */ |
#define SHIFT_FLL 2 /* FLL loop gain (shift) */ |
static int time_state = TIME_OK; /* clock state */ |
static int time_status = STA_UNSYNC; /* clock status bits */ |
static long time_tai; /* TAI offset (s) */ |
static long time_monitor; /* last time offset scaled (ns) */ |
static long time_constant; /* poll interval (shift) (s) */ |
static long time_precision = 1; /* clock precision (ns) */ |
static long time_maxerror = MAXPHASE / 1000; /* maximum error (us) */ |
static long time_esterror = MAXPHASE / 1000; /* estimated error (us) */ |
static long time_reftime; /* time at last adjustment (s) */ |
static l_fp time_offset; /* time offset (ns) */ |
static l_fp time_freq; /* frequency offset (ns/s) */ |
static l_fp time_adj; /* tick adjust (ns/s) */ |
static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ |
#ifdef PPS_SYNC |
/* |
* The following variables are used when a pulse-per-second (PPS) signal |
* is available and connected via a modem control lead. They establish |
* the engineering parameters of the clock discipline loop when |
* controlled by the PPS signal. |
*/ |
#define PPS_FAVG 2 /* min freq avg interval (s) (shift) */ |
#define PPS_FAVGDEF 8 /* default freq avg int (s) (shift) */ |
#define PPS_FAVGMAX 15 /* max freq avg interval (s) (shift) */ |
#define PPS_PAVG 4 /* phase avg interval (s) (shift) */ |
#define PPS_VALID 120 /* PPS signal watchdog max (s) */ |
#define PPS_MAXWANDER 100000 /* max PPS wander (ns/s) */ |
#define PPS_POPCORN 2 /* popcorn spike threshold (shift) */ |
static struct timespec pps_tf[3]; /* phase median filter */ |
static l_fp pps_freq; /* scaled frequency offset (ns/s) */ |
static long pps_fcount; /* frequency accumulator */ |
static long pps_jitter; /* nominal jitter (ns) */ |
static long pps_stabil; /* nominal stability (scaled ns/s) */ |
static long pps_lastsec; /* time at last calibration (s) */ |
static int pps_valid; /* signal watchdog counter */ |
static int pps_shift = PPS_FAVG; /* interval duration (s) (shift) */ |
static int pps_shiftmax = PPS_FAVGDEF; /* max interval duration (s) (shift) */ |
static int pps_intcnt; /* wander counter */ |
/* |
* PPS signal quality monitors |
*/ |
static long pps_calcnt; /* calibration intervals */ |
static long pps_jitcnt; /* jitter limit exceeded */ |
static long pps_stbcnt; /* stability limit exceeded */ |
static long pps_errcnt; /* calibration errors */ |
#endif /* PPS_SYNC */ |
/* |
* End of phase/frequency-lock loop (PLL/FLL) definitions |
*/ |
static void ntp_init(void); |
static void hardupdate(long offset); |
static void ntp_gettime1(struct ntptimeval *ntvp); |
static int cf_useradjtime; |
static int cf_jailadjtime; |
SYSCTL_INT(_kern, OID_AUTO, useradjtime, CTLFLAG_RW, &cf_useradjtime, 0, |
"Non-root is allowed to adjust system time"); |
SYSCTL_INT(_kern, OID_AUTO, jailadjtime, CTLFLAG_RW, &cf_jailadjtime, 0, |
"System time is allowed to be adjusted from jail"); |
static void |
ntp_gettime1(struct ntptimeval *ntvp) |
{ |
struct timespec atv; /* nanosecond time */ |
GIANT_REQUIRED; |
nanotime(&atv); |
ntvp->time.tv_sec = atv.tv_sec; |
ntvp->time.tv_nsec = atv.tv_nsec; |
ntvp->maxerror = time_maxerror; |
ntvp->esterror = time_esterror; |
ntvp->tai = time_tai; |
ntvp->time_state = time_state; |
/* |
* Status word error decode. If any of these conditions occur, |
* an error is returned, instead of the status word. Most |
* applications will care only about the fact the system clock |
* may not be trusted, not about the details. |
* |
* Hardware or software error |
*/ |
if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || |
/* |
* PPS signal lost when either time or frequency synchronization |
* requested |
*/ |
(time_status & (STA_PPSFREQ | STA_PPSTIME) && |
!(time_status & STA_PPSSIGNAL)) || |
/* |
* PPS jitter exceeded when time synchronization requested |
*/ |
(time_status & STA_PPSTIME && |
time_status & STA_PPSJITTER) || |
/* |
* PPS wander exceeded or calibration error when frequency |
* synchronization requested |
*/ |
(time_status & STA_PPSFREQ && |
time_status & (STA_PPSWANDER | STA_PPSERROR))) |
ntvp->time_state = TIME_ERROR; |
} |
/* |
* ntp_gettime() - NTP user application interface |
* |
* See the timex.h header file for synopsis and API description. Note |
* that the TAI offset is returned in the ntvtimeval.tai structure |
* member. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct ntp_gettime_args { |
struct ntptimeval *ntvp; |
}; |
#endif |
/* ARGSUSED */ |
int |
ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) |
{ |
struct ntptimeval ntv; |
mtx_lock(&Giant); |
ntp_gettime1(&ntv); |
mtx_unlock(&Giant); |
return (copyout(&ntv, uap->ntvp, sizeof(ntv))); |
} |
static int |
ntp_sysctl(SYSCTL_HANDLER_ARGS) |
{ |
struct ntptimeval ntv; /* temporary structure */ |
ntp_gettime1(&ntv); |
return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); |
} |
SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW, 0, ""); |
SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE|CTLFLAG_RD, |
0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", ""); |
#ifdef PPS_SYNC |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, &pps_shiftmax, 0, ""); |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shift, CTLFLAG_RW, &pps_shift, 0, ""); |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD, &time_monitor, 0, ""); |
SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD, &pps_freq, sizeof(pps_freq), "I", ""); |
SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, &time_freq, sizeof(time_freq), "I", ""); |
#endif |
/* |
* ntp_adjtime() - NTP daemon application interface |
* |
* See the timex.h header file for synopsis and API description. Note |
* that the timex.constant structure member has a dual purpose to set |
* the time constant and to set the TAI offset. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct ntp_adjtime_args { |
struct timex *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) |
{ |
struct timex ntv; /* temporary structure */ |
long freq; /* frequency ns/s) */ |
int modes; /* mode bits from structure */ |
int s; /* caller priority */ |
int error; |
error = copyin((caddr_t)uap->tp, (caddr_t)&ntv, sizeof(ntv)); |
if (error) |
return(error); |
/* |
* Update selected clock variables - only the superuser can |
* change anything. Note that there is no error checking here on |
* the assumption the superuser should know what it is doing. |
* Note that either the time constant or TAI offset are loaded |
* from the ntv.constant member, depending on the mode bits. If |
* the STA_PLL bit in the status word is cleared, the state and |
* status words are reset to the initial values at boot. |
*/ |
mtx_lock(&Giant); |
modes = ntv.modes; |
if (modes) { /* XXX really check suser sometimes only? */ |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
goto done2; |
#endif |
if (!cf_jailadjtime && jailed(td->td_ucred)) { |
error = EPERM; |
goto done2; |
} |
if (!cf_useradjtime && |
(error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) != 0) |
goto done2; /* jail is already checked at this point */ |
} |
s = splclock(); |
if (modes & MOD_MAXERROR) |
time_maxerror = ntv.maxerror; |
if (modes & MOD_ESTERROR) |
time_esterror = ntv.esterror; |
if (modes & MOD_STATUS) { |
if (time_status & STA_PLL && !(ntv.status & STA_PLL)) { |
time_state = TIME_OK; |
time_status = STA_UNSYNC; |
#ifdef PPS_SYNC |
pps_shift = PPS_FAVG; |
#endif /* PPS_SYNC */ |
} |
time_status &= STA_RONLY; |
time_status |= ntv.status & ~STA_RONLY; |
} |
if (modes & MOD_TIMECONST) { |
if (ntv.constant < 0) |
time_constant = 0; |
else if (ntv.constant > MAXTC) |
time_constant = MAXTC; |
else |
time_constant = ntv.constant; |
} |
if (modes & MOD_TAI) { |
if (ntv.constant > 0) /* XXX zero & negative numbers ? */ |
time_tai = ntv.constant; |
} |
#ifdef PPS_SYNC |
if (modes & MOD_PPSMAX) { |
if (ntv.shift < PPS_FAVG) |
pps_shiftmax = PPS_FAVG; |
else if (ntv.shift > PPS_FAVGMAX) |
pps_shiftmax = PPS_FAVGMAX; |
else |
pps_shiftmax = ntv.shift; |
} |
#endif /* PPS_SYNC */ |
if (modes & MOD_NANO) |
time_status |= STA_NANO; |
if (modes & MOD_MICRO) |
time_status &= ~STA_NANO; |
if (modes & MOD_CLKB) |
time_status |= STA_CLK; |
if (modes & MOD_CLKA) |
time_status &= ~STA_CLK; |
if (modes & MOD_FREQUENCY) { |
freq = (ntv.freq * 1000LL) >> 16; |
if (freq > MAXFREQ) |
L_LINT(time_freq, MAXFREQ); |
else if (freq < -MAXFREQ) |
L_LINT(time_freq, -MAXFREQ); |
else { |
/* |
* ntv.freq is [PPM * 2^16] = [us/s * 2^16] |
* time_freq is [ns/s * 2^32] |
*/ |
time_freq = ntv.freq * 1000LL * 65536LL; |
} |
#ifdef PPS_SYNC |
pps_freq = time_freq; |
#endif /* PPS_SYNC */ |
} |
if (modes & MOD_OFFSET) { |
if (time_status & STA_NANO) |
hardupdate(ntv.offset); |
else |
hardupdate(ntv.offset * 1000); |
} |
/* |
* Retrieve all clock variables. Note that the TAI offset is |
* returned only by ntp_gettime(); |
*/ |
if (time_status & STA_NANO) |
ntv.offset = L_GINT(time_offset); |
else |
ntv.offset = L_GINT(time_offset) / 1000; /* XXX rounding ? */ |
ntv.freq = L_GINT((time_freq / 1000LL) << 16); |
ntv.maxerror = time_maxerror; |
ntv.esterror = time_esterror; |
ntv.status = time_status; |
ntv.constant = time_constant; |
if (time_status & STA_NANO) |
ntv.precision = time_precision; |
else |
ntv.precision = time_precision / 1000; |
ntv.tolerance = MAXFREQ * SCALE_PPM; |
#ifdef PPS_SYNC |
ntv.shift = pps_shift; |
ntv.ppsfreq = L_GINT((pps_freq / 1000LL) << 16); |
if (time_status & STA_NANO) |
ntv.jitter = pps_jitter; |
else |
ntv.jitter = pps_jitter / 1000; |
ntv.stabil = pps_stabil; |
ntv.calcnt = pps_calcnt; |
ntv.errcnt = pps_errcnt; |
ntv.jitcnt = pps_jitcnt; |
ntv.stbcnt = pps_stbcnt; |
#endif /* PPS_SYNC */ |
splx(s); |
error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); |
if (error) |
goto done2; |
/* |
* Status word error decode. See comments in |
* ntp_gettime() routine. |
*/ |
if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || |
(time_status & (STA_PPSFREQ | STA_PPSTIME) && |
!(time_status & STA_PPSSIGNAL)) || |
(time_status & STA_PPSTIME && |
time_status & STA_PPSJITTER) || |
(time_status & STA_PPSFREQ && |
time_status & (STA_PPSWANDER | STA_PPSERROR))) { |
td->td_retval[0] = TIME_ERROR; |
} else { |
td->td_retval[0] = time_state; |
} |
done2: |
mtx_unlock(&Giant); |
return (error); |
} |
/* |
* second_overflow() - called after ntp_tick_adjust() |
* |
* This routine is ordinarily called immediately following the above |
* routine ntp_tick_adjust(). While these two routines are normally |
* combined, they are separated here only for the purposes of |
* simulation. |
*/ |
void |
ntp_update_second(int64_t *adjustment, time_t *newsec) |
{ |
int tickrate; |
l_fp ftemp; /* 32/64-bit temporary */ |
/* |
* On rollover of the second both the nanosecond and microsecond |
* clocks are updated and the state machine cranked as |
* necessary. The phase adjustment to be used for the next |
* second is calculated and the maximum error is increased by |
* the tolerance. |
*/ |
time_maxerror += MAXFREQ / 1000; |
/* |
* Leap second processing. If in leap-insert state at |
* the end of the day, the system clock is set back one |
* second; if in leap-delete state, the system clock is |
* set ahead one second. The nano_time() routine or |
* external clock driver will insure that reported time |
* is always monotonic. |
*/ |
switch (time_state) { |
/* |
* No warning. |
*/ |
case TIME_OK: |
if (time_status & STA_INS) |
time_state = TIME_INS; |
else if (time_status & STA_DEL) |
time_state = TIME_DEL; |
break; |
/* |
* Insert second 23:59:60 following second |
* 23:59:59. |
*/ |
case TIME_INS: |
if (!(time_status & STA_INS)) |
time_state = TIME_OK; |
else if ((*newsec) % 86400 == 0) { |
(*newsec)--; |
time_state = TIME_OOP; |
time_tai++; |
} |
break; |
/* |
* Delete second 23:59:59. |
*/ |
case TIME_DEL: |
if (!(time_status & STA_DEL)) |
time_state = TIME_OK; |
else if (((*newsec) + 1) % 86400 == 0) { |
(*newsec)++; |
time_tai--; |
time_state = TIME_WAIT; |
} |
break; |
/* |
* Insert second in progress. |
*/ |
case TIME_OOP: |
time_state = TIME_WAIT; |
break; |
/* |
* Wait for status bits to clear. |
*/ |
case TIME_WAIT: |
if (!(time_status & (STA_INS | STA_DEL))) |
time_state = TIME_OK; |
} |
/* |
* Compute the total time adjustment for the next second |
* in ns. The offset is reduced by a factor depending on |
* whether the PPS signal is operating. Note that the |
* value is in effect scaled by the clock frequency, |
* since the adjustment is added at each tick interrupt. |
*/ |
ftemp = time_offset; |
#ifdef PPS_SYNC |
/* XXX even if PPS signal dies we should finish adjustment ? */ |
if (time_status & STA_PPSTIME && time_status & |
STA_PPSSIGNAL) |
L_RSHIFT(ftemp, pps_shift); |
else |
L_RSHIFT(ftemp, SHIFT_PLL + time_constant); |
#else |
L_RSHIFT(ftemp, SHIFT_PLL + time_constant); |
#endif /* PPS_SYNC */ |
time_adj = ftemp; |
L_SUB(time_offset, ftemp); |
L_ADD(time_adj, time_freq); |
/* |
* Apply any correction from adjtime(2). If more than one second |
* off we slew at a rate of 5ms/s (5000 PPM) else 500us/s (500PPM) |
* until the last second is slewed the final < 500 usecs. |
*/ |
if (time_adjtime != 0) { |
if (time_adjtime > 1000000) |
tickrate = 5000; |
else if (time_adjtime < -1000000) |
tickrate = -5000; |
else if (time_adjtime > 500) |
tickrate = 500; |
else if (time_adjtime < -500) |
tickrate = -500; |
else |
tickrate = time_adjtime; |
time_adjtime -= tickrate; |
L_LINT(ftemp, tickrate * 1000); |
L_ADD(time_adj, ftemp); |
} |
*adjustment = time_adj; |
#ifdef PPS_SYNC |
if (pps_valid > 0) |
pps_valid--; |
else |
time_status &= ~STA_PPSSIGNAL; |
#endif /* PPS_SYNC */ |
} |
/* |
* ntp_init() - initialize variables and structures |
* |
* This routine must be called after the kernel variables hz and tick |
* are set or changed and before the next tick interrupt. In this |
* particular implementation, these values are assumed set elsewhere in |
* the kernel. The design allows the clock frequency and tick interval |
* to be changed while the system is running. So, this routine should |
* probably be integrated with the code that does that. |
*/ |
static void |
ntp_init() |
{ |
/* |
* The following variables are initialized only at startup. Only |
* those structures not cleared by the compiler need to be |
* initialized, and these only in the simulator. In the actual |
* kernel, any nonzero values here will quickly evaporate. |
*/ |
L_CLR(time_offset); |
L_CLR(time_freq); |
#ifdef PPS_SYNC |
pps_tf[0].tv_sec = pps_tf[0].tv_nsec = 0; |
pps_tf[1].tv_sec = pps_tf[1].tv_nsec = 0; |
pps_tf[2].tv_sec = pps_tf[2].tv_nsec = 0; |
pps_fcount = 0; |
L_CLR(pps_freq); |
#endif /* PPS_SYNC */ |
} |
SYSINIT(ntpclocks, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, ntp_init, NULL) |
/* |
* hardupdate() - local clock update |
* |
* This routine is called by ntp_adjtime() to update the local clock |
* phase and frequency. The implementation is of an adaptive-parameter, |
* hybrid phase/frequency-lock loop (PLL/FLL). The routine computes new |
* time and frequency offset estimates for each call. If the kernel PPS |
* discipline code is configured (PPS_SYNC), the PPS signal itself |
* determines the new time offset, instead of the calling argument. |
* Presumably, calls to ntp_adjtime() occur only when the caller |
* believes the local clock is valid within some bound (+-128 ms with |
* NTP). If the caller's time is far different than the PPS time, an |
* argument will ensue, and it's not clear who will lose. |
* |
* For uncompensated quartz crystal oscillators and nominal update |
* intervals less than 256 s, operation should be in phase-lock mode, |
* where the loop is disciplined to phase. For update intervals greater |
* than 1024 s, operation should be in frequency-lock mode, where the |
* loop is disciplined to frequency. Between 256 s and 1024 s, the mode |
* is selected by the STA_MODE status bit. |
*/ |
static void |
hardupdate(offset) |
long offset; /* clock offset (ns) */ |
{ |
long mtemp; |
l_fp ftemp; |
/* |
* Select how the phase is to be controlled and from which |
* source. If the PPS signal is present and enabled to |
* discipline the time, the PPS offset is used; otherwise, the |
* argument offset is used. |
*/ |
if (!(time_status & STA_PLL)) |
return; |
if (!(time_status & STA_PPSTIME && time_status & |
STA_PPSSIGNAL)) { |
if (offset > MAXPHASE) |
time_monitor = MAXPHASE; |
else if (offset < -MAXPHASE) |
time_monitor = -MAXPHASE; |
else |
time_monitor = offset; |
L_LINT(time_offset, time_monitor); |
} |
/* |
* Select how the frequency is to be controlled and in which |
* mode (PLL or FLL). If the PPS signal is present and enabled |
* to discipline the frequency, the PPS frequency is used; |
* otherwise, the argument offset is used to compute it. |
*/ |
if (time_status & STA_PPSFREQ && time_status & STA_PPSSIGNAL) { |
time_reftime = time_second; |
return; |
} |
if (time_status & STA_FREQHOLD || time_reftime == 0) |
time_reftime = time_second; |
mtemp = time_second - time_reftime; |
L_LINT(ftemp, time_monitor); |
L_RSHIFT(ftemp, (SHIFT_PLL + 2 + time_constant) << 1); |
L_MPY(ftemp, mtemp); |
L_ADD(time_freq, ftemp); |
time_status &= ~STA_MODE; |
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > |
MAXSEC)) { |
L_LINT(ftemp, (time_monitor << 4) / mtemp); |
L_RSHIFT(ftemp, SHIFT_FLL + 4); |
L_ADD(time_freq, ftemp); |
time_status |= STA_MODE; |
} |
time_reftime = time_second; |
if (L_GINT(time_freq) > MAXFREQ) |
L_LINT(time_freq, MAXFREQ); |
else if (L_GINT(time_freq) < -MAXFREQ) |
L_LINT(time_freq, -MAXFREQ); |
} |
#ifdef PPS_SYNC |
/* |
* hardpps() - discipline CPU clock oscillator to external PPS signal |
* |
* This routine is called at each PPS interrupt in order to discipline |
* the CPU clock oscillator to the PPS signal. There are two independent |
* first-order feedback loops, one for the phase, the other for the |
* frequency. The phase loop measures and grooms the PPS phase offset |
* and leaves it in a handy spot for the seconds overflow routine. The |
* frequency loop averages successive PPS phase differences and |
* calculates the PPS frequency offset, which is also processed by the |
* seconds overflow routine. The code requires the caller to capture the |
* time and architecture-dependent hardware counter values in |
* nanoseconds at the on-time PPS signal transition. |
* |
* Note that, on some Unix systems this routine runs at an interrupt |
* priority level higher than the timer interrupt routine hardclock(). |
* Therefore, the variables used are distinct from the hardclock() |
* variables, except for the actual time and frequency variables, which |
* are determined by this routine and updated atomically. |
*/ |
void |
hardpps(tsp, nsec) |
struct timespec *tsp; /* time at PPS */ |
long nsec; /* hardware counter at PPS */ |
{ |
long u_sec, u_nsec, v_nsec; /* temps */ |
l_fp ftemp; |
/* |
* The signal is first processed by a range gate and frequency |
* discriminator. The range gate rejects noise spikes outside |
* the range +-500 us. The frequency discriminator rejects input |
* signals with apparent frequency outside the range 1 +-500 |
* PPM. If two hits occur in the same second, we ignore the |
* later hit; if not and a hit occurs outside the range gate, |
* keep the later hit for later comparison, but do not process |
* it. |
*/ |
time_status |= STA_PPSSIGNAL | STA_PPSJITTER; |
time_status &= ~(STA_PPSWANDER | STA_PPSERROR); |
pps_valid = PPS_VALID; |
u_sec = tsp->tv_sec; |
u_nsec = tsp->tv_nsec; |
if (u_nsec >= (NANOSECOND >> 1)) { |
u_nsec -= NANOSECOND; |
u_sec++; |
} |
v_nsec = u_nsec - pps_tf[0].tv_nsec; |
if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - |
MAXFREQ) |
return; |
pps_tf[2] = pps_tf[1]; |
pps_tf[1] = pps_tf[0]; |
pps_tf[0].tv_sec = u_sec; |
pps_tf[0].tv_nsec = u_nsec; |
/* |
* Compute the difference between the current and previous |
* counter values. If the difference exceeds 0.5 s, assume it |
* has wrapped around, so correct 1.0 s. If the result exceeds |
* the tick interval, the sample point has crossed a tick |
* boundary during the last second, so correct the tick. Very |
* intricate. |
*/ |
u_nsec = nsec; |
if (u_nsec > (NANOSECOND >> 1)) |
u_nsec -= NANOSECOND; |
else if (u_nsec < -(NANOSECOND >> 1)) |
u_nsec += NANOSECOND; |
pps_fcount += u_nsec; |
if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) |
return; |
time_status &= ~STA_PPSJITTER; |
/* |
* A three-stage median filter is used to help denoise the PPS |
* time. The median sample becomes the time offset estimate; the |
* difference between the other two samples becomes the time |
* dispersion (jitter) estimate. |
*/ |
if (pps_tf[0].tv_nsec > pps_tf[1].tv_nsec) { |
if (pps_tf[1].tv_nsec > pps_tf[2].tv_nsec) { |
v_nsec = pps_tf[1].tv_nsec; /* 0 1 2 */ |
u_nsec = pps_tf[0].tv_nsec - pps_tf[2].tv_nsec; |
} else if (pps_tf[2].tv_nsec > pps_tf[0].tv_nsec) { |
v_nsec = pps_tf[0].tv_nsec; /* 2 0 1 */ |
u_nsec = pps_tf[2].tv_nsec - pps_tf[1].tv_nsec; |
} else { |
v_nsec = pps_tf[2].tv_nsec; /* 0 2 1 */ |
u_nsec = pps_tf[0].tv_nsec - pps_tf[1].tv_nsec; |
} |
} else { |
if (pps_tf[1].tv_nsec < pps_tf[2].tv_nsec) { |
v_nsec = pps_tf[1].tv_nsec; /* 2 1 0 */ |
u_nsec = pps_tf[2].tv_nsec - pps_tf[0].tv_nsec; |
} else if (pps_tf[2].tv_nsec < pps_tf[0].tv_nsec) { |
v_nsec = pps_tf[0].tv_nsec; /* 1 0 2 */ |
u_nsec = pps_tf[1].tv_nsec - pps_tf[2].tv_nsec; |
} else { |
v_nsec = pps_tf[2].tv_nsec; /* 1 2 0 */ |
u_nsec = pps_tf[1].tv_nsec - pps_tf[0].tv_nsec; |
} |
} |
/* |
* Nominal jitter is due to PPS signal noise and interrupt |
* latency. If it exceeds the popcorn threshold, the sample is |
* discarded. otherwise, if so enabled, the time offset is |
* updated. We can tolerate a modest loss of data here without |
* much degrading time accuracy. |
*/ |
if (u_nsec > (pps_jitter << PPS_POPCORN)) { |
time_status |= STA_PPSJITTER; |
pps_jitcnt++; |
} else if (time_status & STA_PPSTIME) { |
time_monitor = -v_nsec; |
L_LINT(time_offset, time_monitor); |
} |
pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG; |
u_sec = pps_tf[0].tv_sec - pps_lastsec; |
if (u_sec < (1 << pps_shift)) |
return; |
/* |
* At the end of the calibration interval the difference between |
* the first and last counter values becomes the scaled |
* frequency. It will later be divided by the length of the |
* interval to determine the frequency update. If the frequency |
* exceeds a sanity threshold, or if the actual calibration |
* interval is not equal to the expected length, the data are |
* discarded. We can tolerate a modest loss of data here without |
* much degrading frequency accuracy. |
*/ |
pps_calcnt++; |
v_nsec = -pps_fcount; |
pps_lastsec = pps_tf[0].tv_sec; |
pps_fcount = 0; |
u_nsec = MAXFREQ << pps_shift; |
if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << |
pps_shift)) { |
time_status |= STA_PPSERROR; |
pps_errcnt++; |
return; |
} |
/* |
* Here the raw frequency offset and wander (stability) is |
* calculated. If the wander is less than the wander threshold |
* for four consecutive averaging intervals, the interval is |
* doubled; if it is greater than the threshold for four |
* consecutive intervals, the interval is halved. The scaled |
* frequency offset is converted to frequency offset. The |
* stability metric is calculated as the average of recent |
* frequency changes, but is used only for performance |
* monitoring. |
*/ |
L_LINT(ftemp, v_nsec); |
L_RSHIFT(ftemp, pps_shift); |
L_SUB(ftemp, pps_freq); |
u_nsec = L_GINT(ftemp); |
if (u_nsec > PPS_MAXWANDER) { |
L_LINT(ftemp, PPS_MAXWANDER); |
pps_intcnt--; |
time_status |= STA_PPSWANDER; |
pps_stbcnt++; |
} else if (u_nsec < -PPS_MAXWANDER) { |
L_LINT(ftemp, -PPS_MAXWANDER); |
pps_intcnt--; |
time_status |= STA_PPSWANDER; |
pps_stbcnt++; |
} else { |
pps_intcnt++; |
} |
if (pps_intcnt >= 4) { |
pps_intcnt = 4; |
if (pps_shift < pps_shiftmax) { |
pps_shift++; |
pps_intcnt = 0; |
} |
} else if (pps_intcnt <= -4 || pps_shift > pps_shiftmax) { |
pps_intcnt = -4; |
if (pps_shift > PPS_FAVG) { |
pps_shift--; |
pps_intcnt = 0; |
} |
} |
if (u_nsec < 0) |
u_nsec = -u_nsec; |
pps_stabil += (u_nsec * SCALE_PPM - pps_stabil) >> PPS_FAVG; |
/* |
* The PPS frequency is recalculated and clamped to the maximum |
* MAXFREQ. If enabled, the system clock frequency is updated as |
* well. |
*/ |
L_ADD(pps_freq, ftemp); |
u_nsec = L_GINT(pps_freq); |
if (u_nsec > MAXFREQ) |
L_LINT(pps_freq, MAXFREQ); |
else if (u_nsec < -MAXFREQ) |
L_LINT(pps_freq, -MAXFREQ); |
if (time_status & STA_PPSFREQ) |
time_freq = pps_freq; |
} |
#endif /* PPS_SYNC */ |
#ifndef _SYS_SYSPROTO_H_ |
struct adjtime_args { |
struct timeval *delta; |
struct timeval *olddelta; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
adjtime(struct thread *td, struct adjtime_args *uap) |
{ |
struct timeval delta, olddelta, *deltap; |
int error; |
if (uap->delta) { |
error = copyin(uap->delta, &delta, sizeof(delta)); |
if (error) |
return (error); |
deltap = δ |
} else |
deltap = NULL; |
error = kern_adjtime(td, deltap, &olddelta); |
if (uap->olddelta && error == 0) |
error = copyout(&olddelta, uap->olddelta, sizeof(olddelta)); |
return (error); |
} |
int |
kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) |
{ |
struct timeval atv; |
int error = 0; |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
return (error); |
#endif |
if (!cf_jailadjtime && jailed(td->td_ucred)) |
return (EPERM); |
if (!cf_useradjtime && (error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) != 0) |
return (error); /* jail is already checked */ |
mtx_lock(&Giant); |
if (olddelta) { |
atv.tv_sec = time_adjtime / 1000000; |
atv.tv_usec = time_adjtime % 1000000; |
if (atv.tv_usec < 0) { |
atv.tv_usec += 1000000; |
atv.tv_sec--; |
} |
*olddelta = atv; |
} |
if (delta) |
time_adjtime = (int64_t)delta->tv_sec * 1000000 + |
delta->tv_usec; |
mtx_unlock(&Giant); |
return (error); |
} |
/FreeBSD/mac_settime/trunk/patches/ntp/ntpd.c |
---|
0,0 → 1,1274 |
/* |
* ntpd.c - main program for the fixed point NTP daemon |
*/ |
#ifdef HAVE_CONFIG_H |
# include <config.h> |
#endif |
#include "ntp_machine.h" |
#include "ntpd.h" |
#include "ntp_io.h" |
#include "ntp_stdlib.h" |
#ifdef SIM |
#include "ntpsim.h" |
#endif |
#ifdef HAVE_UNISTD_H |
# include <unistd.h> |
#endif |
#ifdef HAVE_SYS_STAT_H |
# include <sys/stat.h> |
#endif |
#include <stdio.h> |
#ifndef SYS_WINNT |
# if !defined(VMS) /*wjm*/ |
# ifdef HAVE_SYS_PARAM_H |
# include <sys/param.h> |
# endif |
# endif /* VMS */ |
# ifdef HAVE_SYS_SIGNAL_H |
# include <sys/signal.h> |
# else |
# include <signal.h> |
# endif |
# ifdef HAVE_SYS_IOCTL_H |
# include <sys/ioctl.h> |
# endif /* HAVE_SYS_IOCTL_H */ |
# ifdef HAVE_SYS_RESOURCE_H |
# include <sys/resource.h> |
# endif /* HAVE_SYS_RESOURCE_H */ |
#else |
# include <signal.h> |
# include <process.h> |
# include <io.h> |
# include "../libntp/log.h" |
# include <clockstuff.h> |
# include <crtdbg.h> |
#endif /* SYS_WINNT */ |
#if defined(HAVE_RTPRIO) |
# ifdef HAVE_SYS_RESOURCE_H |
# include <sys/resource.h> |
# endif |
# ifdef HAVE_SYS_LOCK_H |
# include <sys/lock.h> |
# endif |
# include <sys/rtprio.h> |
#else |
# ifdef HAVE_PLOCK |
# ifdef HAVE_SYS_LOCK_H |
# include <sys/lock.h> |
# endif |
# endif |
#endif |
#if defined(HAVE_SCHED_SETSCHEDULER) |
# ifdef HAVE_SCHED_H |
# include <sched.h> |
# else |
# ifdef HAVE_SYS_SCHED_H |
# include <sys/sched.h> |
# endif |
# endif |
#endif |
#if defined(HAVE_SYS_MMAN_H) |
# include <sys/mman.h> |
#endif |
#ifdef HAVE_TERMIOS_H |
# include <termios.h> |
#endif |
#ifdef SYS_DOMAINOS |
# include <apollo/base.h> |
#endif /* SYS_DOMAINOS */ |
#include "recvbuff.h" |
#include "ntp_cmdargs.h" |
#if 0 /* HMS: I don't think we need this. 961223 */ |
#ifdef LOCK_PROCESS |
# ifdef SYS_SOLARIS |
# include <sys/mman.h> |
# else |
# include <sys/lock.h> |
# endif |
#endif |
#endif |
#ifdef _AIX |
# include <ulimit.h> |
#endif /* _AIX */ |
#ifdef SCO5_CLOCK |
# include <sys/ci/ciioctl.h> |
#endif |
#ifdef HAVE_CLOCKCTL |
# include <ctype.h> |
# include <grp.h> |
# include <pwd.h> |
#endif |
/* |
* Signals we catch for debugging. If not debugging we ignore them. |
*/ |
#define MOREDEBUGSIG SIGUSR1 |
#define LESSDEBUGSIG SIGUSR2 |
/* |
* Signals which terminate us gracefully. |
*/ |
#ifndef SYS_WINNT |
# define SIGDIE1 SIGHUP |
# define SIGDIE3 SIGQUIT |
# define SIGDIE2 SIGINT |
# define SIGDIE4 SIGTERM |
#endif /* SYS_WINNT */ |
#if defined SYS_WINNT |
/* handles for various threads, process, and objects */ |
HANDLE ResolverThreadHandle = NULL; |
/* variables used to inform the Service Control Manager of our current state */ |
BOOL NoWinService = FALSE; |
SERVICE_STATUS ssStatus; |
SERVICE_STATUS_HANDLE sshStatusHandle; |
HANDLE WaitHandles[3] = { NULL, NULL, NULL }; |
char szMsgPath[255]; |
static BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType); |
BOOL init_randfile(); |
#endif /* SYS_WINNT */ |
/* |
* Scheduling priority we run at |
*/ |
#define NTPD_PRIO (-12) |
int priority_done = 2; /* 0 - Set priority */ |
/* 1 - priority is OK where it is */ |
/* 2 - Don't set priority */ |
/* 1 and 2 are pretty much the same */ |
/* |
* Debugging flag |
*/ |
volatile int debug; |
/* |
* Set the processing not to be in the forground |
*/ |
int forground_process = FALSE; |
/* |
* No-fork flag. If set, we do not become a background daemon. |
*/ |
int nofork; |
#ifdef HAVE_CLOCKCTL |
char *user = NULL; /* User to switch to */ |
char *group = NULL; /* group to switch to */ |
char *chrootdir = NULL; /* directory to chroot to */ |
int sw_uid; |
int sw_gid; |
char *endp; |
struct group *gr; |
struct passwd *pw; |
#endif /* HAVE_CLOCKCTL */ |
/* |
* Initializing flag. All async routines watch this and only do their |
* thing when it is clear. |
*/ |
int initializing; |
/* |
* Version declaration |
*/ |
extern const char *Version; |
int was_alarmed; |
#ifdef DECL_SYSCALL |
/* |
* We put this here, since the argument profile is syscall-specific |
*/ |
extern int syscall P((int, ...)); |
#endif /* DECL_SYSCALL */ |
#ifdef SIGDIE2 |
static RETSIGTYPE finish P((int)); |
#endif /* SIGDIE2 */ |
#ifdef DEBUG |
#ifndef SYS_WINNT |
static RETSIGTYPE moredebug P((int)); |
static RETSIGTYPE lessdebug P((int)); |
#endif |
#else /* not DEBUG */ |
static RETSIGTYPE no_debug P((int)); |
#endif /* not DEBUG */ |
int ntpdmain P((int, char **)); |
static void set_process_priority P((void)); |
#ifdef SIM |
int |
main( |
int argc, |
char *argv[] |
) |
{ |
return ntpsim(argc, argv); |
} |
#else /* SIM */ |
#ifdef NO_MAIN_ALLOWED |
CALL(ntpd,"ntpd",ntpdmain); |
#else |
int |
main( |
int argc, |
char *argv[] |
) |
{ |
return ntpdmain(argc, argv); |
} |
#endif |
#endif /* SIM */ |
#ifdef _AIX |
/* |
* OK. AIX is different than solaris in how it implements plock(). |
* If you do NOT adjust the stack limit, you will get the MAXIMUM |
* stack size allocated and PINNED with you program. To check the |
* value, use ulimit -a. |
* |
* To fix this, we create an automatic variable and set our stack limit |
* to that PLUS 32KB of extra space (we need some headroom). |
* |
* This subroutine gets the stack address. |
* |
* Grover Davidson and Matt Ladendorf |
* |
*/ |
static char * |
get_aix_stack(void) |
{ |
char ch; |
return (&ch); |
} |
/* |
* Signal handler for SIGDANGER. |
*/ |
static void |
catch_danger(int signo) |
{ |
msyslog(LOG_INFO, "ntpd: setpgid(): %m"); |
/* Make the system believe we'll free something, but don't do it! */ |
return; |
} |
#endif /* _AIX */ |
/* |
* Set the process priority |
*/ |
static void |
set_process_priority(void) |
{ |
#ifdef DEBUG |
if (debug > 1) |
msyslog(LOG_DEBUG, "set_process_priority: %s: priority_done is <%d>", |
((priority_done) |
? "Leave priority alone" |
: "Attempt to set priority" |
), |
priority_done); |
#endif /* DEBUG */ |
#ifdef SYS_WINNT |
priority_done += NT_set_process_priority(); |
#endif |
#if defined(HAVE_SCHED_SETSCHEDULER) |
if (!priority_done) { |
extern int config_priority_override, config_priority; |
int pmax, pmin; |
struct sched_param sched; |
pmax = sched_get_priority_max(SCHED_FIFO); |
sched.sched_priority = pmax; |
if ( config_priority_override ) { |
pmin = sched_get_priority_min(SCHED_FIFO); |
if ( config_priority > pmax ) |
sched.sched_priority = pmax; |
else if ( config_priority < pmin ) |
sched.sched_priority = pmin; |
else |
sched.sched_priority = config_priority; |
} |
if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 ) |
msyslog(LOG_ERR, "sched_setscheduler(): %m"); |
else |
++priority_done; |
} |
#endif /* HAVE_SCHED_SETSCHEDULER */ |
#if defined(HAVE_RTPRIO) |
# ifdef RTP_SET |
if (!priority_done) { |
struct rtprio srtp; |
srtp.type = RTP_PRIO_REALTIME; /* was: RTP_PRIO_NORMAL */ |
srtp.prio = 0; /* 0 (hi) -> RTP_PRIO_MAX (31,lo) */ |
if (rtprio(RTP_SET, getpid(), &srtp) < 0) |
msyslog(LOG_ERR, "rtprio() error: %m"); |
else |
++priority_done; |
} |
# else /* not RTP_SET */ |
if (!priority_done) { |
if (rtprio(0, 120) < 0) |
msyslog(LOG_ERR, "rtprio() error: %m"); |
else |
++priority_done; |
} |
# endif /* not RTP_SET */ |
#endif /* HAVE_RTPRIO */ |
#if defined(NTPD_PRIO) && NTPD_PRIO != 0 |
# ifdef HAVE_ATT_NICE |
if (!priority_done) { |
errno = 0; |
if (-1 == nice (NTPD_PRIO) && errno != 0) |
msyslog(LOG_ERR, "nice() error: %m"); |
else |
++priority_done; |
} |
# endif /* HAVE_ATT_NICE */ |
# ifdef HAVE_BSD_NICE |
if (!priority_done) { |
if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO)) |
msyslog(LOG_ERR, "setpriority() error: %m"); |
else |
++priority_done; |
} |
# endif /* HAVE_BSD_NICE */ |
#endif /* NTPD_PRIO && NTPD_PRIO != 0 */ |
if (!priority_done) |
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority"); |
} |
/* |
* Main program. Initialize us, disconnect us from the tty if necessary, |
* and loop waiting for I/O and/or timer expiries. |
*/ |
int |
ntpdmain( |
int argc, |
char *argv[] |
) |
{ |
l_fp now; |
char *cp; |
struct recvbuf *rbuflist; |
struct recvbuf *rbuf; |
#ifdef _AIX /* HMS: ifdef SIGDANGER? */ |
struct sigaction sa; |
#endif |
initializing = 1; /* mark that we are initializing */ |
debug = 0; /* no debugging by default */ |
nofork = 0; /* will fork by default */ |
#ifdef HAVE_UMASK |
{ |
mode_t uv; |
uv = umask(0); |
if(uv) |
(void) umask(uv); |
else |
(void) umask(022); |
} |
#endif |
#if 0 && defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */ |
{ |
uid_t uid; |
uid = getuid(); |
if (uid) |
{ |
msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid); |
exit(1); |
} |
} |
#endif |
#ifdef SYS_WINNT |
/* Set the Event-ID message-file name. */ |
if (!GetModuleFileName(NULL, szMsgPath, sizeof(szMsgPath))) { |
msyslog(LOG_ERR, "GetModuleFileName(PGM_EXE_FILE) failed: %m\n"); |
exit(1); |
} |
addSourceToRegistry("NTP", szMsgPath); |
#endif |
getstartup(argc, argv); /* startup configuration, may set debug */ |
if (debug) |
printf("%s\n", Version); |
/* |
* Initialize random generator and public key pair |
*/ |
#ifdef SYS_WINNT |
/* Initialize random file before OpenSSL checks */ |
if(!init_randfile()) |
msyslog(LOG_ERR, "Unable to initialize .rnd file\n"); |
#endif |
get_systime(&now); |
SRANDOM((int)(now.l_i * now.l_uf)); |
#if !defined(VMS) |
# ifndef NODETACH |
/* |
* Detach us from the terminal. May need an #ifndef GIZMO. |
*/ |
# ifdef DEBUG |
if (!debug && !nofork) |
# else /* DEBUG */ |
if (!nofork) |
# endif /* DEBUG */ |
{ |
# ifndef SYS_WINNT |
# ifdef HAVE_DAEMON |
daemon(0, 0); |
# else /* not HAVE_DAEMON */ |
if (fork()) /* HMS: What about a -1? */ |
exit(0); |
{ |
#if !defined(F_CLOSEM) |
u_long s; |
int max_fd; |
#endif /* not F_CLOSEM */ |
#if defined(F_CLOSEM) |
/* |
* From 'Writing Reliable AIX Daemons,' SG24-4946-00, |
* by Eric Agar (saves us from doing 32767 system |
* calls) |
*/ |
if (fcntl(0, F_CLOSEM, 0) == -1) |
msyslog(LOG_ERR, "ntpd: failed to close open files(): %m"); |
#else /* not F_CLOSEM */ |
# if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) |
max_fd = sysconf(_SC_OPEN_MAX); |
# else /* HAVE_SYSCONF && _SC_OPEN_MAX */ |
max_fd = getdtablesize(); |
# endif /* HAVE_SYSCONF && _SC_OPEN_MAX */ |
for (s = 0; s < max_fd; s++) |
(void) close((int)s); |
#endif /* not F_CLOSEM */ |
(void) open("/", 0); |
(void) dup2(0, 1); |
(void) dup2(0, 2); |
#ifdef SYS_DOMAINOS |
{ |
uid_$t puid; |
status_$t st; |
proc2_$who_am_i(&puid); |
proc2_$make_server(&puid, &st); |
} |
#endif /* SYS_DOMAINOS */ |
#if defined(HAVE_SETPGID) || defined(HAVE_SETSID) |
# ifdef HAVE_SETSID |
if (setsid() == (pid_t)-1) |
msyslog(LOG_ERR, "ntpd: setsid(): %m"); |
# else |
if (setpgid(0, 0) == -1) |
msyslog(LOG_ERR, "ntpd: setpgid(): %m"); |
# endif |
#else /* HAVE_SETPGID || HAVE_SETSID */ |
{ |
# if defined(TIOCNOTTY) |
int fid; |
fid = open("/dev/tty", 2); |
if (fid >= 0) |
{ |
(void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0); |
(void) close(fid); |
} |
# endif /* defined(TIOCNOTTY) */ |
# ifdef HAVE_SETPGRP_0 |
(void) setpgrp(); |
# else /* HAVE_SETPGRP_0 */ |
(void) setpgrp(0, getpid()); |
# endif /* HAVE_SETPGRP_0 */ |
} |
#endif /* HAVE_SETPGID || HAVE_SETSID */ |
#ifdef _AIX |
/* Don't get killed by low-on-memory signal. */ |
sa.sa_handler = catch_danger; |
sigemptyset(&sa.sa_mask); |
sa.sa_flags = SA_RESTART; |
(void) sigaction(SIGDANGER, &sa, NULL); |
#endif /* _AIX */ |
} |
# endif /* not HAVE_DAEMON */ |
# else /* SYS_WINNT */ |
{ |
if (NoWinService == FALSE) { |
SERVICE_TABLE_ENTRY dispatchTable[] = { |
{ TEXT("NetworkTimeProtocol"), (LPSERVICE_MAIN_FUNCTION)service_main }, |
{ NULL, NULL } |
}; |
/* daemonize */ |
if (!StartServiceCtrlDispatcher(dispatchTable)) |
{ |
msyslog(LOG_ERR, "StartServiceCtrlDispatcher: %m"); |
ExitProcess(2); |
} |
} |
else { |
service_main(argc, argv); |
return 0; |
} |
} |
# endif /* SYS_WINNT */ |
} |
# endif /* NODETACH */ |
# if defined(SYS_WINNT) && !defined(NODETACH) |
else |
service_main(argc, argv); |
return 0; /* must return a value */ |
} /* end main */ |
/* |
* If this runs as a service under NT, the main thread will block at |
* StartServiceCtrlDispatcher() and another thread will be started by the |
* Service Control Dispatcher which will begin execution at the routine |
* specified in that call (viz. service_main) |
*/ |
void |
service_main( |
DWORD argc, |
LPTSTR *argv |
) |
{ |
char *cp; |
struct recvbuf *rbuflist; |
struct recvbuf *rbuf; |
if(!debug && NoWinService == FALSE) |
{ |
/* register our service control handler */ |
sshStatusHandle = RegisterServiceCtrlHandler( TEXT("NetworkTimeProtocol"), |
(LPHANDLER_FUNCTION)service_ctrl); |
if(sshStatusHandle == 0) |
{ |
msyslog(LOG_ERR, "RegisterServiceCtrlHandler failed: %m"); |
return; |
} |
/* report pending status to Service Control Manager */ |
ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; |
ssStatus.dwCurrentState = SERVICE_START_PENDING; |
ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
ssStatus.dwServiceSpecificExitCode = 0; |
ssStatus.dwCheckPoint = 1; |
ssStatus.dwWaitHint = 5000; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
return; |
} |
} /* debug */ |
# endif /* defined(SYS_WINNT) && !defined(NODETACH) */ |
#endif /* VMS */ |
/* |
* Logging. This may actually work on the gizmo board. Find a name |
* to log with by using the basename of argv[0] |
*/ |
cp = strrchr(argv[0], '/'); |
if (cp == 0) |
cp = argv[0]; |
else |
cp++; |
debug = 0; /* will be immediately re-initialized 8-( */ |
getstartup(argc, argv); /* startup configuration, catch logfile this time */ |
#if !defined(VMS) |
# ifndef LOG_DAEMON |
openlog(cp, LOG_PID); |
# else /* LOG_DAEMON */ |
# ifndef LOG_NTP |
# define LOG_NTP LOG_DAEMON |
# endif |
openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP); |
# ifdef DEBUG |
if (debug) |
setlogmask(LOG_UPTO(LOG_DEBUG)); |
else |
# endif /* DEBUG */ |
setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */ |
# endif /* LOG_DAEMON */ |
#endif /* !SYS_WINNT && !VMS */ |
NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */ |
msyslog(LOG_NOTICE, "%s", Version); |
#ifdef SYS_WINNT |
/* GMS 1/18/1997 |
* TODO: lock the process in memory using SetProcessWorkingSetSize() and VirtualLock() functions |
* |
process_handle = GetCurrentProcess(); |
if (SetProcessWorkingSetSize(process_handle, 2097152 , 4194304 ) == TRUE) { |
if (VirtualLock(0 , 4194304) == FALSE) |
msyslog(LOG_ERR, "VirtualLock() failed: %m"); |
} else { |
msyslog(LOG_ERR, "SetProcessWorkingSetSize() failed: %m"); |
} |
*/ |
#endif /* SYS_WINNT */ |
#ifdef SCO5_CLOCK |
/* |
* SCO OpenServer's system clock offers much more precise timekeeping |
* on the base CPU than the other CPUs (for multiprocessor systems), |
* so we must lock to the base CPU. |
*/ |
{ |
int fd = open("/dev/at1", O_RDONLY); |
if (fd >= 0) { |
int zero = 0; |
if (ioctl(fd, ACPU_LOCK, &zero) < 0) |
msyslog(LOG_ERR, "cannot lock to base CPU: %m\n"); |
close( fd ); |
} /* else ... |
* If we can't open the device, this probably just isn't |
* a multiprocessor system, so we're A-OK. |
*/ |
} |
#endif |
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE) |
# ifdef HAVE_SETRLIMIT |
/* |
* Set the stack limit to something smaller, so that we don't lock a lot |
* of unused stack memory. |
*/ |
{ |
struct rlimit rl; |
if (getrlimit(RLIMIT_STACK, &rl) != -1 |
&& (rl.rlim_cur = 20 * 4096) < rl.rlim_max) |
{ |
if (setrlimit(RLIMIT_STACK, &rl) == -1) |
{ |
msyslog(LOG_ERR, |
"Cannot adjust stack limit for mlockall: %m"); |
} |
} |
} |
# endif /* HAVE_SETRLIMIT */ |
/* |
* lock the process into memory |
*/ |
if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) |
msyslog(LOG_ERR, "mlockall(): %m"); |
#else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */ |
# ifdef HAVE_PLOCK |
# ifdef PROCLOCK |
# ifdef _AIX |
/* |
* set the stack limit for AIX for plock(). |
* see get_aix_stack for more info. |
*/ |
if (ulimit(SET_STACKLIM, (get_aix_stack() - 8*4096)) < 0) |
{ |
msyslog(LOG_ERR,"Cannot adjust stack limit for plock on AIX: %m"); |
} |
# endif /* _AIX */ |
/* |
* lock the process into memory |
*/ |
if (plock(PROCLOCK) < 0) |
msyslog(LOG_ERR, "plock(PROCLOCK): %m"); |
# else /* not PROCLOCK */ |
# ifdef TXTLOCK |
/* |
* Lock text into ram |
*/ |
if (plock(TXTLOCK) < 0) |
msyslog(LOG_ERR, "plock(TXTLOCK) error: %m"); |
# else /* not TXTLOCK */ |
msyslog(LOG_ERR, "plock() - don't know what to lock!"); |
# endif /* not TXTLOCK */ |
# endif /* not PROCLOCK */ |
# endif /* HAVE_PLOCK */ |
#endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */ |
/* |
* Set up signals we pay attention to locally. |
*/ |
#ifdef SIGDIE1 |
(void) signal_no_reset(SIGDIE1, finish); |
#endif /* SIGDIE1 */ |
#ifdef SIGDIE2 |
(void) signal_no_reset(SIGDIE2, finish); |
#endif /* SIGDIE2 */ |
#ifdef SIGDIE3 |
(void) signal_no_reset(SIGDIE3, finish); |
#endif /* SIGDIE3 */ |
#ifdef SIGDIE4 |
(void) signal_no_reset(SIGDIE4, finish); |
#endif /* SIGDIE4 */ |
#ifdef SIGBUS |
(void) signal_no_reset(SIGBUS, finish); |
#endif /* SIGBUS */ |
#if !defined(SYS_WINNT) && !defined(VMS) |
# ifdef DEBUG |
(void) signal_no_reset(MOREDEBUGSIG, moredebug); |
(void) signal_no_reset(LESSDEBUGSIG, lessdebug); |
# else |
(void) signal_no_reset(MOREDEBUGSIG, no_debug); |
(void) signal_no_reset(LESSDEBUGSIG, no_debug); |
# endif /* DEBUG */ |
#endif /* !SYS_WINNT && !VMS */ |
/* |
* Set up signals we should never pay attention to. |
*/ |
#if defined SIGPIPE |
(void) signal_no_reset(SIGPIPE, SIG_IGN); |
#endif /* SIGPIPE */ |
#if defined SYS_WINNT |
if (!SetConsoleCtrlHandler(OnConsoleEvent, TRUE)) { |
msyslog(LOG_ERR, "Can't set console control handler: %m"); |
} |
#endif |
/* |
* Call the init_ routines to initialize the data structures. |
*/ |
#if defined (HAVE_IO_COMPLETION_PORT) |
init_io_completion_port(); |
init_winnt_time(); |
#endif |
init_auth(); |
init_util(); |
init_restrict(); |
init_mon(); |
init_timer(); |
init_lib(); |
init_random(); |
init_request(); |
init_control(); |
init_peer(); |
#ifdef REFCLOCK |
init_refclock(); |
#endif |
set_process_priority(); |
init_proto(); /* Call at high priority */ |
init_io(); |
init_loopfilter(); |
mon_start(MON_ON); /* monitor on by default now */ |
/* turn off in config if unwanted */ |
/* |
* Get configuration. This (including argument list parsing) is |
* done in a separate module since this will definitely be different |
* for the gizmo board. While at it, save the host name for later |
* along with the length. The crypto needs this. |
*/ |
#ifdef DEBUG |
debug = 0; |
#endif |
getconfig(argc, argv); |
#ifdef OPENSSL |
crypto_setup(); |
#endif /* OPENSSL */ |
initializing = 0; |
#if defined(SYS_WINNT) && !defined(NODETACH) |
# if defined(DEBUG) |
if(!debug) |
{ |
# endif |
if (NoWinService == FALSE) { |
/* report to the service control manager that the service is running */ |
ssStatus.dwCurrentState = SERVICE_RUNNING; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
if (ResolverThreadHandle != NULL) |
CloseHandle(ResolverThreadHandle); |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
return; |
} |
} |
# if defined(DEBUG) |
} |
# endif |
#endif |
#ifdef HAVE_CLOCKCTL |
/* |
* Drop super-user privileges and chroot now if the OS supports |
* non root clock control (only NetBSD for now). |
*/ |
if (user != NULL) { |
if (isdigit((unsigned char)*user)) { |
sw_uid = (uid_t)strtoul(user, &endp, 0); |
if (*endp != '\0') |
goto getuser; |
} else { |
getuser: |
if ((pw = getpwnam(user)) != NULL) { |
sw_uid = pw->pw_uid; |
} else { |
errno = 0; |
msyslog(LOG_ERR, "Cannot find user `%s'", user); |
exit (-1); |
} |
} |
} |
if (group != NULL) { |
if (isdigit((unsigned char)*group)) { |
sw_gid = (gid_t)strtoul(group, &endp, 0); |
if (*endp != '\0') |
goto getgroup; |
} else { |
getgroup: |
if ((gr = getgrnam(group)) != NULL) { |
sw_gid = pw->pw_gid; |
} else { |
errno = 0; |
msyslog(LOG_ERR, "Cannot find group `%s'", group); |
exit (-1); |
} |
} |
} |
if (chrootdir && chroot(chrootdir)) { |
msyslog(LOG_ERR, "Cannot chroot to `%s': %m", chrootdir); |
exit (-1); |
} |
if (group && setgid(sw_gid)) { |
msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group); |
exit (-1); |
} |
if (group && setegid(sw_gid)) { |
msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group); |
exit (-1); |
} |
if (user && setuid(sw_uid)) { |
msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user); |
exit (-1); |
} |
if (user && seteuid(sw_uid)) { |
msyslog(LOG_ERR, "Cannot seteuid() to user `%s': %m", user); |
exit (-1); |
} |
#endif |
/* |
* Report that we're up to any trappers |
*/ |
report_event(EVNT_SYSRESTART, (struct peer *)0); |
/* |
* Use select() on all on all input fd's for unlimited |
* time. select() will terminate on SIGALARM or on the |
* reception of input. Using select() means we can't do |
* robust signal handling and we get a potential race |
* between checking for alarms and doing the select(). |
* Mostly harmless, I think. |
*/ |
/* On VMS, I suspect that select() can't be interrupted |
* by a "signal" either, so I take the easy way out and |
* have select() time out after one second. |
* System clock updates really aren't time-critical, |
* and - lacking a hardware reference clock - I have |
* yet to learn about anything else that is. |
*/ |
#if defined(HAVE_IO_COMPLETION_PORT) |
WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit reques */ |
WaitHandles[1] = get_timer_handle(); |
WaitHandles[2] = get_io_event(); |
for (;;) { |
DWORD Index = WaitForMultipleObjectsEx(sizeof(WaitHandles)/sizeof(WaitHandles[0]), WaitHandles, FALSE, 1000, TRUE); |
switch (Index) { |
case WAIT_OBJECT_0 + 0 : /* exit request */ |
exit(0); |
break; |
case WAIT_OBJECT_0 + 1 : /* timer */ |
timer(); |
break; |
case WAIT_OBJECT_0 + 2 : /* Io event */ |
# ifdef DEBUG |
if ( debug > 3 ) |
{ |
printf( "IoEvent occurred\n" ); |
} |
# endif |
break; |
case WAIT_IO_COMPLETION : /* loop */ |
case WAIT_TIMEOUT : |
break; |
case WAIT_FAILED: |
msyslog(LOG_ERR, "ntpdc: WaitForMultipleObjectsEx Failed: Error: %m"); |
break; |
/* For now do nothing if not expected */ |
default: |
break; |
} /* switch */ |
rbuflist = getrecvbufs(); /* get received buffers */ |
#else /* normal I/O */ |
was_alarmed = 0; |
rbuflist = (struct recvbuf *)0; |
for (;;) |
{ |
# if !defined(HAVE_SIGNALED_IO) |
extern fd_set activefds; |
extern int maxactivefd; |
fd_set rdfdes; |
int nfound; |
# elif defined(HAVE_SIGNALED_IO) |
block_io_and_alarm(); |
# endif |
rbuflist = getrecvbufs(); /* get received buffers */ |
if (alarm_flag) /* alarmed? */ |
{ |
was_alarmed = 1; |
alarm_flag = 0; |
} |
if (!was_alarmed && rbuflist == (struct recvbuf *)0) |
{ |
/* |
* Nothing to do. Wait for something. |
*/ |
# ifndef HAVE_SIGNALED_IO |
rdfdes = activefds; |
# if defined(VMS) || defined(SYS_VXWORKS) |
/* make select() wake up after one second */ |
{ |
struct timeval t1; |
t1.tv_sec = 1; t1.tv_usec = 0; |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
(fd_set *)0, &t1); |
} |
# else |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
(fd_set *)0, (struct timeval *)0); |
# endif /* VMS */ |
if (nfound > 0) |
{ |
l_fp ts; |
get_systime(&ts); |
(void)input_handler(&ts); |
} |
else if (nfound == -1 && errno != EINTR) |
msyslog(LOG_ERR, "select() error: %m"); |
# ifdef DEBUG |
else if (debug > 2) |
msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound); |
# endif /* DEBUG */ |
# else /* HAVE_SIGNALED_IO */ |
wait_for_signal(); |
# endif /* HAVE_SIGNALED_IO */ |
if (alarm_flag) /* alarmed? */ |
{ |
was_alarmed = 1; |
alarm_flag = 0; |
} |
rbuflist = getrecvbufs(); /* get received buffers */ |
} |
# ifdef HAVE_SIGNALED_IO |
unblock_io_and_alarm(); |
# endif /* HAVE_SIGNALED_IO */ |
/* |
* Out here, signals are unblocked. Call timer routine |
* to process expiry. |
*/ |
if (was_alarmed) |
{ |
timer(); |
was_alarmed = 0; |
} |
#endif /* HAVE_IO_COMPLETION_PORT */ |
/* |
* Call the data procedure to handle each received |
* packet. |
*/ |
while (rbuflist != (struct recvbuf *)0) |
{ |
rbuf = rbuflist; |
rbuflist = rbuf->next; |
(rbuf->receiver)(rbuf); |
freerecvbuf(rbuf); |
} |
#if defined DEBUG && defined SYS_WINNT |
if (debug > 4) |
printf("getrecvbufs: %ld handler interrupts, %ld frames\n", |
handler_calls, handler_pkts); |
#endif |
/* |
* Go around again |
*/ |
} |
#ifndef SYS_WINNT |
exit(1); /* unreachable */ |
#endif |
#ifndef SYS_WINNT |
return 1; /* DEC OSF cc braindamage */ |
#endif |
} |
#ifdef SIGDIE2 |
/* |
* finish - exit gracefully |
*/ |
static RETSIGTYPE |
finish( |
int sig |
) |
{ |
msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig); |
switch (sig) |
{ |
# ifdef SIGBUS |
case SIGBUS: |
printf("\nfinish(SIGBUS)\n"); |
exit(0); |
# endif |
case 0: /* Should never happen... */ |
return; |
default: |
exit(0); |
} |
} |
#endif /* SIGDIE2 */ |
#ifdef DEBUG |
#ifndef SYS_WINNT |
/* |
* moredebug - increase debugging verbosity |
*/ |
static RETSIGTYPE |
moredebug( |
int sig |
) |
{ |
int saved_errno = errno; |
if (debug < 255) |
{ |
debug++; |
msyslog(LOG_DEBUG, "debug raised to %d", debug); |
} |
errno = saved_errno; |
} |
/* |
* lessdebug - decrease debugging verbosity |
*/ |
static RETSIGTYPE |
lessdebug( |
int sig |
) |
{ |
int saved_errno = errno; |
if (debug > 0) |
{ |
debug--; |
msyslog(LOG_DEBUG, "debug lowered to %d", debug); |
} |
errno = saved_errno; |
} |
#endif |
#else /* not DEBUG */ |
#ifndef SYS_WINNT/* |
* no_debug - We don't do the debug here. |
*/ |
static RETSIGTYPE |
no_debug( |
int sig |
) |
{ |
int saved_errno = errno; |
msyslog(LOG_DEBUG, "ntpd not compiled for debugging (signal %d)", sig); |
errno = saved_errno; |
} |
#endif /* not SYS_WINNT */ |
#endif /* not DEBUG */ |
#ifdef SYS_WINNT |
/* service_ctrl - control handler for NTP service |
* signals the service_main routine of start/stop requests |
* from the control panel or other applications making |
* win32API calls |
*/ |
void |
service_ctrl( |
DWORD dwCtrlCode |
) |
{ |
DWORD dwState = SERVICE_RUNNING; |
/* Handle the requested control code */ |
switch(dwCtrlCode) |
{ |
case SERVICE_CONTROL_PAUSE: |
/* see no reason to support this */ |
break; |
case SERVICE_CONTROL_CONTINUE: |
/* see no reason to support this */ |
break; |
case SERVICE_CONTROL_STOP: |
dwState = SERVICE_STOP_PENDING; |
/* |
* Report the status, specifying the checkpoint and waithint, |
* before setting the termination event. |
*/ |
ssStatus.dwCurrentState = dwState; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
ssStatus.dwWaitHint = 3000; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
} |
if (WaitHandles[0] != NULL) { |
SetEvent(WaitHandles[0]); |
} |
return; |
case SERVICE_CONTROL_INTERROGATE: |
/* Update the service status */ |
break; |
default: |
/* invalid control code */ |
break; |
} |
ssStatus.dwCurrentState = dwState; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
} |
} |
static BOOL WINAPI |
OnConsoleEvent( |
DWORD dwCtrlType |
) |
{ |
switch (dwCtrlType) { |
case CTRL_BREAK_EVENT : |
if (debug > 0) { |
debug <<= 1; |
} |
else { |
debug = 1; |
} |
if (debug > 8) { |
debug = 0; |
} |
printf("debug level %d\n", debug); |
break ; |
case CTRL_C_EVENT : |
case CTRL_CLOSE_EVENT : |
case CTRL_SHUTDOWN_EVENT : |
if (WaitHandles[0] != NULL) { |
SetEvent(WaitHandles[0]); |
} |
break; |
default : |
return FALSE; |
} |
return TRUE;; |
} |
/* |
* NT version of exit() - all calls to exit() should be routed to |
* this function. |
*/ |
void |
service_exit( |
int status |
) |
{ |
if (!debug) { /* did not become a service, simply exit */ |
/* service mode, need to have the service_main routine |
* register with the service control manager that the |
* service has stopped running, before exiting |
*/ |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
} |
uninit_io_completion_port(); |
reset_winnt_time(); |
# if defined _MSC_VER |
_CrtDumpMemoryLeaks(); |
# endif |
#undef exit |
exit(status); |
} |
#endif /* SYS_WINNT */ |
/FreeBSD/mac_settime/trunk/origins/module/files |
---|
0,0 → 1,1836 |
# $FreeBSD: src/sys/conf/files,v 1.1031.2.8 2005/10/08 18:00:40 imp Exp $ |
# |
# The long compile-with and dependency lines are required because of |
# limitations in config: backslash-newline doesn't work in strings, and |
# dependency lines other than the first are silently ignored. |
# |
acpi_quirks.h optional acpi \ |
dependency "$S/tools/acpi_quirks2h.awk $S/dev/acpica/acpi_quirks" \ |
compile-with "${AWK} -f $S/tools/acpi_quirks2h.awk $S/dev/acpica/acpi_quirks" \ |
no-obj no-implicit-rule before-depend \ |
clean "acpi_quirks.h" |
aicasm optional ahc \ |
dependency "$S/dev/aic7xxx/aicasm/*.[chyl]" \ |
compile-with "CC=${CC} ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \ |
no-obj no-implicit-rule \ |
clean "aicasm* y.tab.h" |
aicasm optional ahd \ |
dependency "$S/dev/aic7xxx/aicasm/*.[chyl]" \ |
compile-with "CC=${CC} ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \ |
no-obj no-implicit-rule \ |
clean "aicasm* y.tab.h" |
aic7xxx_seq.h optional ahc \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq" \ |
no-obj no-implicit-rule before-depend local \ |
clean "aic7xxx_seq.h" \ |
dependency "$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic7xxx_reg.h optional ahc \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq" \ |
no-obj no-implicit-rule before-depend local \ |
clean "aic7xxx_reg.h" \ |
dependency "$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic7xxx_reg_print.c optional ahc \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq" \ |
no-obj no-implicit-rule local \ |
clean "aic7xxx_reg_print.c" \ |
dependency "$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic7xxx_reg_print.o optional ahc ahc_reg_pretty_print \ |
compile-with "${NORMAL_C}" \ |
no-implicit-rule local |
aic79xx_seq.h optional ahd pci \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq" \ |
no-obj no-implicit-rule before-depend local \ |
clean "aic79xx_seq.h" \ |
dependency "$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic79xx_reg.h optional ahd pci \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq" \ |
no-obj no-implicit-rule before-depend local \ |
clean "aic79xx_reg.h" \ |
dependency "$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic79xx_reg_print.c optional ahd pci \ |
compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq" \ |
no-obj no-implicit-rule local \ |
clean "aic79xx_reg_print.c" \ |
dependency "$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" |
aic79xx_reg_print.o optional ahd pci ahd_reg_pretty_print \ |
compile-with "${NORMAL_C}" \ |
no-implicit-rule local |
emu10k1-alsa%diked.h optional snd_emu10k1 pci \ |
dependency "$S/tools/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/emu10k1-alsa.h" \ |
compile-with "CC=${CC} AWK=${AWK} sh $S/tools/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/emu10k1-alsa.h emu10k1-alsa%diked.h" \ |
no-obj no-implicit-rule before-depend \ |
clean "emu10k1-alsa%diked.h" |
miidevs.h optional miibus \ |
dependency "$S/tools/miidevs2h.awk $S/dev/mii/miidevs" \ |
compile-with "${AWK} -f $S/tools/miidevs2h.awk $S/dev/mii/miidevs" \ |
no-obj no-implicit-rule before-depend \ |
clean "miidevs.h" |
pccarddevs.h standard \ |
dependency "$S/tools/pccarddevs2h.awk $S/dev/pccard/pccarddevs" \ |
compile-with "${AWK} -f $S/tools/pccarddevs2h.awk $S/dev/pccard/pccarddevs" \ |
no-obj no-implicit-rule before-depend \ |
clean "pccarddevs.h" |
usbdevs.h optional usb \ |
dependency "$S/tools/usbdevs2h.awk $S/dev/usb/usbdevs" \ |
compile-with "${AWK} -f $S/tools/usbdevs2h.awk $S/dev/usb/usbdevs -h" \ |
no-obj no-implicit-rule before-depend \ |
clean "usbdevs.h" |
usbdevs_data.h optional usb \ |
dependency "$S/tools/usbdevs2h.awk $S/dev/usb/usbdevs" \ |
compile-with "${AWK} -f $S/tools/usbdevs2h.awk $S/dev/usb/usbdevs -d" \ |
no-obj no-implicit-rule before-depend \ |
clean "usbdevs_data.h" |
cam/cam.c optional scbus |
cam/cam_periph.c optional scbus |
cam/cam_queue.c optional scbus |
cam/cam_sim.c optional scbus |
cam/cam_xpt.c optional scbus |
cam/scsi/scsi_all.c optional scbus |
cam/scsi/scsi_cd.c optional cd |
cam/scsi/scsi_ch.c optional ch |
cam/scsi/scsi_da.c optional da |
cam/scsi/scsi_low.c optional ct |
cam/scsi/scsi_low.c optional ncv |
cam/scsi/scsi_low.c optional nsp |
cam/scsi/scsi_low.c optional stg |
cam/scsi/scsi_low_pisa.c optional ct |
cam/scsi/scsi_low_pisa.c optional ncv |
cam/scsi/scsi_low_pisa.c optional nsp |
cam/scsi/scsi_low_pisa.c optional stg |
cam/scsi/scsi_pass.c optional pass |
cam/scsi/scsi_pt.c optional pt |
cam/scsi/scsi_sa.c optional sa |
cam/scsi/scsi_ses.c optional ses |
cam/scsi/scsi_targ_bh.c optional targbh |
cam/scsi/scsi_target.c optional targ |
coda/coda_fbsd.c optional vcoda |
coda/coda_namecache.c optional vcoda |
coda/coda_psdev.c optional vcoda |
coda/coda_subr.c optional vcoda |
coda/coda_venus.c optional vcoda |
coda/coda_vfsops.c optional vcoda |
coda/coda_vnops.c optional vcoda |
compat/linprocfs/linprocfs.c optional linprocfs |
contrib/altq/altq/altq_cbq.c optional altq |
contrib/altq/altq/altq_cdnr.c optional altq |
contrib/altq/altq/altq_hfsc.c optional altq |
contrib/altq/altq/altq_priq.c optional altq |
contrib/altq/altq/altq_red.c optional altq |
contrib/altq/altq/altq_rio.c optional altq |
contrib/altq/altq/altq_rmclass.c optional altq |
contrib/altq/altq/altq_subr.c optional altq |
contrib/dev/acpica/dbcmds.c optional acpi acpi_debug |
contrib/dev/acpica/dbdisply.c optional acpi acpi_debug |
contrib/dev/acpica/dbexec.c optional acpi acpi_debug |
contrib/dev/acpica/dbfileio.c optional acpi acpi_debug |
contrib/dev/acpica/dbhistry.c optional acpi acpi_debug |
contrib/dev/acpica/dbinput.c optional acpi acpi_debug |
contrib/dev/acpica/dbstats.c optional acpi acpi_debug |
contrib/dev/acpica/dbutils.c optional acpi acpi_debug |
contrib/dev/acpica/dbxface.c optional acpi acpi_debug |
contrib/dev/acpica/dmbuffer.c optional acpi acpi_debug |
contrib/dev/acpica/dmnames.c optional acpi acpi_debug |
contrib/dev/acpica/dmopcode.c optional acpi acpi_debug |
contrib/dev/acpica/dmobject.c optional acpi acpi_debug |
contrib/dev/acpica/dmresrc.c optional acpi acpi_debug |
contrib/dev/acpica/dmresrcl.c optional acpi acpi_debug |
contrib/dev/acpica/dmresrcs.c optional acpi acpi_debug |
contrib/dev/acpica/dmutils.c optional acpi acpi_debug |
contrib/dev/acpica/dmwalk.c optional acpi acpi_debug |
contrib/dev/acpica/dsfield.c optional acpi |
contrib/dev/acpica/dsinit.c optional acpi |
contrib/dev/acpica/dsmethod.c optional acpi |
contrib/dev/acpica/dsmthdat.c optional acpi |
contrib/dev/acpica/dsobject.c optional acpi |
contrib/dev/acpica/dsopcode.c optional acpi |
contrib/dev/acpica/dsutils.c optional acpi |
contrib/dev/acpica/dswexec.c optional acpi |
contrib/dev/acpica/dswload.c optional acpi |
contrib/dev/acpica/dswscope.c optional acpi |
contrib/dev/acpica/dswstate.c optional acpi |
contrib/dev/acpica/evevent.c optional acpi |
contrib/dev/acpica/evgpe.c optional acpi |
contrib/dev/acpica/evgpeblk.c optional acpi |
contrib/dev/acpica/evmisc.c optional acpi |
contrib/dev/acpica/evregion.c optional acpi |
contrib/dev/acpica/evrgnini.c optional acpi |
contrib/dev/acpica/evsci.c optional acpi |
contrib/dev/acpica/evxface.c optional acpi |
contrib/dev/acpica/evxfevnt.c optional acpi |
contrib/dev/acpica/evxfregn.c optional acpi |
contrib/dev/acpica/exconfig.c optional acpi |
contrib/dev/acpica/exconvrt.c optional acpi |
contrib/dev/acpica/excreate.c optional acpi |
contrib/dev/acpica/exdump.c optional acpi |
contrib/dev/acpica/exfield.c optional acpi |
contrib/dev/acpica/exfldio.c optional acpi |
contrib/dev/acpica/exmisc.c optional acpi |
contrib/dev/acpica/exmutex.c optional acpi |
contrib/dev/acpica/exnames.c optional acpi |
contrib/dev/acpica/exoparg1.c optional acpi |
contrib/dev/acpica/exoparg2.c optional acpi |
contrib/dev/acpica/exoparg3.c optional acpi |
contrib/dev/acpica/exoparg6.c optional acpi |
contrib/dev/acpica/exprep.c optional acpi |
contrib/dev/acpica/exregion.c optional acpi |
contrib/dev/acpica/exresnte.c optional acpi |
contrib/dev/acpica/exresolv.c optional acpi |
contrib/dev/acpica/exresop.c optional acpi |
contrib/dev/acpica/exstore.c optional acpi |
contrib/dev/acpica/exstoren.c optional acpi |
contrib/dev/acpica/exstorob.c optional acpi |
contrib/dev/acpica/exsystem.c optional acpi |
contrib/dev/acpica/exutils.c optional acpi |
contrib/dev/acpica/hwacpi.c optional acpi |
contrib/dev/acpica/hwgpe.c optional acpi |
contrib/dev/acpica/hwregs.c optional acpi |
contrib/dev/acpica/hwsleep.c optional acpi |
contrib/dev/acpica/hwtimer.c optional acpi |
contrib/dev/acpica/nsaccess.c optional acpi |
contrib/dev/acpica/nsalloc.c optional acpi |
contrib/dev/acpica/nsdump.c optional acpi |
contrib/dev/acpica/nseval.c optional acpi |
contrib/dev/acpica/nsinit.c optional acpi |
contrib/dev/acpica/nsload.c optional acpi |
contrib/dev/acpica/nsnames.c optional acpi |
contrib/dev/acpica/nsobject.c optional acpi |
contrib/dev/acpica/nsparse.c optional acpi |
contrib/dev/acpica/nssearch.c optional acpi |
contrib/dev/acpica/nsutils.c optional acpi |
contrib/dev/acpica/nswalk.c optional acpi |
contrib/dev/acpica/nsxfeval.c optional acpi |
contrib/dev/acpica/nsxfname.c optional acpi |
contrib/dev/acpica/nsxfobj.c optional acpi |
contrib/dev/acpica/psargs.c optional acpi |
contrib/dev/acpica/psopcode.c optional acpi |
contrib/dev/acpica/psparse.c optional acpi |
contrib/dev/acpica/psscope.c optional acpi |
contrib/dev/acpica/pstree.c optional acpi |
contrib/dev/acpica/psutils.c optional acpi |
contrib/dev/acpica/pswalk.c optional acpi |
contrib/dev/acpica/psxface.c optional acpi |
contrib/dev/acpica/rsaddr.c optional acpi |
contrib/dev/acpica/rscalc.c optional acpi |
contrib/dev/acpica/rscreate.c optional acpi |
contrib/dev/acpica/rsdump.c optional acpi |
contrib/dev/acpica/rsio.c optional acpi |
contrib/dev/acpica/rsirq.c optional acpi |
contrib/dev/acpica/rslist.c optional acpi |
contrib/dev/acpica/rsmemory.c optional acpi |
contrib/dev/acpica/rsmisc.c optional acpi |
contrib/dev/acpica/rsutils.c optional acpi |
contrib/dev/acpica/rsxface.c optional acpi |
contrib/dev/acpica/tbconvrt.c optional acpi |
contrib/dev/acpica/tbget.c optional acpi |
contrib/dev/acpica/tbgetall.c optional acpi |
contrib/dev/acpica/tbinstal.c optional acpi |
contrib/dev/acpica/tbrsdt.c optional acpi |
contrib/dev/acpica/tbutils.c optional acpi |
contrib/dev/acpica/tbxface.c optional acpi |
contrib/dev/acpica/tbxfroot.c optional acpi |
contrib/dev/acpica/utalloc.c optional acpi |
contrib/dev/acpica/utclib.c optional acpi |
contrib/dev/acpica/utcopy.c optional acpi |
contrib/dev/acpica/utdebug.c optional acpi |
contrib/dev/acpica/utdelete.c optional acpi |
contrib/dev/acpica/uteval.c optional acpi |
contrib/dev/acpica/utglobal.c optional acpi |
contrib/dev/acpica/utinit.c optional acpi |
contrib/dev/acpica/utmath.c optional acpi |
contrib/dev/acpica/utmisc.c optional acpi |
contrib/dev/acpica/utobject.c optional acpi |
contrib/dev/acpica/utxface.c optional acpi |
contrib/dev/ath/freebsd/ah_osdep.c optional ath_hal |
contrib/ipfilter/netinet/fil.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_auth.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_fil_freebsd.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_frag.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_log.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_nat.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_proxy.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_state.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_lookup.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_pool.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_htable.c optional ipfilter inet |
contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet |
contrib/ipfilter/netinet/mlfk_ipl.c optional ipfilter inet |
contrib/ngatm/netnatm/api/cc_conn.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/cc_data.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/cc_dump.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/cc_port.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/cc_sig.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/cc_user.c optional ngatm_ccatm |
contrib/ngatm/netnatm/api/unisap.c optional ngatm_ccatm |
contrib/ngatm/netnatm/misc/straddr.c optional ngatm_atmbase |
contrib/ngatm/netnatm/misc/unimsg_common.c optional ngatm_atmbase |
contrib/ngatm/netnatm/msg/traffic.c optional ngatm_atmbase |
contrib/ngatm/netnatm/msg/uni_ie.c optional ngatm_atmbase |
contrib/ngatm/netnatm/msg/uni_msg.c optional ngatm_atmbase |
contrib/ngatm/netnatm/saal/saal_sscfu.c optional ngatm_sscfu |
contrib/ngatm/netnatm/saal/saal_sscop.c optional ngatm_sscop |
contrib/ngatm/netnatm/sig/sig_call.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_coord.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_party.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_print.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_reset.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_uni.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_unimsgcpy.c optional ngatm_uni |
contrib/ngatm/netnatm/sig/sig_verify.c optional ngatm_uni |
contrib/pf/net/if_pflog.c optional pflog |
contrib/pf/net/if_pfsync.c optional pfsync |
contrib/pf/net/pf.c optional pf |
contrib/pf/net/pf_if.c optional pf |
contrib/pf/net/pf_subr.c optional pf |
contrib/pf/net/pf_ioctl.c optional pf |
contrib/pf/net/pf_norm.c optional pf |
contrib/pf/net/pf_table.c optional pf |
contrib/pf/net/pf_osfp.c optional pf |
contrib/pf/netinet/in4_cksum.c optional pf inet |
crypto/blowfish/bf_ecb.c optional ipsec ipsec_esp |
crypto/blowfish/bf_skey.c optional crypto |
crypto/blowfish/bf_skey.c optional ipsec ipsec_esp |
crypto/des/des_ecb.c optional crypto |
crypto/des/des_ecb.c optional ipsec ipsec_esp |
crypto/des/des_ecb.c optional netsmbcrypto |
crypto/des/des_setkey.c optional crypto |
crypto/des/des_setkey.c optional ipsec ipsec_esp |
crypto/des/des_setkey.c optional netsmbcrypto |
crypto/rc4/rc4.c optional netgraph_mppc_encryption |
crypto/rijndael/rijndael-alg-fst.c optional crypto |
crypto/rijndael/rijndael-alg-fst.c optional geom_bde |
crypto/rijndael/rijndael-alg-fst.c optional ipsec |
crypto/rijndael/rijndael-alg-fst.c optional random |
crypto/rijndael/rijndael-alg-fst.c optional wlan_ccmp |
crypto/rijndael/rijndael-api-fst.c optional geom_bde |
crypto/rijndael/rijndael-api-fst.c optional random |
crypto/rijndael/rijndael-api.c optional crypto |
crypto/rijndael/rijndael-api.c optional ipsec |
crypto/rijndael/rijndael-api.c optional wlan_ccmp |
crypto/sha1.c optional carp |
crypto/sha1.c optional netgraph_mppc_encryption |
crypto/sha1.c optional crypto |
crypto/sha1.c optional ipsec |
crypto/sha2/sha2.c optional crypto |
crypto/sha2/sha2.c optional geom_bde |
crypto/sha2/sha2.c optional ipsec |
crypto/sha2/sha2.c optional random |
ddb/db_access.c optional ddb |
ddb/db_break.c optional ddb |
ddb/db_command.c optional ddb |
ddb/db_examine.c optional ddb |
ddb/db_expr.c optional ddb |
ddb/db_input.c optional ddb |
ddb/db_lex.c optional ddb |
ddb/db_main.c optional ddb |
ddb/db_output.c optional ddb |
ddb/db_print.c optional ddb |
ddb/db_ps.c optional ddb |
ddb/db_run.c optional ddb |
ddb/db_sym.c optional ddb |
ddb/db_thread.c optional ddb |
ddb/db_variables.c optional ddb |
ddb/db_watch.c optional ddb |
ddb/db_write_cmd.c optional ddb |
#dev/dpt/dpt_control.c optional dpt |
dev/aac/aac.c optional aac |
dev/aac/aac_cam.c optional aacp aac |
dev/aac/aac_debug.c optional aac |
dev/aac/aac_disk.c optional aac |
dev/aac/aac_linux.c optional aac compat_linux |
dev/aac/aac_pci.c optional aac pci |
dev/acpi_support/acpi_asus.c optional acpi_asus acpi |
dev/acpi_support/acpi_fujitsu.c optional acpi_fujitsu acpi |
dev/acpi_support/acpi_ibm.c optional acpi_ibm acpi |
dev/acpi_support/acpi_panasonic.c optional acpi_panasonic acpi |
dev/acpi_support/acpi_sony.c optional acpi_sony acpi |
dev/acpi_support/acpi_toshiba.c optional acpi_toshiba acpi |
dev/acpica/Osd/OsdDebug.c optional acpi |
dev/acpica/Osd/OsdHardware.c optional acpi |
dev/acpica/Osd/OsdInterrupt.c optional acpi |
dev/acpica/Osd/OsdMemory.c optional acpi |
dev/acpica/Osd/OsdSchedule.c optional acpi |
dev/acpica/Osd/OsdStream.c optional acpi |
dev/acpica/Osd/OsdSynch.c optional acpi |
dev/acpica/Osd/OsdTable.c optional acpi |
dev/acpica/acpi.c optional acpi |
dev/acpica/acpi_acad.c optional acpi |
dev/acpica/acpi_battery.c optional acpi |
dev/acpica/acpi_button.c optional acpi |
dev/acpica/acpi_cmbat.c optional acpi |
dev/acpica/acpi_cpu.c optional acpi |
dev/acpica/acpi_ec.c optional acpi |
dev/acpica/acpi_isab.c optional acpi isa |
dev/acpica/acpi_lid.c optional acpi |
dev/acpica/acpi_package.c optional acpi |
dev/acpica/acpi_pci.c optional acpi pci |
dev/acpica/acpi_pci_link.c optional acpi pci |
dev/acpica/acpi_pcib.c optional acpi pci |
dev/acpica/acpi_pcib_acpi.c optional acpi pci |
dev/acpica/acpi_pcib_pci.c optional acpi pci |
dev/acpica/acpi_perf.c optional acpi |
dev/acpica/acpi_powerres.c optional acpi |
dev/acpica/acpi_quirk.c optional acpi |
dev/acpica/acpi_resource.c optional acpi |
dev/acpica/acpi_thermal.c optional acpi |
dev/acpica/acpi_throttle.c optional acpi |
dev/acpica/acpi_timer.c optional acpi |
dev/acpica/acpi_video.c optional acpi_video acpi |
dev/adlink/adlink.c optional adlink |
dev/advansys/adv_eisa.c optional adv eisa |
dev/advansys/adv_pci.c optional adv pci |
dev/advansys/advansys.c optional adv |
dev/advansys/advlib.c optional adv |
dev/advansys/advmcode.c optional adv |
dev/advansys/adw_pci.c optional adw pci |
dev/advansys/adwcam.c optional adw |
dev/advansys/adwlib.c optional adw |
dev/advansys/adwmcode.c optional adw |
dev/aha/aha.c optional aha |
dev/aha/aha_isa.c optional aha isa |
dev/aha/aha_mca.c optional aha mca |
dev/ahb/ahb.c optional ahb eisa |
dev/aic/aic.c optional aic |
dev/aic/aic_pccard.c optional aic pccard |
dev/aic7xxx/ahc_eisa.c optional ahc eisa |
dev/aic7xxx/ahc_isa.c optional ahc isa |
dev/aic7xxx/ahc_pci.c optional ahc pci |
dev/aic7xxx/ahd_pci.c optional ahd pci |
dev/aic7xxx/aic7770.c optional ahc |
dev/aic7xxx/aic79xx.c optional ahd pci |
dev/aic7xxx/aic79xx_osm.c optional ahd pci |
dev/aic7xxx/aic79xx_pci.c optional ahd pci |
dev/aic7xxx/aic7xxx.c optional ahc |
dev/aic7xxx/aic7xxx_93cx6.c optional ahc |
dev/aic7xxx/aic7xxx_osm.c optional ahc |
dev/aic7xxx/aic7xxx_pci.c optional ahc pci |
dev/amd/amd.c optional amd |
dev/amr/amr.c optional amr |
dev/amr/amr_cam.c optional amr |
dev/amr/amr_disk.c optional amr |
dev/amr/amr_pci.c optional amr pci |
dev/an/if_an.c optional an |
dev/an/if_an_isa.c optional an isa |
dev/an/if_an_pccard.c optional an pccard |
dev/an/if_an_pci.c optional an pci |
dev/asr/asr.c optional asr pci |
dev/ata/ata_if.m optional ata |
dev/ata/ata-all.c optional ata |
dev/ata/ata-card.c optional ata pccard |
dev/ata/ata-cbus.c optional ata pc98 |
dev/ata/ata-chipset.c optional ata pci |
dev/ata/ata-disk.c optional atadisk |
dev/ata/ata-dma.c optional ata pci |
dev/ata/ata-isa.c optional ata isa |
dev/ata/ata-lowlevel.c optional ata |
dev/ata/ata-pci.c optional ata pci |
dev/ata/ata-queue.c optional ata |
dev/ata/ata-raid.c optional ataraid |
dev/ata/atapi-cam.c optional atapicam |
dev/ata/atapi-cd.c optional atapicd |
dev/ata/atapi-fd.c optional atapifd |
dev/ata/atapi-tape.c optional atapist |
dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr |
dev/ath/ath_rate/onoe/onoe.c optional ath_rate_onoe |
dev/ath/ath_rate/sample/sample.c optional ath_rate_sample |
dev/ath/if_ath.c optional ath |
dev/ath/if_ath_pci.c optional ath pci |
dev/awi/am79c930.c optional awi |
dev/awi/awi.c optional awi |
dev/awi/if_awi_pccard.c optional awi pccard |
dev/bfe/if_bfe.c optional bfe |
dev/bge/if_bge.c optional bge |
dev/bktr/bktr_audio.c optional bktr pci |
dev/bktr/bktr_card.c optional bktr pci |
dev/bktr/bktr_core.c optional bktr pci |
dev/bktr/bktr_i2c.c optional bktr pci smbus |
dev/bktr/bktr_os.c optional bktr pci |
dev/bktr/bktr_tuner.c optional bktr pci |
dev/bktr/msp34xx.c optional bktr pci |
dev/buslogic/bt.c optional bt |
dev/buslogic/bt_eisa.c optional bt eisa |
dev/buslogic/bt_isa.c optional bt isa |
dev/buslogic/bt_mca.c optional bt mca |
dev/buslogic/bt_pci.c optional bt pci |
dev/cardbus/cardbus.c optional cardbus |
dev/cardbus/cardbus_cis.c optional cardbus |
dev/ciss/ciss.c optional ciss |
dev/cm/smc90cx6.c optional cm |
dev/cnw/if_cnw.c optional cnw pccard |
dev/cpufreq/ichss.c optional cpufreq |
dev/cs/if_cs.c optional cs |
dev/cs/if_cs_isa.c optional cs isa |
dev/cs/if_cs_pccard.c optional cs pccard |
dev/cy/cy.c optional cy |
dev/cy/cy_isa.c optional cy isa |
dev/cy/cy_pci.c optional cy pci |
dev/dcons/dcons.c optional dcons |
dev/dcons/dcons_crom.c optional dcons_crom |
dev/dcons/dcons_os.c optional dcons |
dev/digi/CX.c optional digi_CX |
dev/digi/CX_PCI.c optional digi_CX_PCI |
dev/digi/EPCX.c optional digi_EPCX |
dev/digi/EPCX_PCI.c optional digi_EPCX_PCI |
dev/digi/Xe.c optional digi_Xe |
dev/digi/Xem.c optional digi_Xem |
dev/digi/Xr.c optional digi_Xr |
dev/digi/digi.c optional digi |
dev/digi/digi_isa.c optional digi isa |
dev/digi/digi_pci.c optional digi pci |
dev/dpt/dpt_eisa.c optional dpt eisa |
dev/dpt/dpt_pci.c optional dpt pci |
dev/dpt/dpt_scsi.c optional dpt |
dev/drm/ati_pcigart.c optional drm |
dev/drm/drm_agpsupport.c optional drm |
dev/drm/drm_auth.c optional drm |
dev/drm/drm_bufs.c optional drm |
dev/drm/drm_context.c optional drm |
dev/drm/drm_dma.c optional drm |
dev/drm/drm_drawable.c optional drm |
dev/drm/drm_drv.c optional drm |
dev/drm/drm_fops.c optional drm |
dev/drm/drm_ioctl.c optional drm |
dev/drm/drm_irq.c optional drm |
dev/drm/drm_lock.c optional drm |
dev/drm/drm_memory.c optional drm |
dev/drm/drm_pci.c optional drm |
dev/drm/drm_scatter.c optional drm |
dev/drm/drm_sysctl.c optional drm |
dev/drm/drm_vm.c optional drm |
dev/drm/mach64_dma.c optional mach64drm |
dev/drm/mach64_drv.c optional mach64drm |
dev/drm/mach64_irq.c optional mach64drm |
dev/drm/mach64_state.c optional mach64drm |
dev/drm/mga_dma.c optional mgadrm |
dev/drm/mga_drv.c optional mgadrm |
dev/drm/mga_irq.c optional mgadrm |
dev/drm/mga_state.c optional mgadrm \ |
compile-with "${NORMAL_C} -finline-limit=13500" |
dev/drm/mga_warp.c optional mgadrm |
dev/drm/r128_cce.c optional r128drm |
dev/drm/r128_drv.c optional r128drm |
dev/drm/r128_irq.c optional r128drm |
dev/drm/r128_state.c optional r128drm \ |
compile-with "${NORMAL_C} -finline-limit=13500" |
dev/drm/r300_cmdbuf.c optional radeondrm |
dev/drm/radeon_cp.c optional radeondrm |
dev/drm/radeon_drv.c optional radeondrm |
dev/drm/radeon_irq.c optional radeondrm |
dev/drm/radeon_mem.c optional radeondrm |
dev/drm/radeon_state.c optional radeondrm |
dev/drm/sis_drv.c optional sisdrm |
dev/drm/sis_ds.c optional sisdrm |
dev/drm/sis_mm.c optional sisdrm |
dev/drm/tdfx_drv.c optional tdfxdrm |
dev/ed/if_ed.c optional ed |
dev/ed/if_ed_novell.c optional ed |
dev/ed/if_ed_pccard.c optional ed pccard |
dev/ed/if_ed_pci.c optional ed pci |
dev/ed/if_ed_rtl80x9.c optional ed |
dev/eisa/eisa_if.m standard |
dev/eisa/eisaconf.c optional eisa |
dev/em/if_em.c optional em |
dev/em/if_em_hw.c optional em |
dev/en/if_en_pci.c optional en pci |
dev/en/midway.c optional en |
dev/ep/if_ep.c optional ep |
dev/ep/if_ep_eisa.c optional ep eisa |
dev/ep/if_ep_isa.c optional ep isa |
dev/ep/if_ep_mca.c optional ep mca |
dev/ep/if_ep_pccard.c optional ep pccard |
dev/esp/ncr53c9x.c optional esp |
dev/ex/if_ex.c optional ex |
dev/ex/if_ex_isa.c optional ex isa |
#dev/ex/if_ex_pccard.c optional ex pccard |
dev/exca/exca.c optional cbb |
dev/fatm/if_fatm.c optional fatm pci |
dev/fe/if_fe.c optional fe |
dev/fe/if_fe_pccard.c optional fe pccard |
dev/firewire/firewire.c optional firewire |
dev/firewire/fwcrom.c optional firewire |
dev/firewire/fwdev.c optional firewire |
dev/firewire/fwdma.c optional firewire |
dev/firewire/fwmem.c optional firewire |
dev/firewire/fwohci.c optional firewire |
dev/firewire/fwohci_pci.c optional firewire pci |
dev/firewire/if_fwe.c optional fwe |
dev/firewire/if_fwip.c optional fwip |
dev/firewire/sbp.c optional sbp |
dev/firewire/sbp_targ.c optional sbp_targ |
dev/fxp/if_fxp.c optional fxp |
dev/gem/if_gem.c optional gem |
dev/gem/if_gem_pci.c optional gem pci |
dev/harp/if_harp.c optional harp pci |
dev/hatm/if_hatm.c optional hatm pci |
dev/hatm/if_hatm_intr.c optional hatm pci |
dev/hatm/if_hatm_ioctl.c optional hatm pci |
dev/hatm/if_hatm_rx.c optional hatm pci |
dev/hatm/if_hatm_tx.c optional hatm pci |
dev/hfa/fore_buffer.c optional hfa |
dev/hfa/fore_command.c optional hfa |
dev/hfa/fore_globals.c optional hfa |
dev/hfa/fore_if.c optional hfa |
dev/hfa/fore_init.c optional hfa |
dev/hfa/fore_intr.c optional hfa |
dev/hfa/fore_output.c optional hfa |
dev/hfa/fore_receive.c optional hfa |
dev/hfa/fore_stats.c optional hfa |
dev/hfa/fore_timer.c optional hfa |
dev/hfa/fore_transmit.c optional hfa |
dev/hfa/fore_vcm.c optional hfa |
#dev/hfa/hfa_eisa.c optional hfa eisa |
dev/hfa/hfa_freebsd.c optional hfa |
dev/hfa/hfa_pci.c optional hfa pci |
#dev/hfa/hfa_sbus.c optional hfa sbus |
dev/hifn/hifn7751.c optional hifn |
dev/hme/if_hme.c optional hme |
dev/hme/if_hme_pci.c optional hme pci |
dev/hme/if_hme_sbus.c optional hme sbus |
dev/hwpmc/hwpmc_logging.c optional hwpmc |
dev/hwpmc/hwpmc_mod.c optional hwpmc |
dev/ichsmb/ichsmb.c optional ichsmb |
dev/ichsmb/ichsmb_pci.c optional ichsmb pci |
dev/ida/ida.c optional ida |
dev/ida/ida_disk.c optional ida |
dev/ida/ida_eisa.c optional ida eisa |
dev/ida/ida_pci.c optional ida pci |
dev/ie/if_ie.c optional ie isa nowerror |
dev/ie/if_ie_isa.c optional ie isa |
dev/ieee488/ibfoo.c optional pcii |
dev/ieee488/pcii.c optional pcii |
dev/ieee488/upd7210.c optional pcii |
dev/iicbus/if_ic.c optional ic |
dev/iicbus/iic.c optional iic |
dev/iicbus/iicbb.c optional iicbb |
dev/iicbus/iicbb_if.m optional iicbb |
dev/iicbus/iicbus.c optional iicbus |
dev/iicbus/iicbus_if.m optional iicbus |
dev/iicbus/iiconf.c optional iicbus |
dev/iicbus/iicsmb.c optional iicsmb \ |
dependency "iicbus_if.h" |
dev/iir/iir.c optional iir |
dev/iir/iir_ctrl.c optional iir |
dev/iir/iir_pci.c optional iir pci |
dev/ips/ips.c optional ips |
dev/ips/ips_commands.c optional ips |
dev/ips/ips_disk.c optional ips |
dev/ips/ips_ioctl.c optional ips |
dev/ips/ips_pci.c optional ips pci |
dev/ipw/if_ipw.c optional ipw |
dev/isp/isp.c optional isp |
dev/isp/isp_freebsd.c optional isp |
dev/isp/isp_pci.c optional isp pci |
dev/isp/isp_sbus.c optional isp sbus |
dev/isp/isp_target.c optional isp |
dev/ispfw/ispfw.c optional ispfw |
dev/iwi/if_iwi.c optional iwi |
dev/ixgb/if_ixgb.c optional ixgb |
dev/ixgb/ixgb_ee.c optional ixgb |
dev/ixgb/ixgb_hw.c optional ixgb |
dev/joy/joy.c optional joy |
dev/joy/joy_isa.c optional joy isa |
dev/joy/joy_pccard.c optional joy pccard |
dev/kbdmux/kbdmux.c optional kbdmux |
dev/led/led.c standard |
dev/lge/if_lge.c optional lge |
dev/lnc/if_lnc.c optional lnc |
dev/lnc/if_lnc_pci.c optional lnc pci |
dev/mc146818/mc146818.c optional mc146818 |
dev/mca/mca_bus.c optional mca |
dev/mcd/mcd.c optional mcd isa nowerror |
dev/mcd/mcd_isa.c optional mcd isa nowerror |
dev/md/md.c optional md |
dev/mem/memdev.c optional mem |
dev/mii/acphy.c optional miibus |
dev/mii/amphy.c optional miibus |
dev/mii/bmtphy.c optional miibus |
dev/mii/brgphy.c optional miibus |
dev/mii/ciphy.c optional miibus |
dev/mii/dcphy.c optional miibus pci |
dev/mii/e1000phy.c optional miibus |
dev/mii/exphy.c optional miibus |
dev/mii/inphy.c optional miibus |
dev/mii/lxtphy.c optional miibus |
dev/mii/mii.c optional miibus |
dev/mii/mii_physubr.c optional miibus |
dev/mii/miibus_if.m optional miibus |
dev/mii/mlphy.c optional miibus |
dev/mii/nsgphy.c optional miibus |
dev/mii/nsphy.c optional miibus |
dev/mii/pnaphy.c optional miibus |
dev/mii/pnphy.c optional miibus |
dev/mii/qsphy.c optional miibus |
dev/mii/rgephy.c optional miibus |
dev/mii/rlphy.c optional miibus |
dev/mii/ruephy.c optional miibus |
dev/mii/tdkphy.c optional miibus |
dev/mii/tlphy.c optional miibus |
dev/mii/ukphy.c optional miibus |
dev/mii/ukphy_subr.c optional miibus |
dev/mii/xmphy.c optional miibus |
dev/mk48txx/mk48txx.c optional mk48txx |
dev/mlx/mlx.c optional mlx |
dev/mlx/mlx_disk.c optional mlx |
dev/mlx/mlx_pci.c optional mlx pci |
dev/mly/mly.c optional mly |
dev/mpt/mpt.c optional mpt |
dev/mpt/mpt_cam.c optional mpt |
dev/mpt/mpt_debug.c optional mpt |
dev/mpt/mpt_pci.c optional mpt pci |
dev/mpt/mpt_raid.c optional mpt |
dev/my/if_my.c optional my |
dev/ncv/ncr53c500.c optional ncv |
dev/ncv/ncr53c500_pccard.c optional ncv pccard |
dev/nge/if_nge.c optional nge |
dev/nmdm/nmdm.c optional nmdm |
dev/nsp/nsp.c optional nsp |
dev/nsp/nsp_pccard.c optional nsp pccard |
dev/null/null.c standard |
dev/patm/if_patm.c optional patm pci |
dev/patm/if_patm_attach.c optional patm pci |
dev/patm/if_patm_intr.c optional patm pci |
dev/patm/if_patm_ioctl.c optional patm pci |
dev/patm/if_patm_rtables.c optional patm pci |
dev/patm/if_patm_rx.c optional patm pci |
dev/patm/if_patm_tx.c optional patm pci |
dev/pbio/pbio.c optional pbio isa |
dev/pccard/card_if.m standard |
dev/pccard/pccard.c optional pccard |
dev/pccard/pccard_cis.c optional pccard |
dev/pccard/pccard_cis_quirks.c optional pccard |
dev/pccard/pccard_device.c optional pccard |
dev/pccard/power_if.m standard |
dev/pccbb/pccbb.c optional cbb |
dev/pccbb/pccbb_isa.c optional cbb isa |
dev/pccbb/pccbb_pci.c optional cbb pci |
dev/pci/eisa_pci.c optional pci eisa |
dev/pci/fixup_pci.c optional pci |
dev/pci/ignore_pci.c optional pci |
dev/pci/isa_pci.c optional pci isa |
dev/pci/pci.c optional pci |
dev/pci/pci_if.m standard |
dev/pci/pci_pci.c optional pci |
dev/pci/pci_user.c optional pci |
dev/pci/pcib_if.m standard |
dev/pdq/if_fea.c optional fea eisa |
dev/pdq/if_fpa.c optional fpa pci |
dev/pdq/pdq.c optional fea eisa nowerror |
dev/pdq/pdq.c optional fpa pci nowerror |
dev/pdq/pdq_ifsubr.c optional fea eisa nowerror |
dev/pdq/pdq_ifsubr.c optional fpa pci nowerror |
dev/ppbus/if_plip.c optional plip |
dev/ppbus/immio.c optional vpo |
dev/ppbus/lpbb.c optional lpbb |
dev/ppbus/lpt.c optional lpt |
dev/ppbus/pcfclock.c optional pcfclock |
dev/ppbus/ppb_1284.c optional ppbus |
dev/ppbus/ppb_base.c optional ppbus |
dev/ppbus/ppb_msq.c optional ppbus |
dev/ppbus/ppbconf.c optional ppbus |
dev/ppbus/ppbus_if.m optional ppbus |
dev/ppbus/ppi.c optional ppi |
dev/ppbus/pps.c optional pps |
dev/ppbus/vpo.c optional vpo |
dev/ppbus/vpoio.c optional vpo |
dev/pst/pst-iop.c optional pst |
dev/pst/pst-pci.c optional pst pci |
dev/pst/pst-raid.c optional pst |
dev/puc/puc.c optional puc |
dev/puc/puc_ebus.c optional puc ebus |
dev/puc/puc_pccard.c optional puc pccard |
dev/puc/puc_pci.c optional puc pci |
dev/puc/puc_sbus.c optional puc fhc |
dev/puc/puc_sbus.c optional puc sbus |
dev/puc/pucdata.c optional puc pci |
dev/ral/if_ral.c optional ral |
dev/ral/if_ralrate.c optional ral |
dev/ral/if_ral_pccard.c optional ral pccard |
dev/ral/if_ral_pci.c optional ral pci |
dev/random/harvest.c standard |
dev/random/hash.c optional random |
dev/random/probe.c optional random |
dev/random/randomdev.c optional random |
dev/random/randomdev_soft.c optional random |
dev/random/yarrow.c optional random |
dev/ray/if_ray.c optional ray pccard |
dev/rc/rc.c optional rc |
dev/re/if_re.c optional re |
dev/rndtest/rndtest.c optional rndtest |
dev/rp/rp.c optional rp |
dev/rp/rp_isa.c optional rp isa |
dev/rp/rp_pci.c optional rp pci |
dev/sab/sab.c optional sab ebus |
dev/safe/safe.c optional safe |
dev/sbsh/if_sbsh.c optional sbsh |
dev/scd/scd.c optional scd isa |
dev/scd/scd_isa.c optional scd isa |
dev/si/si.c optional si |
dev/si/si2_z280.c optional si |
dev/si/si3_t225.c optional si |
dev/si/si_eisa.c optional si eisa |
dev/si/si_isa.c optional si isa |
dev/si/si_pci.c optional si pci |
dev/sio/sio_pccard.c optional sio pccard |
dev/sio/sio_pci.c optional sio pci |
dev/sio/sio_puc.c optional sio puc pci |
dev/smbus/smb.c optional smb |
dev/smbus/smbconf.c optional smbus |
dev/smbus/smbus.c optional smbus |
dev/smbus/smbus_if.m optional smbus |
dev/sn/if_sn.c optional sn |
dev/sn/if_sn_isa.c optional sn isa |
dev/sn/if_sn_pccard.c optional sn pccard |
dev/snp/snp.c optional snp |
dev/sound/isa/ad1816.c optional snd_ad1816 isa |
dev/sound/isa/es1888.c optional snd_ess isa |
dev/sound/isa/ess.c optional snd_ess isa |
dev/sound/isa/gusc.c optional snd_gusc isa |
dev/sound/isa/mss.c optional snd_mss isa |
dev/sound/isa/sb16.c optional snd_sb16 isa |
dev/sound/isa/sb8.c optional snd_sb8 isa |
dev/sound/isa/sbc.c optional snd_sbc isa |
dev/sound/isa/sndbuf_dma.c optional sound isa |
dev/sound/pci/als4000.c optional snd_als4000 pci |
#dev/sound/pci/au88x0.c optional snd_au88x0 pci |
dev/sound/pci/cmi.c optional snd_cmi pci |
dev/sound/pci/cs4281.c optional snd_cs4281 pci |
dev/sound/pci/csa.c optional snd_csa pci |
dev/sound/pci/csapcm.c optional snd_csa pci |
dev/sound/pci/ds1.c optional snd_ds1 pci |
dev/sound/pci/emu10k1.c optional snd_emu10k1 pci \ |
dependency "emu10k1-alsa%diked.h" |
dev/sound/pci/es137x.c optional snd_es137x pci |
dev/sound/pci/fm801.c optional snd_fm801 pci |
dev/sound/pci/ich.c optional snd_ich pci |
dev/sound/pci/maestro.c optional snd_maestro pci |
dev/sound/pci/maestro3.c optional snd_maestro3 pci |
dev/sound/pci/neomagic.c optional snd_neomagic pci |
dev/sound/pci/solo.c optional snd_solo pci |
dev/sound/pci/t4dwave.c optional snd_t4dwave pci |
dev/sound/pci/via8233.c optional snd_via8233 pci |
dev/sound/pci/via82c686.c optional snd_via82c686 pci |
dev/sound/pci/vibes.c optional snd_vibes pci |
#dev/sound/pci/vortex1.c optional snd_vortex1 pci |
dev/sound/pcm/ac97.c optional sound |
dev/sound/pcm/ac97_if.m optional sound |
dev/sound/pcm/ac97_patch.c optional sound |
dev/sound/pcm/buffer.c optional sound |
dev/sound/pcm/channel.c optional sound |
dev/sound/pcm/channel_if.m optional sound |
dev/sound/pcm/dsp.c optional sound |
dev/sound/pcm/fake.c optional sound |
dev/sound/pcm/feeder.c optional sound |
dev/sound/pcm/feeder_fmt.c optional sound |
dev/sound/pcm/feeder_if.m optional sound |
dev/sound/pcm/feeder_rate.c optional sound |
dev/sound/pcm/mixer.c optional sound |
dev/sound/pcm/mixer_if.m optional sound |
dev/sound/pcm/sndstat.c optional sound |
dev/sound/pcm/sound.c optional sound |
dev/sound/pcm/vchan.c optional sound |
#dev/sound/usb/upcm.c optional snd_upcm usb |
dev/sound/usb/uaudio.c optional snd_uaudio usb |
dev/sound/usb/uaudio_pcm.c optional snd_uaudio usb |
dev/sr/if_sr.c optional sr |
dev/sr/if_sr_pci.c optional sr pci |
dev/stg/tmc18c30.c optional stg |
dev/stg/tmc18c30_isa.c optional stg isa |
dev/stg/tmc18c30_pccard.c optional stg pccard |
dev/stg/tmc18c30_pci.c optional stg pci |
dev/stg/tmc18c30_subr.c optional stg |
dev/streams/streams.c optional streams |
dev/sx/sx.c optional sx |
#dev/sx/sx_isa.c optional sx isa |
dev/sx/sx_util.c optional sx |
dev/sx/sx_pci.c optional sx pci |
dev/sym/sym_hipd.c optional sym \ |
dependency "$S/dev/sym/sym_{conf,defs}.h" |
dev/syscons/blank/blank_saver.c optional blank_saver |
dev/syscons/daemon/daemon_saver.c optional daemon_saver |
dev/syscons/dragon/dragon_saver.c optional dragon_saver |
dev/syscons/fade/fade_saver.c optional fade_saver |
dev/syscons/fire/fire_saver.c optional fire_saver |
dev/syscons/green/green_saver.c optional green_saver |
dev/syscons/logo/logo.c optional logo_saver |
dev/syscons/logo/logo_saver.c optional logo_saver |
dev/syscons/rain/rain_saver.c optional rain_saver |
dev/syscons/snake/snake_saver.c optional snake_saver |
dev/syscons/star/star_saver.c optional star_saver |
dev/syscons/warp/warp_saver.c optional warp_saver |
dev/tdfx/tdfx_pci.c optional tdfx pci |
dev/trm/trm.c optional trm |
dev/twa/tw_cl_fwimg.c optional twa |
dev/twa/tw_cl_init.c optional twa |
dev/twa/tw_cl_intr.c optional twa |
dev/twa/tw_cl_io.c optional twa |
dev/twa/tw_cl_misc.c optional twa |
dev/twa/tw_osl_cam.c optional twa |
dev/twa/tw_osl_freebsd.c optional twa |
dev/twe/twe.c optional twe |
dev/twe/twe_freebsd.c optional twe |
dev/tx/if_tx.c optional tx |
dev/txp/if_txp.c optional txp |
dev/uart/uart_bus_acpi.c optional uart acpi |
#dev/uart/uart_bus_cbus.c optional uart cbus |
dev/uart/uart_bus_ebus.c optional uart ebus |
dev/uart/uart_bus_isa.c optional uart isa |
dev/uart/uart_bus_pccard.c optional uart pccard |
dev/uart/uart_bus_pci.c optional uart pci |
dev/uart/uart_bus_puc.c optional uart puc |
dev/uart/uart_core.c optional uart |
dev/uart/uart_dbg.c optional uart gdb |
dev/uart/uart_dev_ns8250.c optional uart |
dev/uart/uart_dev_sab82532.c optional uart |
dev/uart/uart_dev_z8530.c optional uart |
dev/uart/uart_if.m optional uart |
dev/uart/uart_subr.c optional uart |
dev/uart/uart_tty.c optional uart |
dev/ubsec/ubsec.c optional ubsec |
# |
# USB support |
dev/usb/ehci.c optional ehci |
dev/usb/ehci_pci.c optional ehci pci |
dev/usb/hid.c optional usb |
dev/usb/if_aue.c optional aue |
dev/usb/if_axe.c optional axe |
dev/usb/if_cdce.c optional cdce |
dev/usb/if_cue.c optional cue |
dev/usb/if_kue.c optional kue |
dev/usb/if_ural.c optional ural |
dev/usb/if_rue.c optional rue |
dev/usb/if_udav.c optional udav |
dev/usb/ohci.c optional ohci |
dev/usb/ohci_pci.c optional ohci pci |
dev/usb/ubsa.c optional ubsa ucom |
dev/usb/ubser.c optional ubser |
dev/usb/ucom.c optional ucom |
dev/usb/ucycom.c optional ucycom ucom |
dev/usb/udbp.c optional udbp |
dev/usb/ufm.c optional ufm |
dev/usb/uftdi.c optional uftdi ucom |
dev/usb/ugen.c optional ugen |
dev/usb/uhci.c optional uhci |
dev/usb/uhci_pci.c optional uhci pci |
dev/usb/uhid.c optional uhid |
dev/usb/uhub.c optional usb |
dev/usb/ukbd.c optional ukbd |
dev/usb/ulpt.c optional ulpt |
dev/usb/umass.c optional umass |
dev/usb/umct.c optional umct |
dev/usb/umodem.c optional umodem |
dev/usb/ums.c optional ums |
dev/usb/uplcom.c optional uplcom ucom |
dev/usb/urio.c optional urio |
dev/usb/usb.c optional usb |
dev/usb/usb_ethersubr.c optional usb |
dev/usb/usb_if.m optional usb |
dev/usb/usb_mem.c optional usb |
dev/usb/usb_quirks.c optional usb |
dev/usb/usb_subr.c optional usb |
dev/usb/usbdi.c optional usb |
dev/usb/usbdi_util.c optional usb |
dev/usb/uscanner.c optional uscanner |
dev/usb/uvisor.c optional uvisor ucom |
dev/usb/uvscom.c optional uvscom ucom |
dev/utopia/idtphy.c optional utopia |
dev/utopia/suni.c optional utopia |
dev/utopia/utopia.c optional utopia |
dev/vge/if_vge.c optional vge |
dev/vkbd/vkbd.c optional vkbd |
dev/vx/if_vx.c optional vx |
dev/vx/if_vx_eisa.c optional vx eisa |
dev/vx/if_vx_pci.c optional vx pci |
dev/watchdog/watchdog.c standard |
dev/wds/wd7000.c optional wds isa |
dev/wi/if_wi.c optional wi |
dev/wi/if_wi_pccard.c optional wi pccard |
dev/wi/if_wi_pci.c optional wi pci |
dev/wl/if_wl.c optional wl isa |
dev/xe/if_xe.c optional xe |
dev/xe/if_xe_pccard.c optional xe pccard |
dev/zs/zs.c optional zs |
fs/deadfs/dead_vnops.c standard |
fs/devfs/devfs_devs.c standard |
fs/devfs/devfs_rule.c standard |
fs/devfs/devfs_vfsops.c standard |
fs/devfs/devfs_vnops.c standard |
fs/fdescfs/fdesc_vfsops.c optional fdescfs |
fs/fdescfs/fdesc_vnops.c optional fdescfs |
fs/fifofs/fifo_vnops.c standard |
fs/hpfs/hpfs_alsubr.c optional hpfs |
fs/hpfs/hpfs_lookup.c optional hpfs |
fs/hpfs/hpfs_subr.c optional hpfs |
fs/hpfs/hpfs_vfsops.c optional hpfs |
fs/hpfs/hpfs_vnops.c optional hpfs |
fs/msdosfs/msdosfs_conv.c optional msdosfs |
fs/msdosfs/msdosfs_denode.c optional msdosfs |
fs/msdosfs/msdosfs_fat.c optional msdosfs |
fs/msdosfs/msdosfs_fileno.c optional msdosfs_large |
fs/msdosfs/msdosfs_iconv.c optional msdosfs_iconv |
fs/msdosfs/msdosfs_lookup.c optional msdosfs |
fs/msdosfs/msdosfs_vfsops.c optional msdosfs |
fs/msdosfs/msdosfs_vnops.c optional msdosfs |
fs/ntfs/ntfs_compr.c optional ntfs |
fs/ntfs/ntfs_iconv.c optional ntfs_iconv |
fs/ntfs/ntfs_ihash.c optional ntfs |
fs/ntfs/ntfs_subr.c optional ntfs |
fs/ntfs/ntfs_vfsops.c optional ntfs |
fs/ntfs/ntfs_vnops.c optional ntfs |
fs/nullfs/null_subr.c optional nullfs |
fs/nullfs/null_vfsops.c optional nullfs |
fs/nullfs/null_vnops.c optional nullfs |
fs/nwfs/nwfs_io.c optional nwfs |
fs/nwfs/nwfs_ioctl.c optional nwfs |
fs/nwfs/nwfs_node.c optional nwfs |
fs/nwfs/nwfs_subr.c optional nwfs |
fs/nwfs/nwfs_vfsops.c optional nwfs |
fs/nwfs/nwfs_vnops.c optional nwfs |
fs/portalfs/portal_vfsops.c optional portalfs |
fs/portalfs/portal_vnops.c optional portalfs |
fs/procfs/procfs.c optional procfs |
fs/procfs/procfs_ctl.c optional procfs |
fs/procfs/procfs_dbregs.c optional procfs |
fs/procfs/procfs_fpregs.c optional procfs |
fs/procfs/procfs_ioctl.c optional procfs |
fs/procfs/procfs_map.c optional procfs |
fs/procfs/procfs_mem.c optional procfs |
fs/procfs/procfs_note.c optional procfs |
fs/procfs/procfs_regs.c optional procfs |
fs/procfs/procfs_rlimit.c optional procfs |
fs/procfs/procfs_status.c optional procfs |
fs/procfs/procfs_type.c optional procfs |
fs/pseudofs/pseudofs.c optional pseudofs |
fs/pseudofs/pseudofs_fileno.c optional pseudofs |
fs/pseudofs/pseudofs_vncache.c optional pseudofs |
fs/pseudofs/pseudofs_vnops.c optional pseudofs |
fs/smbfs/smbfs_io.c optional smbfs |
fs/smbfs/smbfs_node.c optional smbfs |
fs/smbfs/smbfs_smb.c optional smbfs |
fs/smbfs/smbfs_subr.c optional smbfs |
fs/smbfs/smbfs_vfsops.c optional smbfs |
fs/smbfs/smbfs_vnops.c optional smbfs |
fs/udf/osta.c optional udf |
fs/udf/udf_iconv.c optional udf_iconv |
fs/udf/udf_vfsops.c optional udf |
fs/udf/udf_vnops.c optional udf |
fs/umapfs/umap_subr.c optional umapfs |
fs/umapfs/umap_vfsops.c optional umapfs |
fs/umapfs/umap_vnops.c optional umapfs |
fs/unionfs/union_subr.c optional unionfs |
fs/unionfs/union_vfsops.c optional unionfs |
fs/unionfs/union_vnops.c optional unionfs |
gdb/gdb_main.c optional gdb |
gdb/gdb_packet.c optional gdb |
geom/bde/g_bde.c optional geom_bde |
geom/bde/g_bde_crypt.c optional geom_bde |
geom/bde/g_bde_lock.c optional geom_bde |
geom/bde/g_bde_work.c optional geom_bde |
geom/concat/g_concat.c optional geom_concat |
geom/eli/g_eli.c optional geom_eli |
geom/eli/g_eli_crypto.c optional geom_eli |
geom/eli/g_eli_ctl.c optional geom_eli |
geom/eli/g_eli_key.c optional geom_eli |
geom/eli/pkcs5v2.c optional geom_eli |
geom/gate/g_gate.c optional geom_gate |
geom/geom_aes.c optional geom_aes |
geom/geom_apple.c optional geom_apple |
geom/geom_bsd.c optional geom_bsd |
geom/geom_bsd_enc.c optional geom_bsd |
geom/geom_ccd.c optional ccd |
geom/geom_ccd.c optional geom_ccd |
geom/geom_ctl.c standard |
geom/geom_dev.c standard |
geom/geom_disk.c standard |
geom/geom_dump.c standard |
geom/geom_event.c standard |
geom/geom_fox.c optional geom_fox |
geom/geom_gpt.c optional geom_gpt |
geom/geom_io.c standard |
geom/geom_kern.c standard |
geom/geom_mbr.c optional geom_mbr |
geom/geom_mbr_enc.c optional geom_mbr |
geom/geom_pc98.c optional geom_pc98 |
geom/geom_pc98_enc.c optional geom_pc98 |
geom/geom_slice.c standard |
geom/geom_subr.c standard |
geom/geom_sunlabel.c optional geom_sunlabel |
geom/geom_sunlabel_enc.c optional geom_sunlabel |
geom/geom_vfs.c standard |
geom/geom_vol_ffs.c optional geom_vol |
geom/label/g_label.c optional geom_label |
geom/label/g_label_ext2fs.c optional geom_label |
geom/label/g_label_iso9660.c optional geom_label |
geom/label/g_label_msdosfs.c optional geom_label |
geom/label/g_label_reiserfs.c optional geom_label |
geom/label/g_label_ufs.c optional geom_label |
geom/mirror/g_mirror.c optional geom_mirror |
geom/mirror/g_mirror_ctl.c optional geom_mirror |
geom/nop/g_nop.c optional geom_nop |
geom/raid3/g_raid3.c optional geom_raid3 |
geom/raid3/g_raid3_ctl.c optional geom_raid3 |
geom/shsec/g_shsec.c optional geom_shsec |
geom/stripe/g_stripe.c optional geom_stripe |
geom/uzip/g_uzip.c optional geom_uzip |
geom/zero/g_zero.c optional geom_zero |
gnu/fs/ext2fs/ext2_alloc.c optional ext2fs \ |
warning "kernel contains GPL contaminated ext2fs filesystem" |
gnu/fs/ext2fs/ext2_balloc.c optional ext2fs |
gnu/fs/ext2fs/ext2_bmap.c optional ext2fs |
gnu/fs/ext2fs/ext2_inode.c optional ext2fs |
gnu/fs/ext2fs/ext2_inode_cnv.c optional ext2fs |
gnu/fs/ext2fs/ext2_linux_balloc.c optional ext2fs |
gnu/fs/ext2fs/ext2_linux_ialloc.c optional ext2fs |
gnu/fs/ext2fs/ext2_lookup.c optional ext2fs |
gnu/fs/ext2fs/ext2_subr.c optional ext2fs |
gnu/fs/ext2fs/ext2_vfsops.c optional ext2fs |
gnu/fs/ext2fs/ext2_vnops.c optional ext2fs |
gnu/fs/reiserfs/reiserfs_hashes.c optional reiserfs \ |
warning "kernel contains GPL contaminated ReiserFS filesystem" |
gnu/fs/reiserfs/reiserfs_inode.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_item_ops.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_namei.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_prints.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_stree.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_vfsops.c optional reiserfs |
gnu/fs/reiserfs/reiserfs_vnops.c optional reiserfs |
# |
# isdn4bsd device drivers |
# |
i4b/driver/i4b_trace.c optional i4btrc |
i4b/driver/i4b_rbch.c optional i4brbch |
i4b/driver/i4b_tel.c optional i4btel |
i4b/driver/i4b_ipr.c optional i4bipr |
net/slcompress.c optional i4bipr |
i4b/driver/i4b_ctl.c optional i4bctl |
i4b/driver/i4b_ing.c optional i4bing |
i4b/driver/i4b_isppp.c optional i4bisppp |
net/slcompress.c optional i4bisppp |
# |
# isdn4bsd CAPI driver |
# |
i4b/capi/capi_l4if.c optional i4bcapi |
i4b/capi/capi_llif.c optional i4bcapi |
i4b/capi/capi_msgs.c optional i4bcapi |
# |
# isdn4bsd AVM B1/T1 CAPI driver |
# |
i4b/capi/iavc/iavc_pci.c optional iavc i4bcapi pci |
i4b/capi/iavc/iavc_isa.c optional iavc i4bcapi isa |
i4b/capi/iavc/iavc_lli.c optional iavc i4bcapi |
i4b/capi/iavc/iavc_card.c optional iavc i4bcapi |
# |
# isdn4bsd support |
# |
i4b/layer2/i4b_mbuf.c optional i4btrc |
# |
# isdn4bsd Q.921 handler |
# |
i4b/layer2/i4b_l2.c optional i4bq921 |
i4b/layer2/i4b_l2fsm.c optional i4bq921 |
i4b/layer2/i4b_uframe.c optional i4bq921 |
i4b/layer2/i4b_tei.c optional i4bq921 |
i4b/layer2/i4b_sframe.c optional i4bq921 |
i4b/layer2/i4b_iframe.c optional i4bq921 |
i4b/layer2/i4b_l2timer.c optional i4bq921 |
i4b/layer2/i4b_util.c optional i4bq921 |
i4b/layer2/i4b_lme.c optional i4bq921 |
# |
# isdn4bsd Q.931 handler |
# |
i4b/layer3/i4b_q931.c optional i4bq931 |
i4b/layer3/i4b_l3fsm.c optional i4bq931 |
i4b/layer3/i4b_l3timer.c optional i4bq931 |
i4b/layer3/i4b_l2if.c optional i4bq931 |
i4b/layer3/i4b_l4if.c optional i4bq931 |
i4b/layer3/i4b_q932fac.c optional i4bq931 |
# |
# isdn4bsd control device driver, interface to isdnd |
# |
i4b/layer4/i4b_i4bdrv.c optional i4b |
i4b/layer4/i4b_l4.c optional i4b |
i4b/layer4/i4b_l4mgmt.c optional i4b |
i4b/layer4/i4b_l4timer.c optional i4b |
# |
isa/isa_if.m standard |
isa/isa_common.c optional isa |
isa/isahint.c optional isa |
isa/orm.c optional isa |
isa/pnp.c optional isa |
isa/pnpparse.c optional isa |
isofs/cd9660/cd9660_bmap.c optional cd9660 |
isofs/cd9660/cd9660_lookup.c optional cd9660 |
isofs/cd9660/cd9660_node.c optional cd9660 |
isofs/cd9660/cd9660_rrip.c optional cd9660 |
isofs/cd9660/cd9660_util.c optional cd9660 |
isofs/cd9660/cd9660_vfsops.c optional cd9660 |
isofs/cd9660/cd9660_vnops.c optional cd9660 |
isofs/cd9660/cd9660_iconv.c optional cd9660_iconv |
kern/bus_if.m standard |
kern/clock_if.m optional genclock |
kern/cpufreq_if.m standard |
kern/device_if.m standard |
kern/imgact_elf.c standard |
kern/imgact_shell.c standard |
kern/inflate.c optional gzip |
kern/init_main.c standard |
kern/init_sysent.c standard |
kern/kern_acct.c standard |
kern/kern_acl.c standard |
kern/kern_alq.c optional alq |
kern/kern_clock.c standard |
kern/kern_condvar.c standard |
kern/kern_conf.c standard |
kern/kern_cpu.c standard |
kern/kern_context.c standard |
kern/kern_descrip.c standard |
kern/kern_environment.c standard |
kern/kern_event.c standard |
kern/kern_exec.c standard |
kern/kern_exit.c standard |
kern/kern_fork.c standard |
kern/kern_idle.c standard |
kern/kern_intr.c standard |
kern/kern_jail.c standard |
kern/kern_kse.c standard |
kern/kern_kthread.c standard |
kern/kern_ktr.c optional ktr |
kern/kern_ktrace.c standard |
kern/kern_linker.c standard |
kern/kern_lock.c standard |
kern/kern_lockf.c standard |
kern/kern_mac.c standard |
kern/kern_malloc.c standard |
kern/kern_mbuf.c standard |
kern/kern_mib.c standard |
kern/kern_module.c standard |
kern/kern_mtxpool.c standard |
kern/kern_mutex.c standard |
kern/kern_ntptime.c standard |
kern/kern_physio.c standard |
kern/kern_pmc.c standard |
kern/kern_poll.c optional device_polling |
kern/kern_proc.c standard |
kern/kern_prot.c standard |
kern/kern_resource.c standard |
kern/kern_sema.c standard |
kern/kern_shutdown.c standard |
kern/kern_sig.c standard |
kern/kern_subr.c standard |
kern/kern_sx.c standard |
kern/kern_synch.c standard |
kern/kern_syscalls.c standard |
kern/kern_sysctl.c standard |
kern/kern_tc.c standard |
kern/kern_thr.c standard |
kern/kern_thread.c standard |
kern/kern_time.c standard |
kern/kern_timeout.c standard |
kern/kern_umtx.c standard |
kern/kern_uuid.c standard |
kern/kern_xxx.c standard |
kern/link_elf.c standard |
kern/linker_if.m standard |
kern/md4c.c optional netsmb |
kern/md5c.c standard |
kern/sched_4bsd.c optional sched_4bsd |
kern/sched_ule.c optional sched_ule |
kern/subr_autoconf.c standard |
kern/subr_blist.c standard |
kern/subr_bus.c standard |
kern/subr_clock.c optional genclock |
kern/subr_devstat.c standard |
kern/subr_disk.c standard |
kern/subr_eventhandler.c standard |
kern/subr_hints.c standard |
kern/subr_kdb.c standard |
kern/subr_kobj.c standard |
kern/subr_log.c standard |
kern/subr_mbpool.c optional libmbpool |
kern/subr_mchain.c optional libmchain |
kern/subr_module.c standard |
kern/subr_msgbuf.c standard |
kern/subr_param.c standard |
kern/subr_pcpu.c standard |
kern/subr_power.c standard |
kern/subr_prf.c standard |
kern/subr_prof.c standard |
kern/subr_rman.c standard |
kern/subr_sbuf.c standard |
kern/subr_scanf.c standard |
kern/subr_sleepqueue.c standard |
kern/subr_smp.c standard |
kern/subr_taskqueue.c standard |
kern/subr_trap.c standard |
kern/subr_turnstile.c standard |
kern/subr_unit.c standard |
kern/subr_witness.c optional witness |
kern/sys_generic.c standard |
kern/sys_pipe.c standard |
kern/sys_process.c standard |
kern/sys_socket.c standard |
kern/syscalls.c optional witness |
kern/sysv_ipc.c standard |
kern/sysv_msg.c optional sysvmsg |
kern/sysv_sem.c optional sysvsem |
kern/sysv_shm.c optional sysvshm |
kern/tty.c standard |
kern/tty_compat.c standard |
kern/tty_conf.c standard |
kern/tty_cons.c standard |
kern/tty_pty.c optional pty |
kern/tty_subr.c standard |
kern/tty_tty.c standard |
kern/uipc_accf.c optional inet |
kern/uipc_cow.c optional zero_copy_sockets |
kern/uipc_domain.c standard |
kern/uipc_mbuf.c standard |
kern/uipc_mbuf2.c standard |
kern/uipc_proto.c standard |
kern/uipc_sem.c optional p1003_1b_semaphores |
kern/uipc_socket.c standard |
kern/uipc_socket2.c standard |
kern/uipc_syscalls.c standard |
kern/uipc_usrreq.c standard |
kern/vfs_aio.c optional vfs_aio |
kern/vfs_bio.c standard |
kern/vfs_cache.c standard |
kern/vfs_cluster.c standard |
kern/vfs_default.c standard |
kern/vfs_export.c standard |
kern/vfs_hash.c standard |
kern/vfs_init.c standard |
kern/vfs_lookup.c standard |
kern/vfs_mount.c standard |
kern/vfs_subr.c standard |
kern/vfs_syscalls.c standard |
kern/vfs_vnops.c standard |
# |
# These files in libkern/ are those needed by all architectures. Some |
# of the files in libkern/ are only needed on some architectures, e.g., |
# libkern/divdi3.c is needed by i386 but not alpha. Also, some of these |
# routines may be optimized for a particular platform. In either case, |
# the file should be moved to conf/files.<arch> from here. |
# |
libkern/arc4random.c standard |
libkern/bcd.c standard |
libkern/bsearch.c standard |
libkern/crc32.c standard |
libkern/fnmatch.c standard |
libkern/gets.c standard |
libkern/iconv.c optional libiconv |
libkern/iconv_converter_if.m optional libiconv |
libkern/iconv_xlat.c optional libiconv |
libkern/iconv_xlat16.c optional libiconv |
libkern/index.c standard |
libkern/inet_ntoa.c standard |
libkern/mcount.c optional profiling-routine |
libkern/qsort.c standard |
libkern/qsort_r.c standard |
libkern/random.c standard |
libkern/rindex.c standard |
libkern/scanc.c standard |
libkern/skpc.c standard |
libkern/strcasecmp.c standard |
libkern/strcat.c standard |
libkern/strcmp.c standard |
libkern/strcpy.c standard |
libkern/strdup.c standard |
libkern/strlcat.c standard |
libkern/strlcpy.c standard |
libkern/strlen.c standard |
libkern/strncmp.c standard |
libkern/strncpy.c standard |
libkern/strsep.c standard |
libkern/strspn.c standard |
libkern/strtol.c standard |
libkern/strtoq.c standard |
libkern/strtoul.c standard |
libkern/strtouq.c standard |
libkern/strvalid.c standard |
net/bpf.c standard |
net/bpf_filter.c optional bpf |
net/bpf_filter.c optional netgraph_bpf |
net/bridge.c optional bridge |
net/bridgestp.c optional if_bridge |
net/bsd_comp.c optional ppp_bsdcomp |
net/if.c standard |
net/if_arcsubr.c optional arcnet |
net/if_atmsubr.c optional atm |
net/if_bridge.c optional if_bridge |
net/if_clone.c standard |
net/if_disc.c optional disc |
net/if_ef.c optional ef |
net/if_ethersubr.c optional ether |
net/if_faith.c optional faith |
net/if_fddisubr.c optional fddi |
net/if_fwsubr.c optional fwip |
net/if_gif.c optional gif |
net/if_gre.c optional gre |
net/if_iso88025subr.c optional token |
net/if_loop.c optional loop |
net/if_media.c standard |
net/if_mib.c standard |
net/if_ppp.c optional ppp |
net/if_sl.c optional sl |
net/if_spppfr.c optional sppp |
net/if_spppfr.c optional i4bisppp |
net/if_spppsubr.c optional sppp |
net/if_spppsubr.c optional i4bisppp |
net/if_stf.c optional stf |
net/if_tun.c optional tun |
net/if_tap.c optional tap |
net/if_vlan.c optional vlan |
net/netisr.c standard |
net/ppp_deflate.c optional ppp_deflate |
net/ppp_tty.c optional ppp |
net/pfil.c optional ether |
net/pfil.c optional inet |
net/radix.c standard |
net/raw_cb.c standard |
net/raw_usrreq.c standard |
net/route.c standard |
net/rtsock.c standard |
net/slcompress.c optional netgraph_vjc |
net/slcompress.c optional ppp |
net/slcompress.c optional sl |
net/slcompress.c optional sppp |
net/zlib.c optional ppp_deflate |
net/zlib.c optional ipsec |
net/zlib.c optional crypto |
net/zlib.c optional geom_uzip |
net80211/ieee80211.c optional wlan |
net80211/ieee80211_acl.c optional wlan_acl |
net80211/ieee80211_crypto.c optional wlan |
net80211/ieee80211_crypto_ccmp.c optional wlan_ccmp |
net80211/ieee80211_crypto_none.c optional wlan |
net80211/ieee80211_crypto_tkip.c optional wlan_tkip |
net80211/ieee80211_crypto_wep.c optional wlan_wep |
net80211/ieee80211_freebsd.c optional wlan |
net80211/ieee80211_input.c optional wlan |
net80211/ieee80211_ioctl.c optional wlan |
net80211/ieee80211_node.c optional wlan |
net80211/ieee80211_output.c optional wlan |
net80211/ieee80211_proto.c optional wlan |
net80211/ieee80211_xauth.c optional wlan_xauth |
netatalk/aarp.c optional netatalk |
netatalk/at_control.c optional netatalk |
netatalk/at_proto.c optional netatalk |
netatalk/at_rmx.c optional netatalkdebug |
netatalk/ddp_input.c optional netatalk |
netatalk/ddp_output.c optional netatalk |
netatalk/ddp_pcb.c optional netatalk |
netatalk/ddp_usrreq.c optional netatalk |
netatm/atm_aal5.c optional atm_core |
netatm/atm_cm.c optional atm_core |
netatm/atm_device.c optional atm_core |
netatm/atm_if.c optional atm_core |
netatm/atm_proto.c optional atm_core |
netatm/atm_signal.c optional atm_core |
netatm/atm_socket.c optional atm_core |
netatm/atm_subr.c optional atm_core |
netatm/atm_usrreq.c optional atm_core |
netatm/ipatm/ipatm_event.c optional atm_ip atm_core |
netatm/ipatm/ipatm_if.c optional atm_ip atm_core |
netatm/ipatm/ipatm_input.c optional atm_ip atm_core |
netatm/ipatm/ipatm_load.c optional atm_ip atm_core |
netatm/ipatm/ipatm_output.c optional atm_ip atm_core |
netatm/ipatm/ipatm_usrreq.c optional atm_ip atm_core |
netatm/ipatm/ipatm_vcm.c optional atm_ip atm_core |
netatm/sigpvc/sigpvc_if.c optional atm_sigpvc atm_core |
netatm/sigpvc/sigpvc_subr.c optional atm_sigpvc atm_core |
netatm/spans/spans_arp.c optional atm_spans atm_core \ |
dependency "spans_xdr.h" |
netatm/spans/spans_cls.c optional atm_spans atm_core |
netatm/spans/spans_if.c optional atm_spans atm_core |
netatm/spans/spans_kxdr.c optional atm_spans atm_core |
netatm/spans/spans_msg.c optional atm_spans atm_core |
netatm/spans/spans_print.c optional atm_spans atm_core |
netatm/spans/spans_proto.c optional atm_spans atm_core |
netatm/spans/spans_subr.c optional atm_spans atm_core |
netatm/spans/spans_util.c optional atm_spans atm_core |
spans_xdr.h optional atm_spans atm_core \ |
before-depend \ |
dependency "$S/netatm/spans/spans_xdr.x" \ |
compile-with "rpcgen -h -C $S/netatm/spans/spans_xdr.x | grep -v rpc/rpc.h > spans_xdr.h" \ |
clean "spans_xdr.h" \ |
no-obj no-implicit-rule |
spans_xdr.c optional atm_spans atm_core \ |
before-depend \ |
dependency "$S/netatm/spans/spans_xdr.x" \ |
compile-with "rpcgen -c -C $S/netatm/spans/spans_xdr.x | grep -v rpc/rpc.h > spans_xdr.c" \ |
clean "spans_xdr.c" \ |
no-obj no-implicit-rule local |
spans_xdr.o optional atm_spans atm_core \ |
dependency "$S/netatm/spans/spans_xdr.x" \ |
compile-with "${NORMAL_C}" \ |
no-implicit-rule local |
netatm/uni/q2110_sigaa.c optional atm_uni atm_core |
netatm/uni/q2110_sigcpcs.c optional atm_uni atm_core |
netatm/uni/q2110_subr.c optional atm_uni atm_core |
netatm/uni/qsaal1_sigaa.c optional atm_uni atm_core |
netatm/uni/qsaal1_sigcpcs.c optional atm_uni atm_core |
netatm/uni/qsaal1_subr.c optional atm_uni atm_core |
netatm/uni/sscf_uni.c optional atm_uni atm_core |
netatm/uni/sscf_uni_lower.c optional atm_uni atm_core |
netatm/uni/sscf_uni_upper.c optional atm_uni atm_core |
netatm/uni/sscop.c optional atm_uni atm_core |
netatm/uni/sscop_lower.c optional atm_uni atm_core |
netatm/uni/sscop_pdu.c optional atm_uni atm_core |
netatm/uni/sscop_sigaa.c optional atm_uni atm_core |
netatm/uni/sscop_sigcpcs.c optional atm_uni atm_core |
netatm/uni/sscop_subr.c optional atm_uni atm_core |
netatm/uni/sscop_timer.c optional atm_uni atm_core |
netatm/uni/sscop_upper.c optional atm_uni atm_core |
netatm/uni/uni_load.c optional atm_uni atm_core |
netatm/uni/uniarp.c optional atm_uni atm_core |
netatm/uni/uniarp_cache.c optional atm_uni atm_core |
netatm/uni/uniarp_input.c optional atm_uni atm_core |
netatm/uni/uniarp_output.c optional atm_uni atm_core |
netatm/uni/uniarp_timer.c optional atm_uni atm_core |
netatm/uni/uniarp_vcm.c optional atm_uni atm_core |
netatm/uni/uniip.c optional atm_uni atm_core |
netatm/uni/unisig_decode.c optional atm_uni atm_core |
netatm/uni/unisig_encode.c optional atm_uni atm_core |
netatm/uni/unisig_if.c optional atm_uni atm_core |
netatm/uni/unisig_mbuf.c optional atm_uni atm_core |
netatm/uni/unisig_msg.c optional atm_uni atm_core |
netatm/uni/unisig_print.c optional atm_uni atm_core |
netatm/uni/unisig_proto.c optional atm_uni atm_core |
netatm/uni/unisig_sigmgr_state.c optional atm_uni atm_core |
netatm/uni/unisig_subr.c optional atm_uni atm_core |
netatm/uni/unisig_util.c optional atm_uni atm_core |
netatm/uni/unisig_vc_state.c optional atm_uni atm_core |
netgraph/atm/atmpif/ng_atmpif.c optional netgraph_atm_atmpif |
netgraph/atm/atmpif/ng_atmpif_harp.c optional netgraph_atm_atmpif |
netgraph/atm/ccatm/ng_ccatm.c optional ngatm_ccatm |
netgraph/atm/ng_atm.c optional ngatm_atm |
netgraph/atm/ngatmbase.c optional ngatm_atmbase |
netgraph/atm/sscfu/ng_sscfu.c optional ngatm_sscfu |
netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop |
netgraph/atm/uni/ng_uni.c optional ngatm_uni |
netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth |
netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c optional netgraph_bluetooth_bt3c |
netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4 |
netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt |
netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c optional netgraph_bluetooth_ubtbcmfw |
netgraph/bluetooth/hci/ng_hci_cmds.c optional netgraph_bluetooth_hci |
netgraph/bluetooth/hci/ng_hci_evnt.c optional netgraph_bluetooth_hci |
netgraph/bluetooth/hci/ng_hci_main.c optional netgraph_bluetooth_hci |
netgraph/bluetooth/hci/ng_hci_misc.c optional netgraph_bluetooth_hci |
netgraph/bluetooth/hci/ng_hci_ulpi.c optional netgraph_bluetooth_hci |
netgraph/bluetooth/l2cap/ng_l2cap_cmds.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/l2cap/ng_l2cap_evnt.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/l2cap/ng_l2cap_llpi.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/l2cap/ng_l2cap_main.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/l2cap/ng_l2cap_misc.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c optional netgraph_bluetooth_l2cap |
netgraph/bluetooth/socket/ng_btsocket.c optional netgraph_bluetooth_socket |
netgraph/bluetooth/socket/ng_btsocket_hci_raw.c optional netgraph_bluetooth_socket |
netgraph/bluetooth/socket/ng_btsocket_l2cap.c optional netgraph_bluetooth_socket |
netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c optional netgraph_bluetooth_socket |
netgraph/bluetooth/socket/ng_btsocket_rfcomm.c optional netgraph_bluetooth_socket |
netgraph/netflow/netflow.c optional netgraph_netflow |
netgraph/netflow/ng_netflow.c optional netgraph_netflow |
netgraph/ng_UI.c optional netgraph_UI |
netgraph/ng_async.c optional netgraph_async |
netgraph/ng_atmllc.c optional netgraph_atmllc |
netgraph/ng_base.c optional netgraph |
netgraph/ng_bpf.c optional netgraph_bpf |
netgraph/ng_bridge.c optional netgraph_bridge |
netgraph/ng_cisco.c optional netgraph_cisco |
netgraph/ng_device.c optional netgraph_device |
netgraph/ng_echo.c optional netgraph_echo |
netgraph/ng_eiface.c optional netgraph_eiface |
netgraph/ng_ether.c optional netgraph_ether |
netgraph/ng_fec.c optional netgraph_fec |
netgraph/ng_frame_relay.c optional netgraph_frame_relay |
netgraph/ng_gif.c optional netgraph_gif |
netgraph/ng_gif_demux.c optional netgraph_gif_demux |
netgraph/ng_hole.c optional netgraph_hole |
netgraph/ng_iface.c optional netgraph_iface |
netgraph/ng_ip_input.c optional netgraph_ip_input |
netgraph/ng_ipfw.c optional netgraph_ipfw |
netgraph/ng_ksocket.c optional netgraph_ksocket |
netgraph/ng_l2tp.c optional netgraph_l2tp |
netgraph/ng_lmi.c optional netgraph_lmi |
netgraph/ng_mppc.c optional netgraph_mppc_compression |
netgraph/ng_mppc.c optional netgraph_mppc_encryption |
netgraph/ng_nat.c optional netgraph_nat |
netgraph/ng_one2many.c optional netgraph_one2many |
netgraph/ng_parse.c optional netgraph |
netgraph/ng_ppp.c optional netgraph_ppp |
netgraph/ng_pppoe.c optional netgraph_pppoe |
netgraph/ng_pptpgre.c optional netgraph_pptpgre |
netgraph/ng_rfc1490.c optional netgraph_rfc1490 |
netgraph/ng_socket.c optional netgraph_socket |
netgraph/ng_split.c optional netgraph_split |
netgraph/ng_sppp.c optional netgraph_sppp |
netgraph/ng_tcpmss.c optional netgraph_tcpmss |
netgraph/ng_tee.c optional netgraph_tee |
netgraph/ng_tty.c optional netgraph_tty |
netgraph/ng_vjc.c optional netgraph_vjc |
netinet/accf_data.c optional accept_filter_data |
netinet/accf_http.c optional accept_filter_http |
netinet/if_atm.c optional atm |
netinet/if_ether.c optional ether |
netinet/igmp.c optional inet |
netinet/in.c optional inet |
netinet/ip_carp.c optional carp |
netinet/in_gif.c optional gif inet |
netinet/ip_gre.c optional gre inet |
netinet/ip_id.c optional inet |
netinet/in_pcb.c optional inet |
netinet/in_proto.c optional inet |
netinet/in_rmx.c optional inet |
netinet/ip_divert.c optional ipdivert |
netinet/ip_dummynet.c optional dummynet |
netinet/ip_ecn.c optional inet |
netinet/ip_ecn.c optional inet6 |
netinet/ip_encap.c optional inet |
netinet/ip_encap.c optional inet6 |
netinet/ip_fastfwd.c optional inet |
netinet/ip_fw2.c optional ipfirewall |
netinet/ip_fw_pfil.c optional ipfirewall |
netinet/ip_icmp.c optional inet |
netinet/ip_input.c optional inet |
netinet/ip_mroute.c optional mrouting |
netinet/ip_output.c optional inet |
netinet/raw_ip.c optional inet |
netinet/tcp_debug.c optional tcpdebug |
netinet/tcp_hostcache.c optional inet |
netinet/tcp_input.c optional inet |
netinet/tcp_output.c optional inet |
netinet/tcp_sack.c optional inet |
netinet/tcp_subr.c optional inet |
netinet/tcp_syncache.c optional inet |
netinet/tcp_timer.c optional inet |
netinet/tcp_usrreq.c optional inet |
netinet/udp_usrreq.c optional inet |
netinet/libalias/alias.c optional libalias |
netinet/libalias/alias_cuseeme.c optional libalias |
netinet/libalias/alias_db.c optional libalias |
netinet/libalias/alias_ftp.c optional libalias |
netinet/libalias/alias_irc.c optional libalias |
netinet/libalias/alias_nbt.c optional libalias |
netinet/libalias/alias_pptp.c optional libalias |
netinet/libalias/alias_proxy.c optional libalias |
netinet/libalias/alias_skinny.c optional libalias |
netinet/libalias/alias_skinny.c optional libalias |
netinet/libalias/alias_smedia.c optional libalias |
netinet/libalias/alias_util.c optional libalias |
netinet6/ah_aesxcbcmac.c optional ipsec |
netinet6/ah_core.c optional ipsec |
netinet6/ah_input.c optional ipsec |
netinet6/ah_output.c optional ipsec |
netinet6/dest6.c optional inet6 |
netinet6/esp_aesctr.c optional ipsec ipsec_esp |
netinet6/esp_core.c optional ipsec ipsec_esp |
netinet6/esp_input.c optional ipsec ipsec_esp |
netinet6/esp_output.c optional ipsec ipsec_esp |
netinet6/esp_rijndael.c optional ipsec ipsec_esp |
netinet6/frag6.c optional inet6 |
netinet6/icmp6.c optional inet6 |
netinet6/in6.c optional inet6 |
netinet6/in6_cksum.c optional inet6 |
netinet6/in6_gif.c optional gif inet6 |
netinet6/in6_ifattach.c optional inet6 |
netinet6/in6_pcb.c optional inet6 |
netinet6/in6_proto.c optional inet6 |
netinet6/in6_rmx.c optional inet6 |
netinet6/in6_src.c optional inet6 |
netinet6/ip6_forward.c optional inet6 |
netinet6/ip6_fw.c optional inet6 ipv6firewall |
netinet6/ip6_id.c optional inet6 |
netinet6/ip6_input.c optional inet6 |
netinet6/ip6_mroute.c optional inet6 |
netinet6/ip6_output.c optional inet6 |
netinet6/ipcomp_core.c optional ipsec |
netinet6/ipcomp_input.c optional ipsec |
netinet6/ipcomp_output.c optional ipsec |
netinet6/ipsec.c optional ipsec |
netinet6/mld6.c optional inet6 |
netinet6/nd6.c optional inet6 |
netinet6/nd6_nbr.c optional inet6 |
netinet6/nd6_rtr.c optional inet6 |
netinet6/raw_ip6.c optional inet6 |
netinet6/route6.c optional inet6 |
netinet6/scope6.c optional inet6 |
netinet6/udp6_output.c optional inet6 |
netinet6/udp6_usrreq.c optional inet6 |
netipsec/ipsec.c optional fast_ipsec |
netipsec/ipsec_input.c optional fast_ipsec |
netipsec/ipsec_mbuf.c optional fast_ipsec |
netipsec/ipsec_output.c optional fast_ipsec |
netipsec/key.c optional fast_ipsec |
netipsec/key_debug.c optional fast_ipsec |
netipsec/keysock.c optional fast_ipsec |
netipsec/xform_ah.c optional fast_ipsec |
netipsec/xform_esp.c optional fast_ipsec |
netipsec/xform_ipcomp.c optional fast_ipsec |
netipsec/xform_ipip.c optional fast_ipsec |
netipsec/xform_tcp.c optional fast_ipsec tcp_signature |
netipx/ipx.c optional ipx |
netipx/ipx_cksum.c optional ipx |
netipx/ipx_input.c optional ipx |
netipx/ipx_ip.c optional ipx |
netipx/ipx_outputfl.c optional ipx |
netipx/ipx_pcb.c optional ipx |
netipx/ipx_proto.c optional ipx |
netipx/ipx_usrreq.c optional ipx |
netipx/spx_debug.c optional ipx |
netipx/spx_usrreq.c optional ipx |
netkey/key.c optional ipsec |
netkey/key_debug.c optional ipsec |
netkey/keydb.c optional ipsec |
netkey/keysock.c optional ipsec |
netnatm/natm.c optional natm |
netnatm/natm_pcb.c optional natm |
netnatm/natm_proto.c optional natm |
netncp/ncp_conn.c optional ncp |
netncp/ncp_crypt.c optional ncp |
netncp/ncp_login.c optional ncp |
netncp/ncp_mod.c optional ncp |
netncp/ncp_ncp.c optional ncp |
netncp/ncp_nls.c optional ncp |
netncp/ncp_rq.c optional ncp |
netncp/ncp_sock.c optional ncp |
netncp/ncp_subr.c optional ncp |
netsmb/smb_conn.c optional netsmb |
netsmb/smb_crypt.c optional netsmb |
netsmb/smb_dev.c optional netsmb |
netsmb/smb_iod.c optional netsmb |
netsmb/smb_rq.c optional netsmb |
netsmb/smb_smb.c optional netsmb |
netsmb/smb_subr.c optional netsmb |
netsmb/smb_trantcp.c optional netsmb |
netsmb/smb_usr.c optional netsmb |
nfs/nfs_common.c optional nfsclient |
nfs/nfs_common.c optional nfsserver |
nfs4client/nfs4_dev.c optional nfsclient |
nfs4client/nfs4_idmap.c optional nfsclient |
nfs4client/nfs4_socket.c optional nfsclient |
nfs4client/nfs4_subs.c optional nfsclient |
nfs4client/nfs4_vfs_subs.c optional nfsclient |
nfs4client/nfs4_vfsops.c optional nfsclient |
nfs4client/nfs4_vn_subs.c optional nfsclient |
nfs4client/nfs4_vnops.c optional nfsclient |
nfsclient/bootp_subr.c optional bootp nfsclient |
nfsclient/krpc_subr.c optional bootp nfsclient |
nfsclient/nfs_bio.c optional nfsclient |
nfsclient/nfs_diskless.c optional nfsclient nfs_root |
nfsclient/nfs_node.c optional nfsclient |
nfsclient/nfs_socket.c optional nfsclient |
nfsclient/nfs_subs.c optional nfsclient |
nfsclient/nfs_nfsiod.c optional nfsclient |
nfsclient/nfs_vfsops.c optional nfsclient |
nfsclient/nfs_vnops.c optional nfsclient |
nfsclient/nfs_lock.c optional nfsclient |
nfsserver/nfs_serv.c optional nfsserver |
nfsserver/nfs_srvsock.c optional nfsserver |
nfsserver/nfs_srvcache.c optional nfsserver |
nfsserver/nfs_srvsubs.c optional nfsserver |
nfsserver/nfs_syscalls.c optional nfsserver |
# crypto support |
opencrypto/cast.c optional crypto |
opencrypto/cast.c optional ipsec ipsec_esp |
opencrypto/criov.c optional crypto |
opencrypto/crypto.c optional crypto |
opencrypto/cryptodev.c optional cryptodev |
opencrypto/cryptosoft.c optional crypto |
opencrypto/deflate.c optional crypto |
opencrypto/rmd160.c optional crypto |
opencrypto/rmd160.c optional ipsec |
opencrypto/skipjack.c optional crypto |
opencrypto/xform.c optional crypto |
pci/agp.c optional agp pci |
pci/agp_if.m optional agp pci |
pci/alpm.c optional alpm pci |
pci/amdpm.c optional amdpm pci |
pci/amdpm.c optional nfpm pci |
pci/if_dc.c optional dc pci |
pci/if_de.c optional de pci |
pci/if_mn.c optional mn pci |
pci/if_pcn.c optional pcn pci |
pci/if_rl.c optional rl pci |
pci/if_sf.c optional sf pci |
pci/if_sis.c optional sis pci |
pci/if_sk.c optional sk pci |
pci/if_ste.c optional ste pci |
pci/if_ti.c optional ti pci |
pci/if_tl.c optional tl pci |
pci/if_vr.c optional vr pci |
pci/if_wb.c optional wb pci |
pci/if_xl.c optional xl pci |
pci/intpm.c optional intpm pci |
pci/ncr.c optional ncr pci |
pci/viapm.c optional viapm pci |
pci/xrpu.c optional xrpu pci |
posix4/ksched.c optional _kposix_priority_scheduling |
posix4/p1003_1b.c standard |
posix4/posix4_mib.c standard |
rpc/rpcclnt.c optional nfsclient |
security/mac/mac_inet.c optional mac inet |
security/mac/mac_label.c optional mac |
security/mac/mac_net.c optional mac |
security/mac/mac_pipe.c optional mac |
security/mac/mac_posix_sem.c optional mac |
security/mac/mac_process.c optional mac |
security/mac/mac_socket.c optional mac |
security/mac/mac_system.c optional mac |
security/mac/mac_sysv_msg.c optional mac |
security/mac/mac_sysv_sem.c optional mac |
security/mac/mac_sysv_shm.c optional mac |
security/mac/mac_vfs.c optional mac |
security/mac_biba/mac_biba.c optional mac_biba |
security/mac_bsdextended/mac_bsdextended.c optional mac_bsdextended |
security/mac_ifoff/mac_ifoff.c optional mac_ifoff |
security/mac_lomac/mac_lomac.c optional mac_lomac |
security/mac_mls/mac_mls.c optional mac_mls |
security/mac_none/mac_none.c optional mac_none |
security/mac_partition/mac_partition.c optional mac_partition |
security/mac_portacl/mac_portacl.c optional mac_portacl |
security/mac_seeotheruids/mac_seeotheruids.c optional mac_seeotheruids |
security/mac_stub/mac_stub.c optional mac_stub |
security/mac_test/mac_test.c optional mac_test |
security/mac_settime/mac_settime.c optional mac_settime |
ufs/ffs/ffs_alloc.c optional ffs |
ufs/ffs/ffs_balloc.c optional ffs |
ufs/ffs/ffs_inode.c optional ffs |
ufs/ffs/ffs_snapshot.c optional ffs |
ufs/ffs/ffs_softdep.c optional ffs |
ufs/ffs/ffs_subr.c optional ffs |
ufs/ffs/ffs_tables.c optional ffs |
ufs/ffs/ffs_vfsops.c optional ffs |
ufs/ffs/ffs_vnops.c optional ffs |
ufs/ffs/ffs_rawread.c optional directio |
ufs/ufs/ufs_acl.c optional ffs |
ufs/ufs/ufs_bmap.c optional ffs |
ufs/ufs/ufs_dirhash.c optional ffs |
ufs/ufs/ufs_extattr.c optional ffs |
ufs/ufs/ufs_inode.c optional ffs |
ufs/ufs/ufs_lookup.c optional ffs |
ufs/ufs/ufs_quota.c optional ffs |
ufs/ufs/ufs_vfsops.c optional ffs |
ufs/ufs/ufs_vnops.c optional ffs |
vm/default_pager.c standard |
vm/device_pager.c standard |
vm/phys_pager.c standard |
vm/swap_pager.c standard |
vm/uma_core.c standard |
vm/uma_dbg.c standard |
vm/vm_contig.c standard |
vm/memguard.c optional DEBUG_MEMGUARD |
vm/vm_fault.c standard |
vm/vm_glue.c standard |
vm/vm_init.c standard |
vm/vm_kern.c standard |
vm/vm_map.c standard |
vm/vm_meter.c standard |
vm/vm_mmap.c standard |
vm/vm_object.c standard |
vm/vm_page.c standard |
vm/vm_pageout.c standard |
vm/vm_pageq.c standard |
vm/vm_pager.c standard |
vm/vm_unix.c standard |
vm/vm_zeroidle.c standard |
vm/vnode_pager.c standard |
/FreeBSD/mac_settime/trunk/origins/module/Makefile.modules |
---|
0,0 → 1,521 |
# $FreeBSD: src/sys/modules/Makefile,v 1.450.2.5 2005/10/07 15:56:30 nyan Exp $ |
# oldcard -- specialized use for debugging only. |
# owi -- totally unsupported for debugging only. |
SUBDIR= ${_3dfx} \ |
${_aac} \ |
accf_data \ |
accf_http \ |
${_acpi} \ |
${_agp} \ |
aha \ |
${_ahb} \ |
${_aic} \ |
aic7xxx \ |
aio \ |
${_amd} \ |
amr \ |
an \ |
${_aout} \ |
${_apm} \ |
${_ar} \ |
${_arcmsr} \ |
${_arcnet} \ |
${_arl} \ |
${_asr} \ |
ata \ |
ath \ |
${_ath_hal} \ |
ath_rate_amrr \ |
ath_rate_sample \ |
ath_rate_onoe \ |
aue \ |
${_auxio} \ |
${_awi} \ |
axe \ |
bfe \ |
bge \ |
${_bios} \ |
${_bktr} \ |
bridge \ |
cam \ |
${_canbepm} \ |
${_canbus} \ |
${_cardbus} \ |
${_cbb} \ |
cd9660 \ |
cd9660_iconv \ |
cdce \ |
${_ciss} \ |
${_cm} \ |
coda \ |
coda5 \ |
${_coff} \ |
${_cp} \ |
${_cpufreq} \ |
${_crypto} \ |
${_cryptodev} \ |
${_cs} \ |
${_ctau} \ |
cue \ |
${_cx} \ |
dc \ |
dcons \ |
dcons_crom \ |
de \ |
${_digi} \ |
${_dpt} \ |
${_drm} \ |
dummynet \ |
${_ed} \ |
${_el} \ |
${_elink} \ |
${_em} \ |
en \ |
${_ep} \ |
${_ex} \ |
${_exca} \ |
${_ext2fs} \ |
fatm \ |
fdc \ |
fdescfs \ |
${_fe} \ |
firewire \ |
fxp \ |
${_gem} \ |
geom \ |
harp \ |
hatm \ |
${_hfa} \ |
hifn \ |
hme \ |
${_hptmv} \ |
hwpmc \ |
${_i2c} \ |
${_ibcs2} \ |
${_ichwd} \ |
${_ida} \ |
${_idt} \ |
${_ie} \ |
if_bridge \ |
if_disc \ |
if_ef \ |
if_faith \ |
if_gif \ |
if_gre \ |
${_if_ndis} \ |
if_ppp \ |
if_sl \ |
if_stf \ |
if_tap \ |
if_tun \ |
if_vlan \ |
${_iir} \ |
${_io} \ |
ip6fw \ |
ipdivert \ |
${_ipfilter} \ |
ipfw \ |
ip_mroute_mod \ |
${_ips} \ |
ipw \ |
isp \ |
ispfw \ |
iwi \ |
joy \ |
kbdmux \ |
kue \ |
lge \ |
libalias \ |
libiconv \ |
libmbpool \ |
libmchain \ |
${_linprocfs} \ |
${_linux} \ |
${_lnc} \ |
lpt \ |
mac_biba \ |
mac_bsdextended \ |
mac_ifoff \ |
mac_lomac \ |
mac_mls \ |
mac_none \ |
mac_partition \ |
mac_portacl \ |
mac_seeotheruids \ |
mac_stub \ |
mac_test \ |
mcd \ |
md \ |
mem \ |
mii \ |
mlx \ |
${_mly} \ |
mpt \ |
${_mse} \ |
msdosfs \ |
msdosfs_iconv \ |
my \ |
${_ncp} \ |
${_ncv} \ |
${_ndis} \ |
netgraph \ |
nfsclient \ |
nfsserver \ |
nge \ |
${_nve} \ |
nmdm \ |
${_nsp} \ |
ntfs \ |
ntfs_iconv \ |
nullfs \ |
${_nwfs} \ |
${_oltr} \ |
${_osf1} \ |
${_padlock} \ |
patm \ |
${_pccard} \ |
${_pcfclock} \ |
pcn \ |
${_pecoff} \ |
${_pf} \ |
plip \ |
${_pmc} \ |
portalfs \ |
ppbus \ |
ppi \ |
pps \ |
procfs \ |
pseudofs \ |
${_pst} \ |
${_puc} \ |
ral \ |
${_random} \ |
${_ray} \ |
rc \ |
rc4 \ |
re \ |
reiserfs \ |
rl \ |
rp \ |
rue \ |
${_s3} \ |
${_safe} \ |
${_sbni} \ |
sbsh \ |
scd \ |
${_scsi_low} \ |
sf \ |
${_sio} \ |
sis \ |
sk \ |
${_smbfs} \ |
sn \ |
${_snc} \ |
snp \ |
${_sound} \ |
${_speaker} \ |
${_splash} \ |
${_sppp} \ |
${_sr} \ |
ste \ |
${_stg} \ |
${_streams} \ |
sym \ |
${_syscons} \ |
sysvipc \ |
ti \ |
tl \ |
trm \ |
${_twa} \ |
twe \ |
tx \ |
txp \ |
${_uart} \ |
ubsa \ |
ubsec \ |
ubser \ |
ucom \ |
ucycom \ |
udav \ |
udbp \ |
udf \ |
udf_iconv \ |
ufm \ |
${_ufs} \ |
uftdi \ |
ugen \ |
uhid \ |
ukbd \ |
ulpt \ |
umass \ |
umct \ |
umodem \ |
ums \ |
unionfs \ |
uplcom \ |
ural \ |
urio \ |
usb \ |
uscanner \ |
utopia \ |
uvisor \ |
uvscom \ |
${_vesa} \ |
vge \ |
vkbd \ |
${_vpo} \ |
vr \ |
vx \ |
wb \ |
${_wi} \ |
wlan \ |
wlan_acl \ |
wlan_ccmp \ |
wlan_tkip \ |
wlan_wep \ |
wlan_xauth \ |
${_xe} \ |
xl |
.if ${MACHINE_ARCH} != "powerpc" |
_syscons= syscons |
_uart= uart |
_vpo= vpo |
.endif |
.if defined(ALL_MODULES) |
_ufs= ufs |
.endif |
.if !defined(NO_CRYPT) || defined(ALL_MODULES) |
.if exists(${.CURDIR}/../opencrypto) |
_crypto= crypto |
_cryptodev= cryptodev |
.endif |
.if exists(${.CURDIR}/../crypto) |
_random= random |
.endif |
.endif |
.if !defined(NO_IPFILTER) || defined(ALL_MODULES) |
_ipfilter= ipfilter |
.endif |
.if !defined(NO_PF) || defined(ALL_MODULES) |
_pf= pf |
.endif |
.if ${MACHINE_ARCH} == "i386" |
# XXX some of these can move to the general case when de-i386'ed |
# XXX some of these can move now, but are untested on other architectures. |
_3dfx= 3dfx |
_agp= agp |
_aic= aic |
_amd= amd |
_aout= aout |
_apm= apm |
_ar= ar |
_arcnet= arcnet |
_ath_hal= ath_hal |
_awi= awi |
_bktr= bktr |
_cardbus= cardbus |
_cbb= cbb |
_coff= coff |
_cp= cp |
_cpufreq= cpufreq |
_digi= digi |
_drm= drm |
_ed= ed |
_elink= elink |
_em= em |
_ep= ep |
_exca= exca |
_ext2fs= ext2fs |
_fe= fe |
_hfa= hfa |
_i2c= i2c |
_ibcs2= ibcs2 |
_ie= ie |
_if_ndis= if_ndis |
_io= io |
_linprocfs= linprocfs |
_linux= linux |
_lnc= lnc |
_mse= mse |
_ncp= ncp |
_ncv= ncv |
_ndis= ndis |
_nsp= nsp |
_nwfs= nwfs |
_oltr= oltr |
_pccard= pccard |
_pcfclock= pcfclock |
_pecoff= pecoff |
_pst= pst |
_puc= puc |
_ray= ray |
_safe= safe |
_sbni= sbni |
_scsi_low= scsi_low |
_sio= sio |
_smbfs= smbfs |
_sound= sound |
_speaker= speaker |
_splash= splash |
_sppp= sppp |
_sr= sr |
_stg= stg |
_streams= streams |
_wi= wi |
_xe= xe |
.if ${MACHINE} == "i386" |
_aac= aac |
_acpi= acpi |
_ahb= ahb |
_arl= arl |
_arcmsr= arcmsr |
_asr= asr |
_bios= bios |
_ciss= ciss |
_cm= cm |
_cs= cs |
_ctau= ctau |
_cx= cx |
_dpt= dpt |
_el= el |
_ex= ex |
_hptmv= hptmv |
_ichwd= ichwd |
_ida= ida |
_idt= idt |
_iir= iir |
_ips= ips |
_mly= mly |
_nve= nve |
.if !defined(NO_CRYPT) || defined(ALL_MODULES) |
.if exists(${.CURDIR}/../crypto/via) |
_padlock= padlock |
.endif |
.endif |
_s3= s3 |
_twa= twa |
_vesa= vesa |
.elif ${MACHINE} == "pc98" |
_canbepm= canbepm |
_canbus= canbus |
_pmc= pmc |
_snc= snc |
.endif |
.endif |
.if ${MACHINE_ARCH} == "alpha" |
_agp= agp |
_ahb= ahb |
_ext2fs= ext2fs |
_linprocfs= linprocfs |
_linux= linux |
_osf1= osf1 |
_sound= sound |
_sppp= sppp |
.endif |
.if ${MACHINE_ARCH} == "amd64" |
_aac= aac |
#_acpi= acpi # doesn't work on amd64 yet |
_agp= agp |
_arcmsr= arcmsr |
_ath_hal= ath_hal |
_ciss= ciss |
_cpufreq= cpufreq |
_digi= digi |
_drm= drm |
_em= em |
_ext2fs= ext2fs |
_hptmv= hptmv |
_i2c= i2c |
_ichwd= ichwd |
_ida= ida |
_if_ndis= if_ndis |
_iir= iir |
_io= io |
_ips= ips |
#_lnc= lnc |
_mly= mly |
_ndis= ndis |
_nve= nve |
_safe= safe |
_scsi_low= scsi_low |
_smbfs= smbfs |
_sound= sound |
_sppp= sppp |
_twa= twa |
.endif |
.if ${MACHINE_ARCH} == "ia64" |
# Modules not enabled on ia64 (as compared to i386) include: |
# aac acpi aout apm atspeaker drm ibcs2 linprocfs linux ncv |
# nsp oltr pecoff s3 sbni stg vesa |
# acpi is not enabled because it is broken as a module on ia64 |
_aic= aic |
#_ar= ar not 64-bit clean |
_arcnet= arcnet |
_asr= asr |
_bktr= bktr |
_cardbus= cardbus |
_cbb= cbb |
_ciss= ciss |
_cm= cm |
_coff= coff |
_cpufreq= cpufreq |
_el= el |
_em= em |
_ep= ep |
_exca= exca |
_fe= fe |
_hfa= hfa |
_iir= iir |
_mly= mly |
_pccard= pccard |
_scsi_low= scsi_low |
_smbfs= smbfs |
_sound= sound |
_splash= splash |
_sppp= sppp |
#_sr= sr not 64bit clean |
_streams= streams |
_wi= wi |
_xe= xe |
.endif |
.if ${MACHINE_ARCH} == "powerpc" |
_gem= gem |
.endif |
.if ${MACHINE_ARCH} == "sparc64" |
_auxio= auxio |
_gem= gem |
_sound= sound |
.endif |
.if defined(MODULES_OVERRIDE) && !defined(ALL_MODULES) |
SUBDIR=${MODULES_OVERRIDE} |
.endif |
.for reject in ${WITHOUT_MODULES} |
SUBDIR:= ${SUBDIR:N${reject}} |
.endfor |
# Calling kldxref(8) for each module is expensive. |
.if !defined(NO_XREF) |
.MAKEFLAGS+= -DNO_XREF |
afterinstall: |
@if type kldxref >/dev/null 2>&1; then \ |
${ECHO} kldxref ${DESTDIR}${KMODDIR}; \ |
kldxref ${DESTDIR}${KMODDIR}; \ |
fi |
.endif |
.include <bsd.subdir.mk> |
/FreeBSD/mac_settime/trunk/origins/kern/kern_time.c |
---|
0,0 → 1,777 |
/*- |
* Copyright (c) 1982, 1986, 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93 |
*/ |
#include <sys/cdefs.h> |
__FBSDID("$FreeBSD: src/sys/kern/kern_time.c,v 1.116 2005/03/31 22:51:18 jhb Exp $"); |
#include "opt_mac.h" |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/lock.h> |
#include <sys/mutex.h> |
#include <sys/sysproto.h> |
#include <sys/resourcevar.h> |
#include <sys/signalvar.h> |
#include <sys/kernel.h> |
#include <sys/mac.h> |
#include <sys/syscallsubr.h> |
#include <sys/sysent.h> |
#include <sys/proc.h> |
#include <sys/time.h> |
#include <sys/timetc.h> |
#include <sys/vnode.h> |
#include <vm/vm.h> |
#include <vm/vm_extern.h> |
int tz_minuteswest; |
int tz_dsttime; |
/* |
* Time of day and interval timer support. |
* |
* These routines provide the kernel entry points to get and set |
* the time-of-day and per-process interval timers. Subroutines |
* here provide support for adding and subtracting timeval structures |
* and decrementing interval timers, optionally reloading the interval |
* timers when they expire. |
*/ |
static int settime(struct thread *, struct timeval *); |
static void timevalfix(struct timeval *); |
static void no_lease_updatetime(int); |
static void |
no_lease_updatetime(deltat) |
int deltat; |
{ |
} |
void (*lease_updatetime)(int) = no_lease_updatetime; |
static int |
settime(struct thread *td, struct timeval *tv) |
{ |
struct timeval delta, tv1, tv2; |
static struct timeval maxtime, laststep; |
struct timespec ts; |
int s; |
s = splclock(); |
microtime(&tv1); |
delta = *tv; |
timevalsub(&delta, &tv1); |
/* |
* If the system is secure, we do not allow the time to be |
* set to a value earlier than 1 second less than the highest |
* time we have yet seen. The worst a miscreant can do in |
* this circumstance is "freeze" time. He couldn't go |
* back to the past. |
* |
* We similarly do not allow the clock to be stepped more |
* than one second, nor more than once per second. This allows |
* a miscreant to make the clock march double-time, but no worse. |
*/ |
if (securelevel_gt(td->td_ucred, 1) != 0) { |
if (delta.tv_sec < 0 || delta.tv_usec < 0) { |
/* |
* Update maxtime to latest time we've seen. |
*/ |
if (tv1.tv_sec > maxtime.tv_sec) |
maxtime = tv1; |
tv2 = *tv; |
timevalsub(&tv2, &maxtime); |
if (tv2.tv_sec < -1) { |
tv->tv_sec = maxtime.tv_sec - 1; |
printf("Time adjustment clamped to -1 second\n"); |
} |
} else { |
if (tv1.tv_sec == laststep.tv_sec) { |
splx(s); |
return (EPERM); |
} |
if (delta.tv_sec > 1) { |
tv->tv_sec = tv1.tv_sec + 1; |
printf("Time adjustment clamped to +1 second\n"); |
} |
laststep = *tv; |
} |
} |
ts.tv_sec = tv->tv_sec; |
ts.tv_nsec = tv->tv_usec * 1000; |
mtx_lock(&Giant); |
tc_setclock(&ts); |
(void) splsoftclock(); |
lease_updatetime(delta.tv_sec); |
splx(s); |
resettodr(); |
mtx_unlock(&Giant); |
return (0); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_gettime_args { |
clockid_t clock_id; |
struct timespec *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
clock_gettime(struct thread *td, struct clock_gettime_args *uap) |
{ |
struct timespec ats; |
struct timeval sys, user; |
struct proc *p; |
p = td->td_proc; |
switch (uap->clock_id) { |
case CLOCK_REALTIME: |
nanotime(&ats); |
break; |
case CLOCK_VIRTUAL: |
PROC_LOCK(p); |
calcru(p, &user, &sys); |
PROC_UNLOCK(p); |
TIMEVAL_TO_TIMESPEC(&user, &ats); |
break; |
case CLOCK_PROF: |
PROC_LOCK(p); |
calcru(p, &user, &sys); |
PROC_UNLOCK(p); |
timevaladd(&user, &sys); |
TIMEVAL_TO_TIMESPEC(&user, &ats); |
break; |
case CLOCK_MONOTONIC: |
nanouptime(&ats); |
break; |
default: |
return (EINVAL); |
} |
return (copyout(&ats, uap->tp, sizeof(ats))); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_settime_args { |
clockid_t clock_id; |
const struct timespec *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
clock_settime(struct thread *td, struct clock_settime_args *uap) |
{ |
struct timeval atv; |
struct timespec ats; |
int error; |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
return (error); |
#endif |
if ((error = suser(td)) != 0) |
return (error); |
if (uap->clock_id != CLOCK_REALTIME) |
return (EINVAL); |
if ((error = copyin(uap->tp, &ats, sizeof(ats))) != 0) |
return (error); |
if (ats.tv_nsec < 0 || ats.tv_nsec >= 1000000000) |
return (EINVAL); |
/* XXX Don't convert nsec->usec and back */ |
TIMESPEC_TO_TIMEVAL(&atv, &ats); |
error = settime(td, &atv); |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct clock_getres_args { |
clockid_t clock_id; |
struct timespec *tp; |
}; |
#endif |
int |
clock_getres(struct thread *td, struct clock_getres_args *uap) |
{ |
struct timespec ts; |
ts.tv_sec = 0; |
switch (uap->clock_id) { |
case CLOCK_REALTIME: |
case CLOCK_MONOTONIC: |
/* |
* Round up the result of the division cheaply by adding 1. |
* Rounding up is especially important if rounding down |
* would give 0. Perfect rounding is unimportant. |
*/ |
ts.tv_nsec = 1000000000 / tc_getfrequency() + 1; |
break; |
case CLOCK_VIRTUAL: |
case CLOCK_PROF: |
/* Accurately round up here because we can do so cheaply. */ |
ts.tv_nsec = (1000000000 + hz - 1) / hz; |
break; |
default: |
return (EINVAL); |
} |
if (uap->tp == NULL) |
return (0); |
return (copyout(&ts, uap->tp, sizeof(ts))); |
} |
static int nanowait; |
int |
kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt) |
{ |
struct timespec ts, ts2, ts3; |
struct timeval tv; |
int error; |
if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000) |
return (EINVAL); |
if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec == 0)) |
return (0); |
getnanouptime(&ts); |
timespecadd(&ts, rqt); |
TIMESPEC_TO_TIMEVAL(&tv, rqt); |
for (;;) { |
error = tsleep(&nanowait, PWAIT | PCATCH, "nanslp", |
tvtohz(&tv)); |
getnanouptime(&ts2); |
if (error != EWOULDBLOCK) { |
if (error == ERESTART) |
error = EINTR; |
if (rmt != NULL) { |
timespecsub(&ts, &ts2); |
if (ts.tv_sec < 0) |
timespecclear(&ts); |
*rmt = ts; |
} |
return (error); |
} |
if (timespeccmp(&ts2, &ts, >=)) |
return (0); |
ts3 = ts; |
timespecsub(&ts3, &ts2); |
TIMESPEC_TO_TIMEVAL(&tv, &ts3); |
} |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct nanosleep_args { |
struct timespec *rqtp; |
struct timespec *rmtp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
nanosleep(struct thread *td, struct nanosleep_args *uap) |
{ |
struct timespec rmt, rqt; |
int error; |
error = copyin(uap->rqtp, &rqt, sizeof(rqt)); |
if (error) |
return (error); |
if (uap->rmtp && |
!useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) |
return (EFAULT); |
error = kern_nanosleep(td, &rqt, &rmt); |
if (error && uap->rmtp) { |
int error2; |
error2 = copyout(&rmt, uap->rmtp, sizeof(rmt)); |
if (error2) |
error = error2; |
} |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct gettimeofday_args { |
struct timeval *tp; |
struct timezone *tzp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
gettimeofday(struct thread *td, struct gettimeofday_args *uap) |
{ |
struct timeval atv; |
struct timezone rtz; |
int error = 0; |
if (uap->tp) { |
microtime(&atv); |
error = copyout(&atv, uap->tp, sizeof (atv)); |
} |
if (error == 0 && uap->tzp != NULL) { |
rtz.tz_minuteswest = tz_minuteswest; |
rtz.tz_dsttime = tz_dsttime; |
error = copyout(&rtz, uap->tzp, sizeof (rtz)); |
} |
return (error); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct settimeofday_args { |
struct timeval *tv; |
struct timezone *tzp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
settimeofday(struct thread *td, struct settimeofday_args *uap) |
{ |
struct timeval atv, *tvp; |
struct timezone atz, *tzp; |
int error; |
if (uap->tv) { |
error = copyin(uap->tv, &atv, sizeof(atv)); |
if (error) |
return (error); |
tvp = &atv; |
} else |
tvp = NULL; |
if (uap->tzp) { |
error = copyin(uap->tzp, &atz, sizeof(atz)); |
if (error) |
return (error); |
tzp = &atz; |
} else |
tzp = NULL; |
return (kern_settimeofday(td, tvp, tzp)); |
} |
int |
kern_settimeofday(struct thread *td, struct timeval *tv, struct timezone *tzp) |
{ |
int error; |
#ifdef MAC |
error = mac_check_system_settime(td->td_ucred); |
if (error) |
return (error); |
#endif |
error = suser(td); |
if (error) |
return (error); |
/* Verify all parameters before changing time. */ |
if (tv) { |
if (tv->tv_usec < 0 || tv->tv_usec >= 1000000) |
return (EINVAL); |
error = settime(td, tv); |
} |
if (tzp && error == 0) { |
tz_minuteswest = tzp->tz_minuteswest; |
tz_dsttime = tzp->tz_dsttime; |
} |
return (error); |
} |
/* |
* Get value of an interval timer. The process virtual and |
* profiling virtual time timers are kept in the p_stats area, since |
* they can be swapped out. These are kept internally in the |
* way they are specified externally: in time until they expire. |
* |
* The real time interval timer is kept in the process table slot |
* for the process, and its value (it_value) is kept as an |
* absolute time rather than as a delta, so that it is easy to keep |
* periodic real-time signals from drifting. |
* |
* Virtual time timers are processed in the hardclock() routine of |
* kern_clock.c. The real time timer is processed by a timeout |
* routine, called from the softclock() routine. Since a callout |
* may be delayed in real time due to interrupt processing in the system, |
* it is possible for the real time timeout routine (realitexpire, given below), |
* to be delayed in real time past when it is supposed to occur. It |
* does not suffice, therefore, to reload the real timer .it_value from the |
* real time timers .it_interval. Rather, we compute the next time in |
* absolute time the timer should go off. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct getitimer_args { |
u_int which; |
struct itimerval *itv; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
getitimer(struct thread *td, struct getitimer_args *uap) |
{ |
struct itimerval aitv; |
int error; |
error = kern_getitimer(td, uap->which, &aitv); |
if (error != 0) |
return (error); |
return (copyout(&aitv, uap->itv, sizeof (struct itimerval))); |
} |
int |
kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv) |
{ |
struct proc *p = td->td_proc; |
struct timeval ctv; |
if (which > ITIMER_PROF) |
return (EINVAL); |
if (which == ITIMER_REAL) { |
/* |
* Convert from absolute to relative time in .it_value |
* part of real time timer. If time for real time timer |
* has passed return 0, else return difference between |
* current time and time for the timer to go off. |
*/ |
PROC_LOCK(p); |
*aitv = p->p_realtimer; |
PROC_UNLOCK(p); |
if (timevalisset(&aitv->it_value)) { |
getmicrouptime(&ctv); |
if (timevalcmp(&aitv->it_value, &ctv, <)) |
timevalclear(&aitv->it_value); |
else |
timevalsub(&aitv->it_value, &ctv); |
} |
} else { |
mtx_lock_spin(&sched_lock); |
*aitv = p->p_stats->p_timer[which]; |
mtx_unlock_spin(&sched_lock); |
} |
return (0); |
} |
#ifndef _SYS_SYSPROTO_H_ |
struct setitimer_args { |
u_int which; |
struct itimerval *itv, *oitv; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
setitimer(struct thread *td, struct setitimer_args *uap) |
{ |
struct itimerval aitv, oitv; |
int error; |
if (uap->itv == NULL) { |
uap->itv = uap->oitv; |
return (getitimer(td, (struct getitimer_args *)uap)); |
} |
if ((error = copyin(uap->itv, &aitv, sizeof(struct itimerval)))) |
return (error); |
error = kern_setitimer(td, uap->which, &aitv, &oitv); |
if (error != 0 || uap->oitv == NULL) |
return (error); |
return (copyout(&oitv, uap->oitv, sizeof(struct itimerval))); |
} |
int |
kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, |
struct itimerval *oitv) |
{ |
struct proc *p = td->td_proc; |
struct timeval ctv; |
if (aitv == NULL) |
return (kern_getitimer(td, which, oitv)); |
if (which > ITIMER_PROF) |
return (EINVAL); |
if (itimerfix(&aitv->it_value)) |
return (EINVAL); |
if (!timevalisset(&aitv->it_value)) |
timevalclear(&aitv->it_interval); |
else if (itimerfix(&aitv->it_interval)) |
return (EINVAL); |
if (which == ITIMER_REAL) { |
PROC_LOCK(p); |
if (timevalisset(&p->p_realtimer.it_value)) |
callout_stop(&p->p_itcallout); |
getmicrouptime(&ctv); |
if (timevalisset(&aitv->it_value)) { |
callout_reset(&p->p_itcallout, tvtohz(&aitv->it_value), |
realitexpire, p); |
timevaladd(&aitv->it_value, &ctv); |
} |
*oitv = p->p_realtimer; |
p->p_realtimer = *aitv; |
PROC_UNLOCK(p); |
if (timevalisset(&oitv->it_value)) { |
if (timevalcmp(&oitv->it_value, &ctv, <)) |
timevalclear(&oitv->it_value); |
else |
timevalsub(&oitv->it_value, &ctv); |
} |
} else { |
mtx_lock_spin(&sched_lock); |
*oitv = p->p_stats->p_timer[which]; |
p->p_stats->p_timer[which] = *aitv; |
mtx_unlock_spin(&sched_lock); |
} |
return (0); |
} |
/* |
* Real interval timer expired: |
* send process whose timer expired an alarm signal. |
* If time is not set up to reload, then just return. |
* Else compute next time timer should go off which is > current time. |
* This is where delay in processing this timeout causes multiple |
* SIGALRM calls to be compressed into one. |
* tvtohz() always adds 1 to allow for the time until the next clock |
* interrupt being strictly less than 1 clock tick, but we don't want |
* that here since we want to appear to be in sync with the clock |
* interrupt even when we're delayed. |
*/ |
void |
realitexpire(void *arg) |
{ |
struct proc *p; |
struct timeval ctv, ntv; |
p = (struct proc *)arg; |
PROC_LOCK(p); |
psignal(p, SIGALRM); |
if (!timevalisset(&p->p_realtimer.it_interval)) { |
timevalclear(&p->p_realtimer.it_value); |
if (p->p_flag & P_WEXIT) |
wakeup(&p->p_itcallout); |
PROC_UNLOCK(p); |
return; |
} |
for (;;) { |
timevaladd(&p->p_realtimer.it_value, |
&p->p_realtimer.it_interval); |
getmicrouptime(&ctv); |
if (timevalcmp(&p->p_realtimer.it_value, &ctv, >)) { |
ntv = p->p_realtimer.it_value; |
timevalsub(&ntv, &ctv); |
callout_reset(&p->p_itcallout, tvtohz(&ntv) - 1, |
realitexpire, p); |
PROC_UNLOCK(p); |
return; |
} |
} |
/*NOTREACHED*/ |
} |
/* |
* Check that a proposed value to load into the .it_value or |
* .it_interval part of an interval timer is acceptable, and |
* fix it to have at least minimal value (i.e. if it is less |
* than the resolution of the clock, round it up.) |
*/ |
int |
itimerfix(struct timeval *tv) |
{ |
if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || |
tv->tv_usec < 0 || tv->tv_usec >= 1000000) |
return (EINVAL); |
if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < tick) |
tv->tv_usec = tick; |
return (0); |
} |
/* |
* Decrement an interval timer by a specified number |
* of microseconds, which must be less than a second, |
* i.e. < 1000000. If the timer expires, then reload |
* it. In this case, carry over (usec - old value) to |
* reduce the value reloaded into the timer so that |
* the timer does not drift. This routine assumes |
* that it is called in a context where the timers |
* on which it is operating cannot change in value. |
*/ |
int |
itimerdecr(struct itimerval *itp, int usec) |
{ |
if (itp->it_value.tv_usec < usec) { |
if (itp->it_value.tv_sec == 0) { |
/* expired, and already in next interval */ |
usec -= itp->it_value.tv_usec; |
goto expire; |
} |
itp->it_value.tv_usec += 1000000; |
itp->it_value.tv_sec--; |
} |
itp->it_value.tv_usec -= usec; |
usec = 0; |
if (timevalisset(&itp->it_value)) |
return (1); |
/* expired, exactly at end of interval */ |
expire: |
if (timevalisset(&itp->it_interval)) { |
itp->it_value = itp->it_interval; |
itp->it_value.tv_usec -= usec; |
if (itp->it_value.tv_usec < 0) { |
itp->it_value.tv_usec += 1000000; |
itp->it_value.tv_sec--; |
} |
} else |
itp->it_value.tv_usec = 0; /* sec is already 0 */ |
return (0); |
} |
/* |
* Add and subtract routines for timevals. |
* N.B.: subtract routine doesn't deal with |
* results which are before the beginning, |
* it just gets very confused in this case. |
* Caveat emptor. |
*/ |
void |
timevaladd(struct timeval *t1, const struct timeval *t2) |
{ |
t1->tv_sec += t2->tv_sec; |
t1->tv_usec += t2->tv_usec; |
timevalfix(t1); |
} |
void |
timevalsub(struct timeval *t1, const struct timeval *t2) |
{ |
t1->tv_sec -= t2->tv_sec; |
t1->tv_usec -= t2->tv_usec; |
timevalfix(t1); |
} |
static void |
timevalfix(struct timeval *t1) |
{ |
if (t1->tv_usec < 0) { |
t1->tv_sec--; |
t1->tv_usec += 1000000; |
} |
if (t1->tv_usec >= 1000000) { |
t1->tv_sec++; |
t1->tv_usec -= 1000000; |
} |
} |
/* |
* ratecheck(): simple time-based rate-limit checking. |
*/ |
int |
ratecheck(struct timeval *lasttime, const struct timeval *mininterval) |
{ |
struct timeval tv, delta; |
int rv = 0; |
getmicrouptime(&tv); /* NB: 10ms precision */ |
delta = tv; |
timevalsub(&delta, lasttime); |
/* |
* check for 0,0 is so that the message will be seen at least once, |
* even if interval is huge. |
*/ |
if (timevalcmp(&delta, mininterval, >=) || |
(lasttime->tv_sec == 0 && lasttime->tv_usec == 0)) { |
*lasttime = tv; |
rv = 1; |
} |
return (rv); |
} |
/* |
* ppsratecheck(): packets (or events) per second limitation. |
* |
* Return 0 if the limit is to be enforced (e.g. the caller |
* should drop a packet because of the rate limitation). |
* |
* maxpps of 0 always causes zero to be returned. maxpps of -1 |
* always causes 1 to be returned; this effectively defeats rate |
* limiting. |
* |
* Note that we maintain the struct timeval for compatibility |
* with other bsd systems. We reuse the storage and just monitor |
* clock ticks for minimal overhead. |
*/ |
int |
ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps) |
{ |
int now; |
/* |
* Reset the last time and counter if this is the first call |
* or more than a second has passed since the last update of |
* lasttime. |
*/ |
now = ticks; |
if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) { |
lasttime->tv_sec = now; |
*curpps = 1; |
return (maxpps != 0); |
} else { |
(*curpps)++; /* NB: ignore potential overflow */ |
return (maxpps < 0 || *curpps < maxpps); |
} |
} |
/FreeBSD/mac_settime/trunk/origins/kern/kern_ntptime.c |
---|
0,0 → 1,976 |
/*- |
*********************************************************************** |
* * |
* Copyright (c) David L. Mills 1993-2001 * |
* * |
* Permission to use, copy, modify, and distribute this software and * |
* its documentation for any purpose and without fee is hereby * |
* granted, provided that the above copyright notice appears in all * |
* copies and that both the copyright notice and this permission * |
* notice appear in supporting documentation, and that the name * |
* University of Delaware not be used in advertising or publicity * |
* pertaining to distribution of the software without specific, * |
* written prior permission. The University of Delaware makes no * |
* representations about the suitability this software for any * |
* purpose. It is provided "as is" without express or implied * |
* warranty. * |
* * |
**********************************************************************/ |
/* |
* Adapted from the original sources for FreeBSD and timecounters by: |
* Poul-Henning Kamp <phk@FreeBSD.org>. |
* |
* The 32bit version of the "LP" macros seems a bit past its "sell by" |
* date so I have retained only the 64bit version and included it directly |
* in this file. |
* |
* Only minor changes done to interface with the timecounters over in |
* sys/kern/kern_clock.c. Some of the comments below may be (even more) |
* confusing and/or plain wrong in that context. |
*/ |
#include <sys/cdefs.h> |
__FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); |
#include "opt_ntp.h" |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/sysproto.h> |
#include <sys/kernel.h> |
#include <sys/proc.h> |
#include <sys/lock.h> |
#include <sys/mutex.h> |
#include <sys/time.h> |
#include <sys/timex.h> |
#include <sys/timetc.h> |
#include <sys/timepps.h> |
#include <sys/syscallsubr.h> |
#include <sys/sysctl.h> |
/* |
* Single-precision macros for 64-bit machines |
*/ |
typedef int64_t l_fp; |
#define L_ADD(v, u) ((v) += (u)) |
#define L_SUB(v, u) ((v) -= (u)) |
#define L_ADDHI(v, a) ((v) += (int64_t)(a) << 32) |
#define L_NEG(v) ((v) = -(v)) |
#define L_RSHIFT(v, n) \ |
do { \ |
if ((v) < 0) \ |
(v) = -(-(v) >> (n)); \ |
else \ |
(v) = (v) >> (n); \ |
} while (0) |
#define L_MPY(v, a) ((v) *= (a)) |
#define L_CLR(v) ((v) = 0) |
#define L_ISNEG(v) ((v) < 0) |
#define L_LINT(v, a) ((v) = (int64_t)(a) << 32) |
#define L_GINT(v) ((v) < 0 ? -(-(v) >> 32) : (v) >> 32) |
/* |
* Generic NTP kernel interface |
* |
* These routines constitute the Network Time Protocol (NTP) interfaces |
* for user and daemon application programs. The ntp_gettime() routine |
* provides the time, maximum error (synch distance) and estimated error |
* (dispersion) to client user application programs. The ntp_adjtime() |
* routine is used by the NTP daemon to adjust the system clock to an |
* externally derived time. The time offset and related variables set by |
* this routine are used by other routines in this module to adjust the |
* phase and frequency of the clock discipline loop which controls the |
* system clock. |
* |
* When the kernel time is reckoned directly in nanoseconds (NTP_NANO |
* defined), the time at each tick interrupt is derived directly from |
* the kernel time variable. When the kernel time is reckoned in |
* microseconds, (NTP_NANO undefined), the time is derived from the |
* kernel time variable together with a variable representing the |
* leftover nanoseconds at the last tick interrupt. In either case, the |
* current nanosecond time is reckoned from these values plus an |
* interpolated value derived by the clock routines in another |
* architecture-specific module. The interpolation can use either a |
* dedicated counter or a processor cycle counter (PCC) implemented in |
* some architectures. |
* |
* Note that all routines must run at priority splclock or higher. |
*/ |
/* |
* Phase/frequency-lock loop (PLL/FLL) definitions |
* |
* The nanosecond clock discipline uses two variable types, time |
* variables and frequency variables. Both types are represented as 64- |
* bit fixed-point quantities with the decimal point between two 32-bit |
* halves. On a 32-bit machine, each half is represented as a single |
* word and mathematical operations are done using multiple-precision |
* arithmetic. On a 64-bit machine, ordinary computer arithmetic is |
* used. |
* |
* A time variable is a signed 64-bit fixed-point number in ns and |
* fraction. It represents the remaining time offset to be amortized |
* over succeeding tick interrupts. The maximum time offset is about |
* 0.5 s and the resolution is about 2.3e-10 ns. |
* |
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 |
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |s s s| ns | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* | fraction | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |
* A frequency variable is a signed 64-bit fixed-point number in ns/s |
* and fraction. It represents the ns and fraction to be added to the |
* kernel time variable at each second. The maximum frequency offset is |
* about +-500000 ns/s and the resolution is about 2.3e-10 ns/s. |
* |
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 |
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* |s s s s s s s s s s s s s| ns/s | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* | fraction | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
*/ |
/* |
* The following variables establish the state of the PLL/FLL and the |
* residual time and frequency offset of the local clock. |
*/ |
#define SHIFT_PLL 4 /* PLL loop gain (shift) */ |
#define SHIFT_FLL 2 /* FLL loop gain (shift) */ |
static int time_state = TIME_OK; /* clock state */ |
static int time_status = STA_UNSYNC; /* clock status bits */ |
static long time_tai; /* TAI offset (s) */ |
static long time_monitor; /* last time offset scaled (ns) */ |
static long time_constant; /* poll interval (shift) (s) */ |
static long time_precision = 1; /* clock precision (ns) */ |
static long time_maxerror = MAXPHASE / 1000; /* maximum error (us) */ |
static long time_esterror = MAXPHASE / 1000; /* estimated error (us) */ |
static long time_reftime; /* time at last adjustment (s) */ |
static l_fp time_offset; /* time offset (ns) */ |
static l_fp time_freq; /* frequency offset (ns/s) */ |
static l_fp time_adj; /* tick adjust (ns/s) */ |
static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ |
#ifdef PPS_SYNC |
/* |
* The following variables are used when a pulse-per-second (PPS) signal |
* is available and connected via a modem control lead. They establish |
* the engineering parameters of the clock discipline loop when |
* controlled by the PPS signal. |
*/ |
#define PPS_FAVG 2 /* min freq avg interval (s) (shift) */ |
#define PPS_FAVGDEF 8 /* default freq avg int (s) (shift) */ |
#define PPS_FAVGMAX 15 /* max freq avg interval (s) (shift) */ |
#define PPS_PAVG 4 /* phase avg interval (s) (shift) */ |
#define PPS_VALID 120 /* PPS signal watchdog max (s) */ |
#define PPS_MAXWANDER 100000 /* max PPS wander (ns/s) */ |
#define PPS_POPCORN 2 /* popcorn spike threshold (shift) */ |
static struct timespec pps_tf[3]; /* phase median filter */ |
static l_fp pps_freq; /* scaled frequency offset (ns/s) */ |
static long pps_fcount; /* frequency accumulator */ |
static long pps_jitter; /* nominal jitter (ns) */ |
static long pps_stabil; /* nominal stability (scaled ns/s) */ |
static long pps_lastsec; /* time at last calibration (s) */ |
static int pps_valid; /* signal watchdog counter */ |
static int pps_shift = PPS_FAVG; /* interval duration (s) (shift) */ |
static int pps_shiftmax = PPS_FAVGDEF; /* max interval duration (s) (shift) */ |
static int pps_intcnt; /* wander counter */ |
/* |
* PPS signal quality monitors |
*/ |
static long pps_calcnt; /* calibration intervals */ |
static long pps_jitcnt; /* jitter limit exceeded */ |
static long pps_stbcnt; /* stability limit exceeded */ |
static long pps_errcnt; /* calibration errors */ |
#endif /* PPS_SYNC */ |
/* |
* End of phase/frequency-lock loop (PLL/FLL) definitions |
*/ |
static void ntp_init(void); |
static void hardupdate(long offset); |
static void ntp_gettime1(struct ntptimeval *ntvp); |
static void |
ntp_gettime1(struct ntptimeval *ntvp) |
{ |
struct timespec atv; /* nanosecond time */ |
GIANT_REQUIRED; |
nanotime(&atv); |
ntvp->time.tv_sec = atv.tv_sec; |
ntvp->time.tv_nsec = atv.tv_nsec; |
ntvp->maxerror = time_maxerror; |
ntvp->esterror = time_esterror; |
ntvp->tai = time_tai; |
ntvp->time_state = time_state; |
/* |
* Status word error decode. If any of these conditions occur, |
* an error is returned, instead of the status word. Most |
* applications will care only about the fact the system clock |
* may not be trusted, not about the details. |
* |
* Hardware or software error |
*/ |
if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || |
/* |
* PPS signal lost when either time or frequency synchronization |
* requested |
*/ |
(time_status & (STA_PPSFREQ | STA_PPSTIME) && |
!(time_status & STA_PPSSIGNAL)) || |
/* |
* PPS jitter exceeded when time synchronization requested |
*/ |
(time_status & STA_PPSTIME && |
time_status & STA_PPSJITTER) || |
/* |
* PPS wander exceeded or calibration error when frequency |
* synchronization requested |
*/ |
(time_status & STA_PPSFREQ && |
time_status & (STA_PPSWANDER | STA_PPSERROR))) |
ntvp->time_state = TIME_ERROR; |
} |
/* |
* ntp_gettime() - NTP user application interface |
* |
* See the timex.h header file for synopsis and API description. Note |
* that the TAI offset is returned in the ntvtimeval.tai structure |
* member. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct ntp_gettime_args { |
struct ntptimeval *ntvp; |
}; |
#endif |
/* ARGSUSED */ |
int |
ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) |
{ |
struct ntptimeval ntv; |
mtx_lock(&Giant); |
ntp_gettime1(&ntv); |
mtx_unlock(&Giant); |
return (copyout(&ntv, uap->ntvp, sizeof(ntv))); |
} |
static int |
ntp_sysctl(SYSCTL_HANDLER_ARGS) |
{ |
struct ntptimeval ntv; /* temporary structure */ |
ntp_gettime1(&ntv); |
return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); |
} |
SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW, 0, ""); |
SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE|CTLFLAG_RD, |
0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", ""); |
#ifdef PPS_SYNC |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, &pps_shiftmax, 0, ""); |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shift, CTLFLAG_RW, &pps_shift, 0, ""); |
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD, &time_monitor, 0, ""); |
SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD, &pps_freq, sizeof(pps_freq), "I", ""); |
SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, &time_freq, sizeof(time_freq), "I", ""); |
#endif |
/* |
* ntp_adjtime() - NTP daemon application interface |
* |
* See the timex.h header file for synopsis and API description. Note |
* that the timex.constant structure member has a dual purpose to set |
* the time constant and to set the TAI offset. |
*/ |
#ifndef _SYS_SYSPROTO_H_ |
struct ntp_adjtime_args { |
struct timex *tp; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
int |
ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) |
{ |
struct timex ntv; /* temporary structure */ |
long freq; /* frequency ns/s) */ |
int modes; /* mode bits from structure */ |
int s; /* caller priority */ |
int error; |
error = copyin((caddr_t)uap->tp, (caddr_t)&ntv, sizeof(ntv)); |
if (error) |
return(error); |
/* |
* Update selected clock variables - only the superuser can |
* change anything. Note that there is no error checking here on |
* the assumption the superuser should know what it is doing. |
* Note that either the time constant or TAI offset are loaded |
* from the ntv.constant member, depending on the mode bits. If |
* the STA_PLL bit in the status word is cleared, the state and |
* status words are reset to the initial values at boot. |
*/ |
mtx_lock(&Giant); |
modes = ntv.modes; |
if (modes) |
error = suser(td); |
if (error) |
goto done2; |
s = splclock(); |
if (modes & MOD_MAXERROR) |
time_maxerror = ntv.maxerror; |
if (modes & MOD_ESTERROR) |
time_esterror = ntv.esterror; |
if (modes & MOD_STATUS) { |
if (time_status & STA_PLL && !(ntv.status & STA_PLL)) { |
time_state = TIME_OK; |
time_status = STA_UNSYNC; |
#ifdef PPS_SYNC |
pps_shift = PPS_FAVG; |
#endif /* PPS_SYNC */ |
} |
time_status &= STA_RONLY; |
time_status |= ntv.status & ~STA_RONLY; |
} |
if (modes & MOD_TIMECONST) { |
if (ntv.constant < 0) |
time_constant = 0; |
else if (ntv.constant > MAXTC) |
time_constant = MAXTC; |
else |
time_constant = ntv.constant; |
} |
if (modes & MOD_TAI) { |
if (ntv.constant > 0) /* XXX zero & negative numbers ? */ |
time_tai = ntv.constant; |
} |
#ifdef PPS_SYNC |
if (modes & MOD_PPSMAX) { |
if (ntv.shift < PPS_FAVG) |
pps_shiftmax = PPS_FAVG; |
else if (ntv.shift > PPS_FAVGMAX) |
pps_shiftmax = PPS_FAVGMAX; |
else |
pps_shiftmax = ntv.shift; |
} |
#endif /* PPS_SYNC */ |
if (modes & MOD_NANO) |
time_status |= STA_NANO; |
if (modes & MOD_MICRO) |
time_status &= ~STA_NANO; |
if (modes & MOD_CLKB) |
time_status |= STA_CLK; |
if (modes & MOD_CLKA) |
time_status &= ~STA_CLK; |
if (modes & MOD_FREQUENCY) { |
freq = (ntv.freq * 1000LL) >> 16; |
if (freq > MAXFREQ) |
L_LINT(time_freq, MAXFREQ); |
else if (freq < -MAXFREQ) |
L_LINT(time_freq, -MAXFREQ); |
else { |
/* |
* ntv.freq is [PPM * 2^16] = [us/s * 2^16] |
* time_freq is [ns/s * 2^32] |
*/ |
time_freq = ntv.freq * 1000LL * 65536LL; |
} |
#ifdef PPS_SYNC |
pps_freq = time_freq; |
#endif /* PPS_SYNC */ |
} |
if (modes & MOD_OFFSET) { |
if (time_status & STA_NANO) |
hardupdate(ntv.offset); |
else |
hardupdate(ntv.offset * 1000); |
} |
/* |
* Retrieve all clock variables. Note that the TAI offset is |
* returned only by ntp_gettime(); |
*/ |
if (time_status & STA_NANO) |
ntv.offset = L_GINT(time_offset); |
else |
ntv.offset = L_GINT(time_offset) / 1000; /* XXX rounding ? */ |
ntv.freq = L_GINT((time_freq / 1000LL) << 16); |
ntv.maxerror = time_maxerror; |
ntv.esterror = time_esterror; |
ntv.status = time_status; |
ntv.constant = time_constant; |
if (time_status & STA_NANO) |
ntv.precision = time_precision; |
else |
ntv.precision = time_precision / 1000; |
ntv.tolerance = MAXFREQ * SCALE_PPM; |
#ifdef PPS_SYNC |
ntv.shift = pps_shift; |
ntv.ppsfreq = L_GINT((pps_freq / 1000LL) << 16); |
if (time_status & STA_NANO) |
ntv.jitter = pps_jitter; |
else |
ntv.jitter = pps_jitter / 1000; |
ntv.stabil = pps_stabil; |
ntv.calcnt = pps_calcnt; |
ntv.errcnt = pps_errcnt; |
ntv.jitcnt = pps_jitcnt; |
ntv.stbcnt = pps_stbcnt; |
#endif /* PPS_SYNC */ |
splx(s); |
error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); |
if (error) |
goto done2; |
/* |
* Status word error decode. See comments in |
* ntp_gettime() routine. |
*/ |
if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || |
(time_status & (STA_PPSFREQ | STA_PPSTIME) && |
!(time_status & STA_PPSSIGNAL)) || |
(time_status & STA_PPSTIME && |
time_status & STA_PPSJITTER) || |
(time_status & STA_PPSFREQ && |
time_status & (STA_PPSWANDER | STA_PPSERROR))) { |
td->td_retval[0] = TIME_ERROR; |
} else { |
td->td_retval[0] = time_state; |
} |
done2: |
mtx_unlock(&Giant); |
return (error); |
} |
/* |
* second_overflow() - called after ntp_tick_adjust() |
* |
* This routine is ordinarily called immediately following the above |
* routine ntp_tick_adjust(). While these two routines are normally |
* combined, they are separated here only for the purposes of |
* simulation. |
*/ |
void |
ntp_update_second(int64_t *adjustment, time_t *newsec) |
{ |
int tickrate; |
l_fp ftemp; /* 32/64-bit temporary */ |
/* |
* On rollover of the second both the nanosecond and microsecond |
* clocks are updated and the state machine cranked as |
* necessary. The phase adjustment to be used for the next |
* second is calculated and the maximum error is increased by |
* the tolerance. |
*/ |
time_maxerror += MAXFREQ / 1000; |
/* |
* Leap second processing. If in leap-insert state at |
* the end of the day, the system clock is set back one |
* second; if in leap-delete state, the system clock is |
* set ahead one second. The nano_time() routine or |
* external clock driver will insure that reported time |
* is always monotonic. |
*/ |
switch (time_state) { |
/* |
* No warning. |
*/ |
case TIME_OK: |
if (time_status & STA_INS) |
time_state = TIME_INS; |
else if (time_status & STA_DEL) |
time_state = TIME_DEL; |
break; |
/* |
* Insert second 23:59:60 following second |
* 23:59:59. |
*/ |
case TIME_INS: |
if (!(time_status & STA_INS)) |
time_state = TIME_OK; |
else if ((*newsec) % 86400 == 0) { |
(*newsec)--; |
time_state = TIME_OOP; |
time_tai++; |
} |
break; |
/* |
* Delete second 23:59:59. |
*/ |
case TIME_DEL: |
if (!(time_status & STA_DEL)) |
time_state = TIME_OK; |
else if (((*newsec) + 1) % 86400 == 0) { |
(*newsec)++; |
time_tai--; |
time_state = TIME_WAIT; |
} |
break; |
/* |
* Insert second in progress. |
*/ |
case TIME_OOP: |
time_state = TIME_WAIT; |
break; |
/* |
* Wait for status bits to clear. |
*/ |
case TIME_WAIT: |
if (!(time_status & (STA_INS | STA_DEL))) |
time_state = TIME_OK; |
} |
/* |
* Compute the total time adjustment for the next second |
* in ns. The offset is reduced by a factor depending on |
* whether the PPS signal is operating. Note that the |
* value is in effect scaled by the clock frequency, |
* since the adjustment is added at each tick interrupt. |
*/ |
ftemp = time_offset; |
#ifdef PPS_SYNC |
/* XXX even if PPS signal dies we should finish adjustment ? */ |
if (time_status & STA_PPSTIME && time_status & |
STA_PPSSIGNAL) |
L_RSHIFT(ftemp, pps_shift); |
else |
L_RSHIFT(ftemp, SHIFT_PLL + time_constant); |
#else |
L_RSHIFT(ftemp, SHIFT_PLL + time_constant); |
#endif /* PPS_SYNC */ |
time_adj = ftemp; |
L_SUB(time_offset, ftemp); |
L_ADD(time_adj, time_freq); |
/* |
* Apply any correction from adjtime(2). If more than one second |
* off we slew at a rate of 5ms/s (5000 PPM) else 500us/s (500PPM) |
* until the last second is slewed the final < 500 usecs. |
*/ |
if (time_adjtime != 0) { |
if (time_adjtime > 1000000) |
tickrate = 5000; |
else if (time_adjtime < -1000000) |
tickrate = -5000; |
else if (time_adjtime > 500) |
tickrate = 500; |
else if (time_adjtime < -500) |
tickrate = -500; |
else |
tickrate = time_adjtime; |
time_adjtime -= tickrate; |
L_LINT(ftemp, tickrate * 1000); |
L_ADD(time_adj, ftemp); |
} |
*adjustment = time_adj; |
#ifdef PPS_SYNC |
if (pps_valid > 0) |
pps_valid--; |
else |
time_status &= ~STA_PPSSIGNAL; |
#endif /* PPS_SYNC */ |
} |
/* |
* ntp_init() - initialize variables and structures |
* |
* This routine must be called after the kernel variables hz and tick |
* are set or changed and before the next tick interrupt. In this |
* particular implementation, these values are assumed set elsewhere in |
* the kernel. The design allows the clock frequency and tick interval |
* to be changed while the system is running. So, this routine should |
* probably be integrated with the code that does that. |
*/ |
static void |
ntp_init() |
{ |
/* |
* The following variables are initialized only at startup. Only |
* those structures not cleared by the compiler need to be |
* initialized, and these only in the simulator. In the actual |
* kernel, any nonzero values here will quickly evaporate. |
*/ |
L_CLR(time_offset); |
L_CLR(time_freq); |
#ifdef PPS_SYNC |
pps_tf[0].tv_sec = pps_tf[0].tv_nsec = 0; |
pps_tf[1].tv_sec = pps_tf[1].tv_nsec = 0; |
pps_tf[2].tv_sec = pps_tf[2].tv_nsec = 0; |
pps_fcount = 0; |
L_CLR(pps_freq); |
#endif /* PPS_SYNC */ |
} |
SYSINIT(ntpclocks, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, ntp_init, NULL) |
/* |
* hardupdate() - local clock update |
* |
* This routine is called by ntp_adjtime() to update the local clock |
* phase and frequency. The implementation is of an adaptive-parameter, |
* hybrid phase/frequency-lock loop (PLL/FLL). The routine computes new |
* time and frequency offset estimates for each call. If the kernel PPS |
* discipline code is configured (PPS_SYNC), the PPS signal itself |
* determines the new time offset, instead of the calling argument. |
* Presumably, calls to ntp_adjtime() occur only when the caller |
* believes the local clock is valid within some bound (+-128 ms with |
* NTP). If the caller's time is far different than the PPS time, an |
* argument will ensue, and it's not clear who will lose. |
* |
* For uncompensated quartz crystal oscillators and nominal update |
* intervals less than 256 s, operation should be in phase-lock mode, |
* where the loop is disciplined to phase. For update intervals greater |
* than 1024 s, operation should be in frequency-lock mode, where the |
* loop is disciplined to frequency. Between 256 s and 1024 s, the mode |
* is selected by the STA_MODE status bit. |
*/ |
static void |
hardupdate(offset) |
long offset; /* clock offset (ns) */ |
{ |
long mtemp; |
l_fp ftemp; |
/* |
* Select how the phase is to be controlled and from which |
* source. If the PPS signal is present and enabled to |
* discipline the time, the PPS offset is used; otherwise, the |
* argument offset is used. |
*/ |
if (!(time_status & STA_PLL)) |
return; |
if (!(time_status & STA_PPSTIME && time_status & |
STA_PPSSIGNAL)) { |
if (offset > MAXPHASE) |
time_monitor = MAXPHASE; |
else if (offset < -MAXPHASE) |
time_monitor = -MAXPHASE; |
else |
time_monitor = offset; |
L_LINT(time_offset, time_monitor); |
} |
/* |
* Select how the frequency is to be controlled and in which |
* mode (PLL or FLL). If the PPS signal is present and enabled |
* to discipline the frequency, the PPS frequency is used; |
* otherwise, the argument offset is used to compute it. |
*/ |
if (time_status & STA_PPSFREQ && time_status & STA_PPSSIGNAL) { |
time_reftime = time_second; |
return; |
} |
if (time_status & STA_FREQHOLD || time_reftime == 0) |
time_reftime = time_second; |
mtemp = time_second - time_reftime; |
L_LINT(ftemp, time_monitor); |
L_RSHIFT(ftemp, (SHIFT_PLL + 2 + time_constant) << 1); |
L_MPY(ftemp, mtemp); |
L_ADD(time_freq, ftemp); |
time_status &= ~STA_MODE; |
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > |
MAXSEC)) { |
L_LINT(ftemp, (time_monitor << 4) / mtemp); |
L_RSHIFT(ftemp, SHIFT_FLL + 4); |
L_ADD(time_freq, ftemp); |
time_status |= STA_MODE; |
} |
time_reftime = time_second; |
if (L_GINT(time_freq) > MAXFREQ) |
L_LINT(time_freq, MAXFREQ); |
else if (L_GINT(time_freq) < -MAXFREQ) |
L_LINT(time_freq, -MAXFREQ); |
} |
#ifdef PPS_SYNC |
/* |
* hardpps() - discipline CPU clock oscillator to external PPS signal |
* |
* This routine is called at each PPS interrupt in order to discipline |
* the CPU clock oscillator to the PPS signal. There are two independent |
* first-order feedback loops, one for the phase, the other for the |
* frequency. The phase loop measures and grooms the PPS phase offset |
* and leaves it in a handy spot for the seconds overflow routine. The |
* frequency loop averages successive PPS phase differences and |
* calculates the PPS frequency offset, which is also processed by the |
* seconds overflow routine. The code requires the caller to capture the |
* time and architecture-dependent hardware counter values in |
* nanoseconds at the on-time PPS signal transition. |
* |
* Note that, on some Unix systems this routine runs at an interrupt |
* priority level higher than the timer interrupt routine hardclock(). |
* Therefore, the variables used are distinct from the hardclock() |
* variables, except for the actual time and frequency variables, which |
* are determined by this routine and updated atomically. |
*/ |
void |
hardpps(tsp, nsec) |
struct timespec *tsp; /* time at PPS */ |
long nsec; /* hardware counter at PPS */ |
{ |
long u_sec, u_nsec, v_nsec; /* temps */ |
l_fp ftemp; |
/* |
* The signal is first processed by a range gate and frequency |
* discriminator. The range gate rejects noise spikes outside |
* the range +-500 us. The frequency discriminator rejects input |
* signals with apparent frequency outside the range 1 +-500 |
* PPM. If two hits occur in the same second, we ignore the |
* later hit; if not and a hit occurs outside the range gate, |
* keep the later hit for later comparison, but do not process |
* it. |
*/ |
time_status |= STA_PPSSIGNAL | STA_PPSJITTER; |
time_status &= ~(STA_PPSWANDER | STA_PPSERROR); |
pps_valid = PPS_VALID; |
u_sec = tsp->tv_sec; |
u_nsec = tsp->tv_nsec; |
if (u_nsec >= (NANOSECOND >> 1)) { |
u_nsec -= NANOSECOND; |
u_sec++; |
} |
v_nsec = u_nsec - pps_tf[0].tv_nsec; |
if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - |
MAXFREQ) |
return; |
pps_tf[2] = pps_tf[1]; |
pps_tf[1] = pps_tf[0]; |
pps_tf[0].tv_sec = u_sec; |
pps_tf[0].tv_nsec = u_nsec; |
/* |
* Compute the difference between the current and previous |
* counter values. If the difference exceeds 0.5 s, assume it |
* has wrapped around, so correct 1.0 s. If the result exceeds |
* the tick interval, the sample point has crossed a tick |
* boundary during the last second, so correct the tick. Very |
* intricate. |
*/ |
u_nsec = nsec; |
if (u_nsec > (NANOSECOND >> 1)) |
u_nsec -= NANOSECOND; |
else if (u_nsec < -(NANOSECOND >> 1)) |
u_nsec += NANOSECOND; |
pps_fcount += u_nsec; |
if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) |
return; |
time_status &= ~STA_PPSJITTER; |
/* |
* A three-stage median filter is used to help denoise the PPS |
* time. The median sample becomes the time offset estimate; the |
* difference between the other two samples becomes the time |
* dispersion (jitter) estimate. |
*/ |
if (pps_tf[0].tv_nsec > pps_tf[1].tv_nsec) { |
if (pps_tf[1].tv_nsec > pps_tf[2].tv_nsec) { |
v_nsec = pps_tf[1].tv_nsec; /* 0 1 2 */ |
u_nsec = pps_tf[0].tv_nsec - pps_tf[2].tv_nsec; |
} else if (pps_tf[2].tv_nsec > pps_tf[0].tv_nsec) { |
v_nsec = pps_tf[0].tv_nsec; /* 2 0 1 */ |
u_nsec = pps_tf[2].tv_nsec - pps_tf[1].tv_nsec; |
} else { |
v_nsec = pps_tf[2].tv_nsec; /* 0 2 1 */ |
u_nsec = pps_tf[0].tv_nsec - pps_tf[1].tv_nsec; |
} |
} else { |
if (pps_tf[1].tv_nsec < pps_tf[2].tv_nsec) { |
v_nsec = pps_tf[1].tv_nsec; /* 2 1 0 */ |
u_nsec = pps_tf[2].tv_nsec - pps_tf[0].tv_nsec; |
} else if (pps_tf[2].tv_nsec < pps_tf[0].tv_nsec) { |
v_nsec = pps_tf[0].tv_nsec; /* 1 0 2 */ |
u_nsec = pps_tf[1].tv_nsec - pps_tf[2].tv_nsec; |
} else { |
v_nsec = pps_tf[2].tv_nsec; /* 1 2 0 */ |
u_nsec = pps_tf[1].tv_nsec - pps_tf[0].tv_nsec; |
} |
} |
/* |
* Nominal jitter is due to PPS signal noise and interrupt |
* latency. If it exceeds the popcorn threshold, the sample is |
* discarded. otherwise, if so enabled, the time offset is |
* updated. We can tolerate a modest loss of data here without |
* much degrading time accuracy. |
*/ |
if (u_nsec > (pps_jitter << PPS_POPCORN)) { |
time_status |= STA_PPSJITTER; |
pps_jitcnt++; |
} else if (time_status & STA_PPSTIME) { |
time_monitor = -v_nsec; |
L_LINT(time_offset, time_monitor); |
} |
pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG; |
u_sec = pps_tf[0].tv_sec - pps_lastsec; |
if (u_sec < (1 << pps_shift)) |
return; |
/* |
* At the end of the calibration interval the difference between |
* the first and last counter values becomes the scaled |
* frequency. It will later be divided by the length of the |
* interval to determine the frequency update. If the frequency |
* exceeds a sanity threshold, or if the actual calibration |
* interval is not equal to the expected length, the data are |
* discarded. We can tolerate a modest loss of data here without |
* much degrading frequency accuracy. |
*/ |
pps_calcnt++; |
v_nsec = -pps_fcount; |
pps_lastsec = pps_tf[0].tv_sec; |
pps_fcount = 0; |
u_nsec = MAXFREQ << pps_shift; |
if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << |
pps_shift)) { |
time_status |= STA_PPSERROR; |
pps_errcnt++; |
return; |
} |
/* |
* Here the raw frequency offset and wander (stability) is |
* calculated. If the wander is less than the wander threshold |
* for four consecutive averaging intervals, the interval is |
* doubled; if it is greater than the threshold for four |
* consecutive intervals, the interval is halved. The scaled |
* frequency offset is converted to frequency offset. The |
* stability metric is calculated as the average of recent |
* frequency changes, but is used only for performance |
* monitoring. |
*/ |
L_LINT(ftemp, v_nsec); |
L_RSHIFT(ftemp, pps_shift); |
L_SUB(ftemp, pps_freq); |
u_nsec = L_GINT(ftemp); |
if (u_nsec > PPS_MAXWANDER) { |
L_LINT(ftemp, PPS_MAXWANDER); |
pps_intcnt--; |
time_status |= STA_PPSWANDER; |
pps_stbcnt++; |
} else if (u_nsec < -PPS_MAXWANDER) { |
L_LINT(ftemp, -PPS_MAXWANDER); |
pps_intcnt--; |
time_status |= STA_PPSWANDER; |
pps_stbcnt++; |
} else { |
pps_intcnt++; |
} |
if (pps_intcnt >= 4) { |
pps_intcnt = 4; |
if (pps_shift < pps_shiftmax) { |
pps_shift++; |
pps_intcnt = 0; |
} |
} else if (pps_intcnt <= -4 || pps_shift > pps_shiftmax) { |
pps_intcnt = -4; |
if (pps_shift > PPS_FAVG) { |
pps_shift--; |
pps_intcnt = 0; |
} |
} |
if (u_nsec < 0) |
u_nsec = -u_nsec; |
pps_stabil += (u_nsec * SCALE_PPM - pps_stabil) >> PPS_FAVG; |
/* |
* The PPS frequency is recalculated and clamped to the maximum |
* MAXFREQ. If enabled, the system clock frequency is updated as |
* well. |
*/ |
L_ADD(pps_freq, ftemp); |
u_nsec = L_GINT(pps_freq); |
if (u_nsec > MAXFREQ) |
L_LINT(pps_freq, MAXFREQ); |
else if (u_nsec < -MAXFREQ) |
L_LINT(pps_freq, -MAXFREQ); |
if (time_status & STA_PPSFREQ) |
time_freq = pps_freq; |
} |
#endif /* PPS_SYNC */ |
#ifndef _SYS_SYSPROTO_H_ |
struct adjtime_args { |
struct timeval *delta; |
struct timeval *olddelta; |
}; |
#endif |
/* |
* MPSAFE |
*/ |
/* ARGSUSED */ |
int |
adjtime(struct thread *td, struct adjtime_args *uap) |
{ |
struct timeval delta, olddelta, *deltap; |
int error; |
if (uap->delta) { |
error = copyin(uap->delta, &delta, sizeof(delta)); |
if (error) |
return (error); |
deltap = δ |
} else |
deltap = NULL; |
error = kern_adjtime(td, deltap, &olddelta); |
if (uap->olddelta && error == 0) |
error = copyout(&olddelta, uap->olddelta, sizeof(olddelta)); |
return (error); |
} |
int |
kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) |
{ |
struct timeval atv; |
int error; |
if ((error = suser(td))) |
return (error); |
mtx_lock(&Giant); |
if (olddelta) { |
atv.tv_sec = time_adjtime / 1000000; |
atv.tv_usec = time_adjtime % 1000000; |
if (atv.tv_usec < 0) { |
atv.tv_usec += 1000000; |
atv.tv_sec--; |
} |
*olddelta = atv; |
} |
if (delta) |
time_adjtime = (int64_t)delta->tv_sec * 1000000 + |
delta->tv_usec; |
mtx_unlock(&Giant); |
return (error); |
} |
/FreeBSD/mac_settime/trunk/origins/ntp/ntpd.c |
---|
0,0 → 1,1274 |
/* |
* ntpd.c - main program for the fixed point NTP daemon |
*/ |
#ifdef HAVE_CONFIG_H |
# include <config.h> |
#endif |
#include "ntp_machine.h" |
#include "ntpd.h" |
#include "ntp_io.h" |
#include "ntp_stdlib.h" |
#ifdef SIM |
#include "ntpsim.h" |
#endif |
#ifdef HAVE_UNISTD_H |
# include <unistd.h> |
#endif |
#ifdef HAVE_SYS_STAT_H |
# include <sys/stat.h> |
#endif |
#include <stdio.h> |
#ifndef SYS_WINNT |
# if !defined(VMS) /*wjm*/ |
# ifdef HAVE_SYS_PARAM_H |
# include <sys/param.h> |
# endif |
# endif /* VMS */ |
# ifdef HAVE_SYS_SIGNAL_H |
# include <sys/signal.h> |
# else |
# include <signal.h> |
# endif |
# ifdef HAVE_SYS_IOCTL_H |
# include <sys/ioctl.h> |
# endif /* HAVE_SYS_IOCTL_H */ |
# ifdef HAVE_SYS_RESOURCE_H |
# include <sys/resource.h> |
# endif /* HAVE_SYS_RESOURCE_H */ |
#else |
# include <signal.h> |
# include <process.h> |
# include <io.h> |
# include "../libntp/log.h" |
# include <clockstuff.h> |
# include <crtdbg.h> |
#endif /* SYS_WINNT */ |
#if defined(HAVE_RTPRIO) |
# ifdef HAVE_SYS_RESOURCE_H |
# include <sys/resource.h> |
# endif |
# ifdef HAVE_SYS_LOCK_H |
# include <sys/lock.h> |
# endif |
# include <sys/rtprio.h> |
#else |
# ifdef HAVE_PLOCK |
# ifdef HAVE_SYS_LOCK_H |
# include <sys/lock.h> |
# endif |
# endif |
#endif |
#if defined(HAVE_SCHED_SETSCHEDULER) |
# ifdef HAVE_SCHED_H |
# include <sched.h> |
# else |
# ifdef HAVE_SYS_SCHED_H |
# include <sys/sched.h> |
# endif |
# endif |
#endif |
#if defined(HAVE_SYS_MMAN_H) |
# include <sys/mman.h> |
#endif |
#ifdef HAVE_TERMIOS_H |
# include <termios.h> |
#endif |
#ifdef SYS_DOMAINOS |
# include <apollo/base.h> |
#endif /* SYS_DOMAINOS */ |
#include "recvbuff.h" |
#include "ntp_cmdargs.h" |
#if 0 /* HMS: I don't think we need this. 961223 */ |
#ifdef LOCK_PROCESS |
# ifdef SYS_SOLARIS |
# include <sys/mman.h> |
# else |
# include <sys/lock.h> |
# endif |
#endif |
#endif |
#ifdef _AIX |
# include <ulimit.h> |
#endif /* _AIX */ |
#ifdef SCO5_CLOCK |
# include <sys/ci/ciioctl.h> |
#endif |
#ifdef HAVE_CLOCKCTL |
# include <ctype.h> |
# include <grp.h> |
# include <pwd.h> |
#endif |
/* |
* Signals we catch for debugging. If not debugging we ignore them. |
*/ |
#define MOREDEBUGSIG SIGUSR1 |
#define LESSDEBUGSIG SIGUSR2 |
/* |
* Signals which terminate us gracefully. |
*/ |
#ifndef SYS_WINNT |
# define SIGDIE1 SIGHUP |
# define SIGDIE3 SIGQUIT |
# define SIGDIE2 SIGINT |
# define SIGDIE4 SIGTERM |
#endif /* SYS_WINNT */ |
#if defined SYS_WINNT |
/* handles for various threads, process, and objects */ |
HANDLE ResolverThreadHandle = NULL; |
/* variables used to inform the Service Control Manager of our current state */ |
BOOL NoWinService = FALSE; |
SERVICE_STATUS ssStatus; |
SERVICE_STATUS_HANDLE sshStatusHandle; |
HANDLE WaitHandles[3] = { NULL, NULL, NULL }; |
char szMsgPath[255]; |
static BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType); |
BOOL init_randfile(); |
#endif /* SYS_WINNT */ |
/* |
* Scheduling priority we run at |
*/ |
#define NTPD_PRIO (-12) |
int priority_done = 2; /* 0 - Set priority */ |
/* 1 - priority is OK where it is */ |
/* 2 - Don't set priority */ |
/* 1 and 2 are pretty much the same */ |
/* |
* Debugging flag |
*/ |
volatile int debug; |
/* |
* Set the processing not to be in the forground |
*/ |
int forground_process = FALSE; |
/* |
* No-fork flag. If set, we do not become a background daemon. |
*/ |
int nofork; |
#ifdef HAVE_CLOCKCTL |
char *user = NULL; /* User to switch to */ |
char *group = NULL; /* group to switch to */ |
char *chrootdir = NULL; /* directory to chroot to */ |
int sw_uid; |
int sw_gid; |
char *endp; |
struct group *gr; |
struct passwd *pw; |
#endif /* HAVE_CLOCKCTL */ |
/* |
* Initializing flag. All async routines watch this and only do their |
* thing when it is clear. |
*/ |
int initializing; |
/* |
* Version declaration |
*/ |
extern const char *Version; |
int was_alarmed; |
#ifdef DECL_SYSCALL |
/* |
* We put this here, since the argument profile is syscall-specific |
*/ |
extern int syscall P((int, ...)); |
#endif /* DECL_SYSCALL */ |
#ifdef SIGDIE2 |
static RETSIGTYPE finish P((int)); |
#endif /* SIGDIE2 */ |
#ifdef DEBUG |
#ifndef SYS_WINNT |
static RETSIGTYPE moredebug P((int)); |
static RETSIGTYPE lessdebug P((int)); |
#endif |
#else /* not DEBUG */ |
static RETSIGTYPE no_debug P((int)); |
#endif /* not DEBUG */ |
int ntpdmain P((int, char **)); |
static void set_process_priority P((void)); |
#ifdef SIM |
int |
main( |
int argc, |
char *argv[] |
) |
{ |
return ntpsim(argc, argv); |
} |
#else /* SIM */ |
#ifdef NO_MAIN_ALLOWED |
CALL(ntpd,"ntpd",ntpdmain); |
#else |
int |
main( |
int argc, |
char *argv[] |
) |
{ |
return ntpdmain(argc, argv); |
} |
#endif |
#endif /* SIM */ |
#ifdef _AIX |
/* |
* OK. AIX is different than solaris in how it implements plock(). |
* If you do NOT adjust the stack limit, you will get the MAXIMUM |
* stack size allocated and PINNED with you program. To check the |
* value, use ulimit -a. |
* |
* To fix this, we create an automatic variable and set our stack limit |
* to that PLUS 32KB of extra space (we need some headroom). |
* |
* This subroutine gets the stack address. |
* |
* Grover Davidson and Matt Ladendorf |
* |
*/ |
static char * |
get_aix_stack(void) |
{ |
char ch; |
return (&ch); |
} |
/* |
* Signal handler for SIGDANGER. |
*/ |
static void |
catch_danger(int signo) |
{ |
msyslog(LOG_INFO, "ntpd: setpgid(): %m"); |
/* Make the system believe we'll free something, but don't do it! */ |
return; |
} |
#endif /* _AIX */ |
/* |
* Set the process priority |
*/ |
static void |
set_process_priority(void) |
{ |
#ifdef DEBUG |
if (debug > 1) |
msyslog(LOG_DEBUG, "set_process_priority: %s: priority_done is <%d>", |
((priority_done) |
? "Leave priority alone" |
: "Attempt to set priority" |
), |
priority_done); |
#endif /* DEBUG */ |
#ifdef SYS_WINNT |
priority_done += NT_set_process_priority(); |
#endif |
#if defined(HAVE_SCHED_SETSCHEDULER) |
if (!priority_done) { |
extern int config_priority_override, config_priority; |
int pmax, pmin; |
struct sched_param sched; |
pmax = sched_get_priority_max(SCHED_FIFO); |
sched.sched_priority = pmax; |
if ( config_priority_override ) { |
pmin = sched_get_priority_min(SCHED_FIFO); |
if ( config_priority > pmax ) |
sched.sched_priority = pmax; |
else if ( config_priority < pmin ) |
sched.sched_priority = pmin; |
else |
sched.sched_priority = config_priority; |
} |
if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 ) |
msyslog(LOG_ERR, "sched_setscheduler(): %m"); |
else |
++priority_done; |
} |
#endif /* HAVE_SCHED_SETSCHEDULER */ |
#if defined(HAVE_RTPRIO) |
# ifdef RTP_SET |
if (!priority_done) { |
struct rtprio srtp; |
srtp.type = RTP_PRIO_REALTIME; /* was: RTP_PRIO_NORMAL */ |
srtp.prio = 0; /* 0 (hi) -> RTP_PRIO_MAX (31,lo) */ |
if (rtprio(RTP_SET, getpid(), &srtp) < 0) |
msyslog(LOG_ERR, "rtprio() error: %m"); |
else |
++priority_done; |
} |
# else /* not RTP_SET */ |
if (!priority_done) { |
if (rtprio(0, 120) < 0) |
msyslog(LOG_ERR, "rtprio() error: %m"); |
else |
++priority_done; |
} |
# endif /* not RTP_SET */ |
#endif /* HAVE_RTPRIO */ |
#if defined(NTPD_PRIO) && NTPD_PRIO != 0 |
# ifdef HAVE_ATT_NICE |
if (!priority_done) { |
errno = 0; |
if (-1 == nice (NTPD_PRIO) && errno != 0) |
msyslog(LOG_ERR, "nice() error: %m"); |
else |
++priority_done; |
} |
# endif /* HAVE_ATT_NICE */ |
# ifdef HAVE_BSD_NICE |
if (!priority_done) { |
if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO)) |
msyslog(LOG_ERR, "setpriority() error: %m"); |
else |
++priority_done; |
} |
# endif /* HAVE_BSD_NICE */ |
#endif /* NTPD_PRIO && NTPD_PRIO != 0 */ |
if (!priority_done) |
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority"); |
} |
/* |
* Main program. Initialize us, disconnect us from the tty if necessary, |
* and loop waiting for I/O and/or timer expiries. |
*/ |
int |
ntpdmain( |
int argc, |
char *argv[] |
) |
{ |
l_fp now; |
char *cp; |
struct recvbuf *rbuflist; |
struct recvbuf *rbuf; |
#ifdef _AIX /* HMS: ifdef SIGDANGER? */ |
struct sigaction sa; |
#endif |
initializing = 1; /* mark that we are initializing */ |
debug = 0; /* no debugging by default */ |
nofork = 0; /* will fork by default */ |
#ifdef HAVE_UMASK |
{ |
mode_t uv; |
uv = umask(0); |
if(uv) |
(void) umask(uv); |
else |
(void) umask(022); |
} |
#endif |
#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */ |
{ |
uid_t uid; |
uid = getuid(); |
if (uid) |
{ |
msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid); |
exit(1); |
} |
} |
#endif |
#ifdef SYS_WINNT |
/* Set the Event-ID message-file name. */ |
if (!GetModuleFileName(NULL, szMsgPath, sizeof(szMsgPath))) { |
msyslog(LOG_ERR, "GetModuleFileName(PGM_EXE_FILE) failed: %m\n"); |
exit(1); |
} |
addSourceToRegistry("NTP", szMsgPath); |
#endif |
getstartup(argc, argv); /* startup configuration, may set debug */ |
if (debug) |
printf("%s\n", Version); |
/* |
* Initialize random generator and public key pair |
*/ |
#ifdef SYS_WINNT |
/* Initialize random file before OpenSSL checks */ |
if(!init_randfile()) |
msyslog(LOG_ERR, "Unable to initialize .rnd file\n"); |
#endif |
get_systime(&now); |
SRANDOM((int)(now.l_i * now.l_uf)); |
#if !defined(VMS) |
# ifndef NODETACH |
/* |
* Detach us from the terminal. May need an #ifndef GIZMO. |
*/ |
# ifdef DEBUG |
if (!debug && !nofork) |
# else /* DEBUG */ |
if (!nofork) |
# endif /* DEBUG */ |
{ |
# ifndef SYS_WINNT |
# ifdef HAVE_DAEMON |
daemon(0, 0); |
# else /* not HAVE_DAEMON */ |
if (fork()) /* HMS: What about a -1? */ |
exit(0); |
{ |
#if !defined(F_CLOSEM) |
u_long s; |
int max_fd; |
#endif /* not F_CLOSEM */ |
#if defined(F_CLOSEM) |
/* |
* From 'Writing Reliable AIX Daemons,' SG24-4946-00, |
* by Eric Agar (saves us from doing 32767 system |
* calls) |
*/ |
if (fcntl(0, F_CLOSEM, 0) == -1) |
msyslog(LOG_ERR, "ntpd: failed to close open files(): %m"); |
#else /* not F_CLOSEM */ |
# if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) |
max_fd = sysconf(_SC_OPEN_MAX); |
# else /* HAVE_SYSCONF && _SC_OPEN_MAX */ |
max_fd = getdtablesize(); |
# endif /* HAVE_SYSCONF && _SC_OPEN_MAX */ |
for (s = 0; s < max_fd; s++) |
(void) close((int)s); |
#endif /* not F_CLOSEM */ |
(void) open("/", 0); |
(void) dup2(0, 1); |
(void) dup2(0, 2); |
#ifdef SYS_DOMAINOS |
{ |
uid_$t puid; |
status_$t st; |
proc2_$who_am_i(&puid); |
proc2_$make_server(&puid, &st); |
} |
#endif /* SYS_DOMAINOS */ |
#if defined(HAVE_SETPGID) || defined(HAVE_SETSID) |
# ifdef HAVE_SETSID |
if (setsid() == (pid_t)-1) |
msyslog(LOG_ERR, "ntpd: setsid(): %m"); |
# else |
if (setpgid(0, 0) == -1) |
msyslog(LOG_ERR, "ntpd: setpgid(): %m"); |
# endif |
#else /* HAVE_SETPGID || HAVE_SETSID */ |
{ |
# if defined(TIOCNOTTY) |
int fid; |
fid = open("/dev/tty", 2); |
if (fid >= 0) |
{ |
(void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0); |
(void) close(fid); |
} |
# endif /* defined(TIOCNOTTY) */ |
# ifdef HAVE_SETPGRP_0 |
(void) setpgrp(); |
# else /* HAVE_SETPGRP_0 */ |
(void) setpgrp(0, getpid()); |
# endif /* HAVE_SETPGRP_0 */ |
} |
#endif /* HAVE_SETPGID || HAVE_SETSID */ |
#ifdef _AIX |
/* Don't get killed by low-on-memory signal. */ |
sa.sa_handler = catch_danger; |
sigemptyset(&sa.sa_mask); |
sa.sa_flags = SA_RESTART; |
(void) sigaction(SIGDANGER, &sa, NULL); |
#endif /* _AIX */ |
} |
# endif /* not HAVE_DAEMON */ |
# else /* SYS_WINNT */ |
{ |
if (NoWinService == FALSE) { |
SERVICE_TABLE_ENTRY dispatchTable[] = { |
{ TEXT("NetworkTimeProtocol"), (LPSERVICE_MAIN_FUNCTION)service_main }, |
{ NULL, NULL } |
}; |
/* daemonize */ |
if (!StartServiceCtrlDispatcher(dispatchTable)) |
{ |
msyslog(LOG_ERR, "StartServiceCtrlDispatcher: %m"); |
ExitProcess(2); |
} |
} |
else { |
service_main(argc, argv); |
return 0; |
} |
} |
# endif /* SYS_WINNT */ |
} |
# endif /* NODETACH */ |
# if defined(SYS_WINNT) && !defined(NODETACH) |
else |
service_main(argc, argv); |
return 0; /* must return a value */ |
} /* end main */ |
/* |
* If this runs as a service under NT, the main thread will block at |
* StartServiceCtrlDispatcher() and another thread will be started by the |
* Service Control Dispatcher which will begin execution at the routine |
* specified in that call (viz. service_main) |
*/ |
void |
service_main( |
DWORD argc, |
LPTSTR *argv |
) |
{ |
char *cp; |
struct recvbuf *rbuflist; |
struct recvbuf *rbuf; |
if(!debug && NoWinService == FALSE) |
{ |
/* register our service control handler */ |
sshStatusHandle = RegisterServiceCtrlHandler( TEXT("NetworkTimeProtocol"), |
(LPHANDLER_FUNCTION)service_ctrl); |
if(sshStatusHandle == 0) |
{ |
msyslog(LOG_ERR, "RegisterServiceCtrlHandler failed: %m"); |
return; |
} |
/* report pending status to Service Control Manager */ |
ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; |
ssStatus.dwCurrentState = SERVICE_START_PENDING; |
ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
ssStatus.dwServiceSpecificExitCode = 0; |
ssStatus.dwCheckPoint = 1; |
ssStatus.dwWaitHint = 5000; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
return; |
} |
} /* debug */ |
# endif /* defined(SYS_WINNT) && !defined(NODETACH) */ |
#endif /* VMS */ |
/* |
* Logging. This may actually work on the gizmo board. Find a name |
* to log with by using the basename of argv[0] |
*/ |
cp = strrchr(argv[0], '/'); |
if (cp == 0) |
cp = argv[0]; |
else |
cp++; |
debug = 0; /* will be immediately re-initialized 8-( */ |
getstartup(argc, argv); /* startup configuration, catch logfile this time */ |
#if !defined(VMS) |
# ifndef LOG_DAEMON |
openlog(cp, LOG_PID); |
# else /* LOG_DAEMON */ |
# ifndef LOG_NTP |
# define LOG_NTP LOG_DAEMON |
# endif |
openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP); |
# ifdef DEBUG |
if (debug) |
setlogmask(LOG_UPTO(LOG_DEBUG)); |
else |
# endif /* DEBUG */ |
setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */ |
# endif /* LOG_DAEMON */ |
#endif /* !SYS_WINNT && !VMS */ |
NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */ |
msyslog(LOG_NOTICE, "%s", Version); |
#ifdef SYS_WINNT |
/* GMS 1/18/1997 |
* TODO: lock the process in memory using SetProcessWorkingSetSize() and VirtualLock() functions |
* |
process_handle = GetCurrentProcess(); |
if (SetProcessWorkingSetSize(process_handle, 2097152 , 4194304 ) == TRUE) { |
if (VirtualLock(0 , 4194304) == FALSE) |
msyslog(LOG_ERR, "VirtualLock() failed: %m"); |
} else { |
msyslog(LOG_ERR, "SetProcessWorkingSetSize() failed: %m"); |
} |
*/ |
#endif /* SYS_WINNT */ |
#ifdef SCO5_CLOCK |
/* |
* SCO OpenServer's system clock offers much more precise timekeeping |
* on the base CPU than the other CPUs (for multiprocessor systems), |
* so we must lock to the base CPU. |
*/ |
{ |
int fd = open("/dev/at1", O_RDONLY); |
if (fd >= 0) { |
int zero = 0; |
if (ioctl(fd, ACPU_LOCK, &zero) < 0) |
msyslog(LOG_ERR, "cannot lock to base CPU: %m\n"); |
close( fd ); |
} /* else ... |
* If we can't open the device, this probably just isn't |
* a multiprocessor system, so we're A-OK. |
*/ |
} |
#endif |
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE) |
# ifdef HAVE_SETRLIMIT |
/* |
* Set the stack limit to something smaller, so that we don't lock a lot |
* of unused stack memory. |
*/ |
{ |
struct rlimit rl; |
if (getrlimit(RLIMIT_STACK, &rl) != -1 |
&& (rl.rlim_cur = 20 * 4096) < rl.rlim_max) |
{ |
if (setrlimit(RLIMIT_STACK, &rl) == -1) |
{ |
msyslog(LOG_ERR, |
"Cannot adjust stack limit for mlockall: %m"); |
} |
} |
} |
# endif /* HAVE_SETRLIMIT */ |
/* |
* lock the process into memory |
*/ |
if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) |
msyslog(LOG_ERR, "mlockall(): %m"); |
#else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */ |
# ifdef HAVE_PLOCK |
# ifdef PROCLOCK |
# ifdef _AIX |
/* |
* set the stack limit for AIX for plock(). |
* see get_aix_stack for more info. |
*/ |
if (ulimit(SET_STACKLIM, (get_aix_stack() - 8*4096)) < 0) |
{ |
msyslog(LOG_ERR,"Cannot adjust stack limit for plock on AIX: %m"); |
} |
# endif /* _AIX */ |
/* |
* lock the process into memory |
*/ |
if (plock(PROCLOCK) < 0) |
msyslog(LOG_ERR, "plock(PROCLOCK): %m"); |
# else /* not PROCLOCK */ |
# ifdef TXTLOCK |
/* |
* Lock text into ram |
*/ |
if (plock(TXTLOCK) < 0) |
msyslog(LOG_ERR, "plock(TXTLOCK) error: %m"); |
# else /* not TXTLOCK */ |
msyslog(LOG_ERR, "plock() - don't know what to lock!"); |
# endif /* not TXTLOCK */ |
# endif /* not PROCLOCK */ |
# endif /* HAVE_PLOCK */ |
#endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */ |
/* |
* Set up signals we pay attention to locally. |
*/ |
#ifdef SIGDIE1 |
(void) signal_no_reset(SIGDIE1, finish); |
#endif /* SIGDIE1 */ |
#ifdef SIGDIE2 |
(void) signal_no_reset(SIGDIE2, finish); |
#endif /* SIGDIE2 */ |
#ifdef SIGDIE3 |
(void) signal_no_reset(SIGDIE3, finish); |
#endif /* SIGDIE3 */ |
#ifdef SIGDIE4 |
(void) signal_no_reset(SIGDIE4, finish); |
#endif /* SIGDIE4 */ |
#ifdef SIGBUS |
(void) signal_no_reset(SIGBUS, finish); |
#endif /* SIGBUS */ |
#if !defined(SYS_WINNT) && !defined(VMS) |
# ifdef DEBUG |
(void) signal_no_reset(MOREDEBUGSIG, moredebug); |
(void) signal_no_reset(LESSDEBUGSIG, lessdebug); |
# else |
(void) signal_no_reset(MOREDEBUGSIG, no_debug); |
(void) signal_no_reset(LESSDEBUGSIG, no_debug); |
# endif /* DEBUG */ |
#endif /* !SYS_WINNT && !VMS */ |
/* |
* Set up signals we should never pay attention to. |
*/ |
#if defined SIGPIPE |
(void) signal_no_reset(SIGPIPE, SIG_IGN); |
#endif /* SIGPIPE */ |
#if defined SYS_WINNT |
if (!SetConsoleCtrlHandler(OnConsoleEvent, TRUE)) { |
msyslog(LOG_ERR, "Can't set console control handler: %m"); |
} |
#endif |
/* |
* Call the init_ routines to initialize the data structures. |
*/ |
#if defined (HAVE_IO_COMPLETION_PORT) |
init_io_completion_port(); |
init_winnt_time(); |
#endif |
init_auth(); |
init_util(); |
init_restrict(); |
init_mon(); |
init_timer(); |
init_lib(); |
init_random(); |
init_request(); |
init_control(); |
init_peer(); |
#ifdef REFCLOCK |
init_refclock(); |
#endif |
set_process_priority(); |
init_proto(); /* Call at high priority */ |
init_io(); |
init_loopfilter(); |
mon_start(MON_ON); /* monitor on by default now */ |
/* turn off in config if unwanted */ |
/* |
* Get configuration. This (including argument list parsing) is |
* done in a separate module since this will definitely be different |
* for the gizmo board. While at it, save the host name for later |
* along with the length. The crypto needs this. |
*/ |
#ifdef DEBUG |
debug = 0; |
#endif |
getconfig(argc, argv); |
#ifdef OPENSSL |
crypto_setup(); |
#endif /* OPENSSL */ |
initializing = 0; |
#if defined(SYS_WINNT) && !defined(NODETACH) |
# if defined(DEBUG) |
if(!debug) |
{ |
# endif |
if (NoWinService == FALSE) { |
/* report to the service control manager that the service is running */ |
ssStatus.dwCurrentState = SERVICE_RUNNING; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
if (ResolverThreadHandle != NULL) |
CloseHandle(ResolverThreadHandle); |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
return; |
} |
} |
# if defined(DEBUG) |
} |
# endif |
#endif |
#ifdef HAVE_CLOCKCTL |
/* |
* Drop super-user privileges and chroot now if the OS supports |
* non root clock control (only NetBSD for now). |
*/ |
if (user != NULL) { |
if (isdigit((unsigned char)*user)) { |
sw_uid = (uid_t)strtoul(user, &endp, 0); |
if (*endp != '\0') |
goto getuser; |
} else { |
getuser: |
if ((pw = getpwnam(user)) != NULL) { |
sw_uid = pw->pw_uid; |
} else { |
errno = 0; |
msyslog(LOG_ERR, "Cannot find user `%s'", user); |
exit (-1); |
} |
} |
} |
if (group != NULL) { |
if (isdigit((unsigned char)*group)) { |
sw_gid = (gid_t)strtoul(group, &endp, 0); |
if (*endp != '\0') |
goto getgroup; |
} else { |
getgroup: |
if ((gr = getgrnam(group)) != NULL) { |
sw_gid = pw->pw_gid; |
} else { |
errno = 0; |
msyslog(LOG_ERR, "Cannot find group `%s'", group); |
exit (-1); |
} |
} |
} |
if (chrootdir && chroot(chrootdir)) { |
msyslog(LOG_ERR, "Cannot chroot to `%s': %m", chrootdir); |
exit (-1); |
} |
if (group && setgid(sw_gid)) { |
msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group); |
exit (-1); |
} |
if (group && setegid(sw_gid)) { |
msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group); |
exit (-1); |
} |
if (user && setuid(sw_uid)) { |
msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user); |
exit (-1); |
} |
if (user && seteuid(sw_uid)) { |
msyslog(LOG_ERR, "Cannot seteuid() to user `%s': %m", user); |
exit (-1); |
} |
#endif |
/* |
* Report that we're up to any trappers |
*/ |
report_event(EVNT_SYSRESTART, (struct peer *)0); |
/* |
* Use select() on all on all input fd's for unlimited |
* time. select() will terminate on SIGALARM or on the |
* reception of input. Using select() means we can't do |
* robust signal handling and we get a potential race |
* between checking for alarms and doing the select(). |
* Mostly harmless, I think. |
*/ |
/* On VMS, I suspect that select() can't be interrupted |
* by a "signal" either, so I take the easy way out and |
* have select() time out after one second. |
* System clock updates really aren't time-critical, |
* and - lacking a hardware reference clock - I have |
* yet to learn about anything else that is. |
*/ |
#if defined(HAVE_IO_COMPLETION_PORT) |
WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit reques */ |
WaitHandles[1] = get_timer_handle(); |
WaitHandles[2] = get_io_event(); |
for (;;) { |
DWORD Index = WaitForMultipleObjectsEx(sizeof(WaitHandles)/sizeof(WaitHandles[0]), WaitHandles, FALSE, 1000, TRUE); |
switch (Index) { |
case WAIT_OBJECT_0 + 0 : /* exit request */ |
exit(0); |
break; |
case WAIT_OBJECT_0 + 1 : /* timer */ |
timer(); |
break; |
case WAIT_OBJECT_0 + 2 : /* Io event */ |
# ifdef DEBUG |
if ( debug > 3 ) |
{ |
printf( "IoEvent occurred\n" ); |
} |
# endif |
break; |
case WAIT_IO_COMPLETION : /* loop */ |
case WAIT_TIMEOUT : |
break; |
case WAIT_FAILED: |
msyslog(LOG_ERR, "ntpdc: WaitForMultipleObjectsEx Failed: Error: %m"); |
break; |
/* For now do nothing if not expected */ |
default: |
break; |
} /* switch */ |
rbuflist = getrecvbufs(); /* get received buffers */ |
#else /* normal I/O */ |
was_alarmed = 0; |
rbuflist = (struct recvbuf *)0; |
for (;;) |
{ |
# if !defined(HAVE_SIGNALED_IO) |
extern fd_set activefds; |
extern int maxactivefd; |
fd_set rdfdes; |
int nfound; |
# elif defined(HAVE_SIGNALED_IO) |
block_io_and_alarm(); |
# endif |
rbuflist = getrecvbufs(); /* get received buffers */ |
if (alarm_flag) /* alarmed? */ |
{ |
was_alarmed = 1; |
alarm_flag = 0; |
} |
if (!was_alarmed && rbuflist == (struct recvbuf *)0) |
{ |
/* |
* Nothing to do. Wait for something. |
*/ |
# ifndef HAVE_SIGNALED_IO |
rdfdes = activefds; |
# if defined(VMS) || defined(SYS_VXWORKS) |
/* make select() wake up after one second */ |
{ |
struct timeval t1; |
t1.tv_sec = 1; t1.tv_usec = 0; |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
(fd_set *)0, &t1); |
} |
# else |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
(fd_set *)0, (struct timeval *)0); |
# endif /* VMS */ |
if (nfound > 0) |
{ |
l_fp ts; |
get_systime(&ts); |
(void)input_handler(&ts); |
} |
else if (nfound == -1 && errno != EINTR) |
msyslog(LOG_ERR, "select() error: %m"); |
# ifdef DEBUG |
else if (debug > 2) |
msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound); |
# endif /* DEBUG */ |
# else /* HAVE_SIGNALED_IO */ |
wait_for_signal(); |
# endif /* HAVE_SIGNALED_IO */ |
if (alarm_flag) /* alarmed? */ |
{ |
was_alarmed = 1; |
alarm_flag = 0; |
} |
rbuflist = getrecvbufs(); /* get received buffers */ |
} |
# ifdef HAVE_SIGNALED_IO |
unblock_io_and_alarm(); |
# endif /* HAVE_SIGNALED_IO */ |
/* |
* Out here, signals are unblocked. Call timer routine |
* to process expiry. |
*/ |
if (was_alarmed) |
{ |
timer(); |
was_alarmed = 0; |
} |
#endif /* HAVE_IO_COMPLETION_PORT */ |
/* |
* Call the data procedure to handle each received |
* packet. |
*/ |
while (rbuflist != (struct recvbuf *)0) |
{ |
rbuf = rbuflist; |
rbuflist = rbuf->next; |
(rbuf->receiver)(rbuf); |
freerecvbuf(rbuf); |
} |
#if defined DEBUG && defined SYS_WINNT |
if (debug > 4) |
printf("getrecvbufs: %ld handler interrupts, %ld frames\n", |
handler_calls, handler_pkts); |
#endif |
/* |
* Go around again |
*/ |
} |
#ifndef SYS_WINNT |
exit(1); /* unreachable */ |
#endif |
#ifndef SYS_WINNT |
return 1; /* DEC OSF cc braindamage */ |
#endif |
} |
#ifdef SIGDIE2 |
/* |
* finish - exit gracefully |
*/ |
static RETSIGTYPE |
finish( |
int sig |
) |
{ |
msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig); |
switch (sig) |
{ |
# ifdef SIGBUS |
case SIGBUS: |
printf("\nfinish(SIGBUS)\n"); |
exit(0); |
# endif |
case 0: /* Should never happen... */ |
return; |
default: |
exit(0); |
} |
} |
#endif /* SIGDIE2 */ |
#ifdef DEBUG |
#ifndef SYS_WINNT |
/* |
* moredebug - increase debugging verbosity |
*/ |
static RETSIGTYPE |
moredebug( |
int sig |
) |
{ |
int saved_errno = errno; |
if (debug < 255) |
{ |
debug++; |
msyslog(LOG_DEBUG, "debug raised to %d", debug); |
} |
errno = saved_errno; |
} |
/* |
* lessdebug - decrease debugging verbosity |
*/ |
static RETSIGTYPE |
lessdebug( |
int sig |
) |
{ |
int saved_errno = errno; |
if (debug > 0) |
{ |
debug--; |
msyslog(LOG_DEBUG, "debug lowered to %d", debug); |
} |
errno = saved_errno; |
} |
#endif |
#else /* not DEBUG */ |
#ifndef SYS_WINNT/* |
* no_debug - We don't do the debug here. |
*/ |
static RETSIGTYPE |
no_debug( |
int sig |
) |
{ |
int saved_errno = errno; |
msyslog(LOG_DEBUG, "ntpd not compiled for debugging (signal %d)", sig); |
errno = saved_errno; |
} |
#endif /* not SYS_WINNT */ |
#endif /* not DEBUG */ |
#ifdef SYS_WINNT |
/* service_ctrl - control handler for NTP service |
* signals the service_main routine of start/stop requests |
* from the control panel or other applications making |
* win32API calls |
*/ |
void |
service_ctrl( |
DWORD dwCtrlCode |
) |
{ |
DWORD dwState = SERVICE_RUNNING; |
/* Handle the requested control code */ |
switch(dwCtrlCode) |
{ |
case SERVICE_CONTROL_PAUSE: |
/* see no reason to support this */ |
break; |
case SERVICE_CONTROL_CONTINUE: |
/* see no reason to support this */ |
break; |
case SERVICE_CONTROL_STOP: |
dwState = SERVICE_STOP_PENDING; |
/* |
* Report the status, specifying the checkpoint and waithint, |
* before setting the termination event. |
*/ |
ssStatus.dwCurrentState = dwState; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
ssStatus.dwWaitHint = 3000; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
} |
if (WaitHandles[0] != NULL) { |
SetEvent(WaitHandles[0]); |
} |
return; |
case SERVICE_CONTROL_INTERROGATE: |
/* Update the service status */ |
break; |
default: |
/* invalid control code */ |
break; |
} |
ssStatus.dwCurrentState = dwState; |
ssStatus.dwWin32ExitCode = NO_ERROR; |
if (!SetServiceStatus(sshStatusHandle, &ssStatus)) |
{ |
msyslog(LOG_ERR, "SetServiceStatus: %m"); |
} |
} |
static BOOL WINAPI |
OnConsoleEvent( |
DWORD dwCtrlType |
) |
{ |
switch (dwCtrlType) { |
case CTRL_BREAK_EVENT : |
if (debug > 0) { |
debug <<= 1; |
} |
else { |
debug = 1; |
} |
if (debug > 8) { |
debug = 0; |
} |
printf("debug level %d\n", debug); |
break ; |
case CTRL_C_EVENT : |
case CTRL_CLOSE_EVENT : |
case CTRL_SHUTDOWN_EVENT : |
if (WaitHandles[0] != NULL) { |
SetEvent(WaitHandles[0]); |
} |
break; |
default : |
return FALSE; |
} |
return TRUE;; |
} |
/* |
* NT version of exit() - all calls to exit() should be routed to |
* this function. |
*/ |
void |
service_exit( |
int status |
) |
{ |
if (!debug) { /* did not become a service, simply exit */ |
/* service mode, need to have the service_main routine |
* register with the service control manager that the |
* service has stopped running, before exiting |
*/ |
ssStatus.dwCurrentState = SERVICE_STOPPED; |
SetServiceStatus(sshStatusHandle, &ssStatus); |
} |
uninit_io_completion_port(); |
reset_winnt_time(); |
# if defined _MSC_VER |
_CrtDumpMemoryLeaks(); |
# endif |
#undef exit |
exit(status); |
} |
#endif /* SYS_WINNT */ |
/FreeBSD/mac_settime/trunk/bin/clear_src.sh |
---|
0,0 → 1,31 |
#!/bin/sh |
# |
# delete our patches from /usr/src |
# to prepare for system update |
# |
# to update the system run as root |
# ./clear_src.sh && cvsup src_update && ./copy_orig.sh && ./update_src.sh |
# |
# then run ./get_diffs.sh as user and examine the diffs |
# |
PATCHED_FILES_KERN="sys/kern/kern_time.c sys/kern/kern_ntptime.c" |
PATCHED_FILES_MODULE="sys/conf/files sys/modules/Makefile" |
PATCHED_FILES_NTP="contrib/ntp/ntpd/ntpd.c" |
BIN_DIR=`dirname $0` |
SRCDIR=/usr/src |
for f in ${PATCHED_FILES_KERN} ; do |
rm "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
for f in ${PATCHED_FILES_MODULE} ; do |
rm "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
for f in ${PATCHED_FILES_NTP} ; do |
rm "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/FreeBSD/mac_settime/trunk/bin/update_src.sh |
---|
0,0 → 1,19 |
#!/bin/sh |
# |
# copy our version of files to system |
# |
# to update the system run as root |
# ./clear_src.sh && cvsup src_update && ./copy_orig.sh && ./update_src.sh |
# |
# then run ./get_diffs.sh as user and examine the diffs |
# |
BIN_DIR=`dirname $0` |
BASE_DIR="${BIN_DIR}/.." |
cp ${BASE_DIR}/src/kern/* /usr/src/sys/kern |
cp ${BASE_DIR}/src/module/files /usr/src/sys/conf/files |
cp ${BASE_DIR}/src/module/Makefile.modules /usr/src/sys/modules/Makefile |
cp ${BASE_DIR}/src/ntp/ntpd.c /usr/src/contrib/ntp/ntpd/ntpd.c |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/FreeBSD/mac_settime/trunk/bin/copy_orig.sh |
---|
0,0 → 1,31 |
#!/bin/sh |
# |
# make copy of all standard files in /usr/src |
# which we want to work on to get diffs later |
# |
# to update the system run as root |
# ./clear_src.sh && cvsup src_update && ./copy_orig.sh && ./update_src.sh |
# |
# then run ./get_diffs.sh as user and examine the diffs |
# |
PATCHED_FILES_KERN="sys/kern/kern_time.c sys/kern/kern_ntptime.c" |
PATCHED_FILES_MODULE="sys/conf/files sys/modules/Makefile" |
PATCHED_FILES_NTP="contrib/ntp/ntpd/ntpd.c" |
BIN_DIR=`dirname $0` |
SRCDIR=/usr/src |
for f in ${PATCHED_FILES_KERN} ; do |
cp "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
for f in ${PATCHED_FILES_MODULE} ; do |
cp "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
for f in ${PATCHED_FILES_NTP} ; do |
cp "${SRCDIR}/$f" "${SRCDIR}/$f.orig" |
done |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/FreeBSD/mac_settime/trunk/bin/get_diff.sh |
---|
0,0 → 1,27 |
#!/bin/sh |
PATCHED_FILES_KERN="sys/kern/kern_time.c sys/kern/kern_ntptime.c" |
PATCHED_FILES_MODULE="sys/conf/files sys/modules/Makefile" |
PATCHED_FILES_NTP="contrib/ntp/ntpd/ntpd.c" |
BIN_DIR=`dirname $0` |
OUTDIR="${BIN_DIR}/../output" |
SRCDIR=/usr/src |
mkdir -p ${OUTDIR} |
rm -f ${OUTDIR}/kern_settime.patch |
for f in ${PATCHED_FILES_KERN} ; do |
(cd ${SRCDIR}; diff -u $f.orig $f) >> ${OUTDIR}/kern_settime.patch |
done |
rm -f ${OUTDIR}/modules.patch |
for f in ${PATCHED_FILES_MODULE} ; do |
(cd ${SRCDIR}; diff -u $f.orig $f) >> ${OUTDIR}/modules.patch |
done |
rm -f ${OUTDIR}/ntp.patch |
for f in ${PATCHED_FILES_NTP} ; do |
(cd ${SRCDIR}; diff -u $f.orig $f) >> ${OUTDIR}/ntp.patch |
done |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/FreeBSD/mac_settime/trunk |
---|
Property changes: |
Added: svn:ignore |
+output |