diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index 9837d8a4..72f6c96b 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $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 @@ -35,10 +35,9 @@ #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; @@ -81,7 +80,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, 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; @@ -128,7 +127,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, 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) @@ -253,8 +251,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, 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; @@ -406,11 +402,6 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, 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--; diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index 246afcdd..78e16cd9 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $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 @@ -367,8 +367,6 @@ char *print_rtable(int); 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 *); diff --git a/src/usr.sbin/ntpd/sensors.c b/src/usr.sbin/ntpd/sensors.c index 6c5a1314..971276e8 100644 --- a/src/usr.sbin/ntpd/sensors.c +++ b/src/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $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 @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -33,7 +32,6 @@ #include "ntpd.h" #define MAXDEVNAMLEN 16 -#define _PATH_DEV_HOTPLUG "/dev/hotplug" int sensor_probe(int, char *, struct sensor *); void sensor_add(int, char *); @@ -250,52 +248,3 @@ sensor_update(struct ntp_sensor *s) 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)); -}