Index: sys/kern/subr_bus.c =================================================================== --- sys/kern/subr_bus.c +++ sys/kern/subr_bus.c @@ -675,11 +675,13 @@ } /** - * @brief Send a 'notification' to userland, using standard ways + * @brief Send a 'notification' to userland, using standard ways. This version + * takes a format string and varargs, which fits a number of consumers' slightly + * less trivial needs. */ void -devctl_notify(const char *system, const char *subsystem, const char *type, - const char *data) +devctl_notifyf(const char *system, const char *subsystem, const char *type, + const char *datafmt, ...) { struct dev_event_info *dei; struct sbuf sb; @@ -695,15 +697,35 @@ sbuf_cat(&sb, subsystem); sbuf_cat(&sb, " type="); sbuf_cat(&sb, type); - if (data != NULL) { + if (datafmt != NULL && *datafmt != '\0') { + va_list ap; + + va_start(ap, datafmt); sbuf_putc(&sb, ' '); - sbuf_cat(&sb, data); + sbuf_vprintf(&sb, datafmt, ap); + va_end(ap); } sbuf_putc(&sb, '\n'); if (sbuf_finish(&sb) != 0) devctl_free_dei(dei); /* overflow -> drop it */ else devctl_queue(dei); + +} + +/** + * @brief Send a 'notification' to userland, using standard ways + */ +void +devctl_notify(const char *system, const char *subsystem, const char *type, + const char *data) +{ + + if (data != NULL) { + devctl_notifyf(system, subsystem, type, "%s", data); + } else { + devctl_notifyf(system, subsystem, type, NULL); + } } /* Index: sys/sys/devctl.h =================================================================== --- sys/sys/devctl.h +++ sys/sys/devctl.h @@ -13,6 +13,8 @@ * hook to send the message. */ bool devctl_process_running(void); +void devctl_notifyf(const char *__system, const char *__subsystem, + const char *__type, const char *__datafmt, ...) __printflike(4, 5); void devctl_notify(const char *__system, const char *__subsystem, const char *__type, const char *__data); struct sbuf;