1 $DragonFly: src/usr.sbin/ntpd/patches/Attic/ntpd.c.patch,v 1.7 2005/04/22 08:35:04 joerg Exp $
3 --- ntpd.c.orig 2004-11-09 20:39:54.000000000 +0100
4 +++ ntpd.c 2004-11-09 20:40:48.000000000 +0100
8 #include <sys/socket.h>
9 +#include <sys/sysctl.h>
11 #include <netinet/in.h>
17 -__dead void usage(void);
18 +void usage(void) __dead2;
19 int main(int, char *[]);
20 int check_child(pid_t, const char *);
21 int dispatch_imsg(struct ntpd_conf *);
22 void ntpd_adjtime(double);
23 +void ntpd_adjfreq(double);
24 void ntpd_settime(double);
26 volatile sig_atomic_t quit = 0;
35 - extern char *__progname;
37 - fprintf(stderr, "usage: %s [-dSs] [-f file]\n", __progname);
38 + fprintf(stderr, "usage: %s [-dSs] [-f file]\n", getprogname());
43 memcpy(&d, imsg.data, sizeof(d));
47 + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(d))
48 + fatalx("invalid IMSG_ADJFREQ received");
49 + memcpy(&d, imsg.data, sizeof(d));
53 if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(d))
54 fatalx("invalid IMSG_SETTIME received");
57 ntpd_adjtime(double d)
62 if (d >= (double)LOG_NEGLIGEE / 1000 ||
63 d <= -1 * (double)LOG_NEGLIGEE / 1000)
64 log_info("adjusting local clock by %fs", d);
66 log_debug("adjusting local clock by %fs", d);
68 - if (adjtime(&tv, NULL) == -1)
69 - log_warn("adjtime failed");
72 + if (sysctlbyname("kern.ntp.adjust", NULL, NULL, &adjust,
74 + log_info("adjtime failed");
78 +ntpd_adjfreq(double relfreq)
81 + size_t len = sizeof(curfreq);
83 + if (sysctlbyname("kern.ntp.permanent", &curfreq, &len, NULL, 0) ||
84 + len != sizeof(curfreq)) {
85 + log_warn("adjfreq failed");
89 + curfreq += relfreq * 1e9 * (1ll << 32);
91 + if (sysctlbyname("kern.ntp.permanent", NULL, NULL, &curfreq,
93 + log_warn("adjfreq failed");