devctl (alike?) for devfs
Andriy Gapon
avg at icyb.net.ua
Thu Apr 24 21:35:28 UTC 2008
I decided to do it in devfs_devs.c because there are less entry points
there and the code is much simpler (you know: aliases, clones).
I also had to add !cold condition, because apparently we have devices
created so early in the boot, that devctl is not ready to handle a
notification. My system hanged after only getting to the following line
in verbose boot:
ULE: setup cpu 0
However it is possible that it did something wrong - at that time I had
devctl calls in kern_conf.
I guess this also should be OK from the user perspective because they
would be interested in device events after a system is booted and devd
is running.
Here is a log of devd started with -dD flags in single-user mode, then I
attached and later detached an external hdd:
http://www.icyb.net.ua/~avg/devd.log.gz
Search for DEVFS for interesting lines.
--
Andriy Gapon
-------------- next part --------------
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index ca5c2de..3556799 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
+#include <sys/bus.h>
#include <sys/dirent.h>
#include <sys/kernel.h>
#include <sys/limits.h>
@@ -518,6 +519,9 @@ devfs_create(struct cdev *dev)
dev_refl(dev);
TAILQ_INSERT_TAIL(&cdevp_list, cdp, cdp_list);
devfs_generation++;
+
+ if (!cold)
+ devctl_notify("DEVFS", dev->si_name, "ATTACH", NULL);
}
void
@@ -529,6 +533,9 @@ devfs_destroy(struct cdev *dev)
cdp = dev->si_priv;
cdp->cdp_flags &= ~CDP_ACTIVE;
devfs_generation++;
+
+ if (!cold)
+ devctl_notify("DEVFS", dev->si_name, "DETACH", NULL);
}
static void
More information about the freebsd-hackers
mailing list