Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163623506
D34504.id103670.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D34504.id103670.diff
View Options
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;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jul 25, 10:59 PM (13 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35503559
Default Alt Text
D34504.id103670.diff (1 KB)
Attached To
Mode
D34504: kern: add devctl_notifyf()
Attached
Detach File
Event Timeline
Log In to Comment