From 6968b9e7d3cf2019a7ba3a73692c1c9d15989fe1 Mon Sep 17 00:00:00 2001 From: imp Date: Mon, 21 Apr 2003 04:30:12 +0000 Subject: Put an anti-foot-shooting measure in place. Set hw.bus.devctl_disable to 0 when we startup. Print a warning in this case. This allows people that are playing with devd by hand to have something happen. Otherwise, it appears that devd isn't working because /dev/devctl is disabled and producing no events. Suggested by: peter on irc a long time ago. --- sbin/devd/devd.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sbin/devd') diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index 9a0ea0e..bc598fe 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -58,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include "devd.h" #define CF "/etc/devd.conf" +#define SYSCTL "hw.bus.devctl_disable" using namespace std; @@ -783,6 +785,22 @@ usage() exit(1); } +static void +check_devd_enabled() +{ + int val = 0; + size_t len; + + len = sizeof(val); + if (sysctlbyname(SYSCTL, &val, &len, NULL, NULL) != 0) + errx(1, "devctl sysctl missing from kernel!"); + if (val) { + warnx("Setting " SYSCTL " to 0"); + val = 0; + sysctlbyname(SYSCTL, NULL, NULL, &val, sizeof(val)); + } +} + /* * main */ @@ -791,6 +809,7 @@ main(int argc, char **argv) { int ch; + check_devd_enabled(); while ((ch = getopt(argc, argv, "d")) != -1) { switch (ch) { case 'd': -- cgit v1.1