-/* $OpenBSD: ntp.c,v 1.130 2015/03/02 10:31:17 bcook Exp $ */
+/* $OpenBSD: ntp.c,v 1.131 2015/05/20 13:32:39 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
#include "ntpd.h"
#define PFD_PIPE_MAIN 0
-#define PFD_HOTPLUG 1
-#define PFD_PIPE_DNS 2
-#define PFD_SOCK_CTL 3
-#define PFD_MAX 4
+#define PFD_PIPE_DNS 1
+#define PFD_SOCK_CTL 2
+#define PFD_MAX 3
volatile sig_atomic_t ntp_quit = 0;
volatile sig_atomic_t ntp_report = 0;
struct passwd *pw)
{
int a, b, nfds, i, j, idx_peers, timeout;
- int hotplugfd, nullfd, pipe_dns[2], idx_clients;
+ int nullfd, pipe_dns[2], idx_clients;
int ctls;
u_int pfd_elms = 0, idx2peer_elms = 0;
u_int listener_cnt, new_cnt, sent_cnt, trial_cnt;
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
fatal(NULL);
- hotplugfd = sensor_hotplugfd();
close(pipe_prnt[0]);
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1)
nextaction = getmonotime() + 3600;
pfd[PFD_PIPE_MAIN].fd = ibuf_main->fd;
pfd[PFD_PIPE_MAIN].events = POLLIN;
- pfd[PFD_HOTPLUG].fd = hotplugfd;
- pfd[PFD_HOTPLUG].events = POLLIN;
pfd[PFD_PIPE_DNS].fd = ibuf_dns->fd;
pfd[PFD_PIPE_DNS].events = POLLIN;
pfd[PFD_SOCK_CTL].fd = fd_ctl;
ctl_cnt += control_accept(fd_ctl);
}
- if (nfds > 0 && pfd[PFD_HOTPLUG].revents & (POLLIN|POLLERR)) {
- nfds--;
- sensor_hotplugevent(hotplugfd);
- }
-
for (j = PFD_MAX; nfds > 0 && j < idx_peers; j++)
if (pfd[j].revents & (POLLIN|POLLERR)) {
nfds--;
-/* $OpenBSD: ntpd.h,v 1.120 2015/05/17 18:31:32 reyk Exp $ */
+/* $OpenBSD: ntpd.h,v 1.121 2015/05/20 13:32:39 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
void sensor_init(void);
int sensor_scan(void);
void sensor_query(struct ntp_sensor *);
-int sensor_hotplugfd(void);
-void sensor_hotplugevent(int);
/* ntp_dns.c */
pid_t ntp_dns(int[2], struct ntpd_conf *, struct passwd *);
-/* $OpenBSD: sensors.c,v 1.49 2015/01/09 07:35:37 deraadt Exp $ */
+/* $OpenBSD: sensors.c,v 1.50 2015/05/20 13:32:39 reyk Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
#include <sys/sensors.h>
#include <sys/sysctl.h>
#include <sys/device.h>
-#include <sys/hotplug.h>
#include <errno.h>
#include <fcntl.h>
#include "ntpd.h"
#define MAXDEVNAMLEN 16
-#define _PATH_DEV_HOTPLUG "/dev/hotplug"
int sensor_probe(int, char *, struct sensor *);
void sensor_add(int, char *);
log_debug("sensor update %s: offset %f", s->device, s->update.offset);
priv_adjtime();
}
-
-int
-sensor_hotplugfd(void)
-{
-#ifdef notyet
- int fd, flags;
-
- if ((fd = open(_PATH_DEV_HOTPLUG, O_RDONLY, 0)) == -1) {
- log_warn("open %s", _PATH_DEV_HOTPLUG);
- return (-1);
- }
-
- if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
- fatal("fcntl F_GETFL");
- flags |= O_NONBLOCK;
- if ((flags = fcntl(fd, F_SETFL, flags)) == -1)
- fatal("fcntl F_SETFL");
-
- return (fd);
-#else
- return (-1);
-#endif
-}
-
-void
-sensor_hotplugevent(int fd)
-{
- struct hotplug_event he;
- ssize_t n;
-
- do {
- if ((n = read(fd, &he, sizeof(he))) == -1 &&
- errno != EINTR && errno != EAGAIN)
- fatal("sensor_hotplugevent read");
-
- if (n == sizeof(he))
- switch (he.he_type) {
- case HOTPLUG_DEVAT:
- if (he.he_devclass == DV_DULL &&
- !strcmp(he.he_devname, "sensordev"))
- sensor_scan();
- break;
- default: /* ignore */
- break;
- }
- else if (n > 0)
- fatal("sensor_hotplugevent: short read");
- } while (n > 0 || (n == -1 && errno == EINTR));
-}