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.
This commit is contained in:
Warner Losh 2003-04-21 04:30:12 +00:00
parent 02245e6120
commit 9c1808986c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113787

View File

@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <ctype.h>
#include <dirent.h>
@ -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':