Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115621390
D34504.id103672.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D34504.id103672.diff
View Options
Index: share/man/man9/Makefile
===================================================================
--- share/man/man9/Makefile
+++ share/man/man9/Makefile
@@ -971,6 +971,7 @@
MLINKS+=dev_clone.9 drain_dev_clone_events.9
MLINKS+=dev_refthread.9 devvn_refthread.9 \
dev_refthread.9 dev_relthread.9
+MLINKS+=devctl_notify.9 devctl_notifyf.9
MLINKS+=devfs_set_cdevpriv.9 devfs_clear_cdevpriv.9 \
devfs_set_cdevpriv.9 devfs_get_cdevpriv.9
MLINKS+=device_add_child.9 device_add_child_ordered.9
Index: share/man/man9/devctl_notify.9
===================================================================
--- share/man/man9/devctl_notify.9
+++ share/man/man9/devctl_notify.9
@@ -23,16 +23,19 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 22, 2020
+.Dd March 9, 2022
.Dt DEVCTL_NOTIFY 9
.Os
.Sh NAME
-.Nm devctl_notify
+.Nm devctl_notify ,
+.Nm devctl_notifyf
.Nd Send a message, via devctl, to userland
.Sh SYNOPSIS
.In sys/devctl.h
.Ft void
.Fn devctl_notify "const char *system" "const char *subsystem" "const char *type" "const char *data"
+.Ft void
+.Fn devctl_notifyf "const char *system" "const char *subsystem" "const char *type" "const char *datafmt" "..."
.Sh DESCRIPTION
Send a notification to user land via
.Xr devctl 4 .
@@ -66,11 +69,22 @@
discover itself and sending all the data userland will want to use to
decide what to do with the message.
.Pp
+The
+.Fn devctl_notifyf
+function is identical to
+.Fn devctl_notify ,
+except it takes a format string to populate
+.Fa data
+and formats it as
+.Xr printf 9
+would print it.
+.Pp
The current total message length limit is just under 1kb.
Senders should try to remain well below this limit.
.Sh SEE ALSO
.Xr devctl 4 ,
-.Xr devd 8
+.Xr devd 8 ,
+.Xr printf 9
.Sh AUTHORS
This manual page was written by
.An M. Warner Losh
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
Sun, Apr 27, 3:18 AM (14 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17812679
Default Alt Text
D34504.id103672.diff (3 KB)
Attached To
Mode
D34504: kern: add devctl_notifyf()
Attached
Detach File
Event Timeline
Log In to Comment