summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2015-05-20 13:32:39 +0000
committerreyk <reyk@openbsd.org>2015-05-20 13:32:39 +0000
commit7cfabfde9fb353a0a784d88843c391d4cf4d13fb (patch)
treee744f9c81cb7142ac559257c5f09bbe04f334d80
parentUse off_t instead of size_t to pass file size and print it using %lld when (diff)
downloadwireguard-openbsd-7cfabfde9fb353a0a784d88843c391d4cf4d13fb.tar.xz
wireguard-openbsd-7cfabfde9fb353a0a784d88843c391d4cf4d13fb.zip
Remove hotplug(4) sensor support: the code has been disabled by
henning@ 9 years ago because of an issue with the /dev/hotplug device - it does not support multiple readers opening it. Nobody ever cared enough to fix it so it is time to sent the dead code to the Attic. OK henning@ (feeling sad about it), mpi@ and others
-rw-r--r--usr.sbin/ntpd/ntp.c19
-rw-r--r--usr.sbin/ntpd/ntpd.h4
-rw-r--r--usr.sbin/ntpd/sensors.c53
3 files changed, 7 insertions, 69 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 9837d8a4ec1..72f6c96be1e 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/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 <henning@openbsd.org>
@@ -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/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index 246afcdd21b..78e16cd96ff 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/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 <henning@openbsd.org>
@@ -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/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c
index 6c5a13148b8..971276e80e4 100644
--- a/usr.sbin/ntpd/sensors.c
+++ b/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 <henning@openbsd.org>
@@ -21,7 +21,6 @@
#include <sys/sensors.h>
#include <sys/sysctl.h>
#include <sys/device.h>
-#include <sys/hotplug.h>
#include <errno.h>
#include <fcntl.h>
@@ -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));
-}