diff --git a/sys/kern/kern_devctl.c b/sys/kern/kern_devctl.c index 414a2b74cbc7..2443e1b2b0ba 100644 --- a/sys/kern/kern_devctl.c +++ b/sys/kern/kern_devctl.c @@ -134,6 +134,10 @@ static struct filterops devctl_rfiltops = { static struct cdev *devctl_dev; static void devaddq(const char *type, const char *what, device_t dev); +static struct devctlbridge { + send_event_f send_f; +} devctl_notify_hook = { .send_f = NULL }; + static void devctl_init(void) { @@ -435,6 +439,8 @@ devctl_notify(const char *system, const char *subsystem, const char *type, if (system == NULL || subsystem == NULL || type == NULL) return; + if (devctl_notify_hook.send_f != NULL) + devctl_notify_hook.send_f(system, subsystem, type, data); dei = devctl_alloc_dei_sb(&sb); if (dei == NULL) return; @@ -569,4 +575,14 @@ devctl_safe_quote_sb(struct sbuf *sb, const char *src) } } +void +devctl_set_notify_hook(send_event_f *hook) +{ + devctl_notify_hook.send_f = hook; +} +void +devctl_unset_notify_hook(void) +{ + devctl_notify_hook.send_f = NULL; +} diff --git a/sys/sys/devctl.h b/sys/sys/devctl.h index b72cd28dfce8..049a1d7f32b9 100644 --- a/sys/sys/devctl.h +++ b/sys/sys/devctl.h @@ -17,6 +17,9 @@ void devctl_notify(const char *__system, const char *__subsystem, const char *__type, const char *__data); struct sbuf; void devctl_safe_quote_sb(struct sbuf *__sb, const char *__src); +typedef void send_event_f(const char *system, const char *subsystem, + const char *type, const char *data); +void devctl_set_notify_hook(send_event_f *hook); #endif #endif /* _SYS_DEVCTL_H_ */