diff options
author | imp <imp@FreeBSD.org> | 2004-06-30 02:46:25 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2004-06-30 02:46:25 +0000 |
commit | 3e05633a44b7bc685841e376bd562e8fa5494038 (patch) | |
tree | 6c0b2ab9360c385de2025cc5b3137a40b530ed1d /sys/kern/subr_bus.c | |
parent | 06cc06e43b8ddae7de0964445572da990ad75c44 (diff) | |
download | FreeBSD-src-3e05633a44b7bc685841e376bd562e8fa5494038.zip FreeBSD-src-3e05633a44b7bc685841e376bd562e8fa5494038.tar.gz |
Include more information about the device in the devadded and
devremoved events. This reduces the races around these events. We
now include the pnp info in both. This lets one do more interesting
thigns with devd on device insertion.
Submitted by: Bernd Walter
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index fd2e9d4..cff6e7f 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -617,7 +617,25 @@ bad: static void devadded(device_t dev) { - devaddq("+", device_get_nameunit(dev), dev); + char *pnp = NULL; + char *tmp = NULL; + + pnp = malloc(1024, M_BUS, M_NOWAIT); + if (pnp == NULL) + goto fail; + tmp = malloc(1024, M_BUS, M_NOWAIT); + if (tmp == NULL) + goto fail; + *pnp = '\0'; + bus_child_pnpinfo_str(dev, pnp, 1024); + snprintf(tmp, 1024, "%s %s", device_get_nameunit(dev), pnp); + devaddq("+", tmp, dev); +fail: + if (pnp != NULL) + free(pnp, M_BUS); + if (tmp != NULL) + free(tmp, M_BUS); + return; } /* @@ -627,7 +645,25 @@ devadded(device_t dev) static void devremoved(device_t dev) { - devaddq("-", device_get_nameunit(dev), dev); + char *pnp = NULL; + char *tmp = NULL; + + pnp = malloc(1024, M_BUS, M_NOWAIT); + if (pnp == NULL) + goto fail; + tmp = malloc(1024, M_BUS, M_NOWAIT); + if (tmp == NULL) + goto fail; + *pnp = '\0'; + bus_child_pnpinfo_str(dev, pnp, 1024); + snprintf(tmp, 1024, "%s %s", device_get_nameunit(dev), pnp); + devaddq("-", tmp, dev); +fail: + if (pnp != NULL) + free(pnp, M_BUS); + if (tmp != NULL) + free(tmp, M_BUS); + return; } /* |