aboutsummaryrefslogtreecommitdiff
path: root/sbin/devd
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/devd')
-rw-r--r--sbin/devd/Makefile20
-rw-r--r--sbin/devd/autofs.conf9
-rw-r--r--sbin/devd/devd.88
-rw-r--r--sbin/devd/devd.cc51
-rw-r--r--sbin/devd/devd.conf32
-rw-r--r--sbin/devd/devd.conf.5211
-rw-r--r--sbin/devd/devmatch.conf26
-rw-r--r--sbin/devd/hyperv.conf1
-rw-r--r--sbin/devd/moused.conf11
-rw-r--r--sbin/devd/nvmf.conf7
-rw-r--r--sbin/devd/snd.conf23
-rw-r--r--sbin/devd/tests/Makefile1
-rw-r--r--sbin/devd/tests/client_test.c33
13 files changed, 306 insertions, 127 deletions
diff --git a/sbin/devd/Makefile b/sbin/devd/Makefile
index f1a5f12ac478..553aecf4ee88 100644
--- a/sbin/devd/Makefile
+++ b/sbin/devd/Makefile
@@ -1,7 +1,6 @@
-
.include <src.opts.mk>
-WARNS?= 3
+WARNS?= 6
PACKAGE=devd
CONFGROUPS= CONFS DEVD
CONFS= devd.conf
@@ -11,6 +10,13 @@ DEVDDIR= /etc/devd
DEVD+= asus.conf
.endif
+.if ${MK_AUTOFS} != "no"
+CONFGROUPS+= AUTOFS
+AUTOFSDIR= ${DEVDDIR}
+AUTOFS+= autofs.conf
+AUTOFSPACKAGE= autofs
+.endif
+
CONFGROUPS+= DHCLIENT
DHCLIENTDIR= ${DEVDDIR}
DHCLIENT+= dhclient.conf
@@ -26,6 +32,11 @@ CONSOLEDIR= ${DEVDDIR}
CONSOLE+= moused.conf syscons.conf
CONSOLEPACKAGE= console-tools
+CONFGROUPS+= SND
+SNDDIR= ${DEVDDIR}
+SND= snd.conf
+SNDPACKAGE= sound
+
.if ${MK_BLUETOOTH} != "no"
CONFGROUPS+= BLUETOOTH
BLUETOOTHDIR= ${DEVDDIR}
@@ -40,6 +51,11 @@ HYPERV+= hyperv.conf
HYPERVPACKAGE= hyperv-tools
.endif
+CONFGROUPS+= NVME
+NVMEDIR= ${DEVDDIR}
+NVME+= nvmf.conf
+NVMEPACKAGE= nvme-tools
+
.if ${MK_USB} != "no"
DEVD+= uath.conf ulpt.conf
.endif
diff --git a/sbin/devd/autofs.conf b/sbin/devd/autofs.conf
new file mode 100644
index 000000000000..2671687ecd83
--- /dev/null
+++ b/sbin/devd/autofs.conf
@@ -0,0 +1,9 @@
+#
+# autofs(4) specific devd events
+
+# Discard autofs caches, useful for the -media special map.
+notify 100 {
+ match "system" "GEOM";
+ match "subsystem" "DEV";
+ action "/usr/sbin/automount -c";
+};
diff --git a/sbin/devd/devd.8 b/sbin/devd/devd.8
index f7e19df438ed..f4e8e173399c 100644
--- a/sbin/devd/devd.8
+++ b/sbin/devd/devd.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 19, 2021
+.Dd May 7, 2025
.Dt DEVD 8
.Os
.Sh NAME
@@ -154,6 +154,12 @@ to communicate with its clients.
.It Pa /var/run/devd.pipe
A deprecated socket retained for use with old clients.
.El
+.Sh EXAMPLES
+Use
+.Xr cat 1
+to monitor kernel events:
+.Pp
+.Dl cat /var/run/devd.seqpacket.pipe
.Sh SEE ALSO
.Xr devctl 4 ,
.Xr devd.conf 5
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index 05715c18708f..ee38fbb2ccee 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -63,7 +63,6 @@
// - devd needs to document the unix domain socket
// - devd.conf needs more details on the supported statements.
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -154,6 +153,8 @@ static volatile sig_atomic_t romeo_must_die = 0;
static const char *configfile = CF;
+static char vm_guest[80];
+
static void devdlog(int priority, const char* message, ...)
__printflike(2, 3);
static void event_loop(void);
@@ -868,6 +869,8 @@ process_event(char *buffer)
cfg.set_variable("timestamp", timestr);
free(timestr);
+ cfg.set_variable("vm_guest", vm_guest);
+
// Match doesn't have a device, and the format is a little
// different, so handle it separately.
switch (type) {
@@ -939,7 +942,7 @@ create_socket(const char *name, int socktype)
return (fd);
}
-static unsigned int max_clients = 10; /* Default, can be overridden on cmdline. */
+static unsigned int max_clients = 50; /* Default, can be overridden on cmdline. */
static unsigned int num_clients;
static list<client_t> clients;
@@ -1108,6 +1111,14 @@ event_loop(void)
err(1, "select");
} else if (rv == 0)
check_clients();
+ /*
+ * Aside from the socket type, both sockets use the same
+ * protocol, so we can process clients the same way.
+ */
+ if (FD_ISSET(stream_fd, &fds))
+ new_client(stream_fd, SOCK_STREAM);
+ if (FD_ISSET(seqpacket_fd, &fds))
+ new_client(seqpacket_fd, SOCK_SEQPACKET);
if (FD_ISSET(fd, &fds)) {
rv = read(fd, buffer, sizeof(buffer) - 1);
if (rv > 0) {
@@ -1136,14 +1147,6 @@ event_loop(void)
break;
}
}
- if (FD_ISSET(stream_fd, &fds))
- new_client(stream_fd, SOCK_STREAM);
- /*
- * Aside from the socket type, both sockets use the same
- * protocol, so we can process clients the same way.
- */
- if (FD_ISSET(seqpacket_fd, &fds))
- new_client(seqpacket_fd, SOCK_SEQPACKET);
}
cfg.remove_pidfile();
close(seqpacket_fd);
@@ -1205,27 +1208,6 @@ new_action(const char *cmd)
eps *
new_match(const char *var, const char *re)
{
- /*
- * In FreeBSD 14, we changed the system=kern to system=kernel for the
- * resume message to match all the other 'kernel' messages. Generate a
- * warning for the life of 14.x that we've 'fixed' the file on the fly,
- * but make it a fatal error in 15.x and newer.
- */
- if (strcmp(var, "kern") == 0) {
-#if __FreeBSD_version < 1500000
- devdlog(LOG_WARNING,
- "Changing deprecated system='kern' to new name 'kernel' in %s line %d.",
- curr_cf, lineno);
- free(const_cast<char *>(var));
- var = strdup("kernel");
-#elif __FreeBSD_version < 1600000
- errx(1, "Encountered deprecated system=\"kern\" rule in %s line %d",
- curr_cf, lineno);
-#else
-#error "Remove this gross hack"
-#endif
- }
-
eps *e = new match(cfg, var, re);
free(const_cast<char *>(var));
free(const_cast<char *>(re));
@@ -1323,6 +1305,7 @@ int
main(int argc, char **argv)
{
int ch;
+ size_t len;
check_devd_enabled();
while ((ch = getopt(argc, argv, "df:l:nq")) != -1) {
@@ -1347,6 +1330,12 @@ main(int argc, char **argv)
}
}
+ len = sizeof(vm_guest);
+ if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) < 0) {
+ devdlog(LOG_ERR,
+ "sysctlbyname(kern.vm_guest) failed: %d\n", errno);
+ }
+
cfg.parse();
if (!no_daemon && daemonize_quick) {
cfg.open_pidfile();
diff --git a/sbin/devd/devd.conf b/sbin/devd/devd.conf
index ea8421e76d61..86faf2f30722 100644
--- a/sbin/devd/devd.conf
+++ b/sbin/devd/devd.conf
@@ -18,7 +18,7 @@ options {
# Setup some shorthand for regex that we use later in the file.
#XXX Yes, this is gross -- imp
set wifi-driver-regex
- "(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|otus|\
+ "(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|mtw|otus|\
ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+";
};
@@ -75,29 +75,6 @@ detach 100 {
# action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
#};
-# Don't even try to second guess what to do about drivers that don't
-# match here. Instead, pass it off to syslog. Commented out for the
-# moment, as the pnpinfo variable isn't set in devd yet. Individual
-# variables within the bus supplied pnpinfo are set.
-nomatch 0 {
-# action "logger Unknown device: $pnpinfo $location $bus";
-};
-
-# Various logging of unknown devices.
-nomatch 10 {
- match "bus" "uhub[0-9]+";
- action "logger Unknown USB device: vendor $vendor product $product \
- bus $bus";
-};
-
-# Some Cardbus cards don't offer numerical manufacturer/product IDs, just
-# show the CIS info there.
-nomatch 10 {
- match "bus" "cardbus[0-9]+";
- action "logger Unknown Cardbus device: device $device class $class \
- vendor $vendor bus $bus";
-};
-
# Notify all users before beginning emergency shutdown when we get
# a _CRT or _HOT thermal event and we're going to power down the system
# very soon.
@@ -159,13 +136,6 @@ notify 0 {
action "service postgresql restart";
};
-# Discard autofs caches, useful for the -media special map.
-notify 100 {
- match "system" "GEOM";
- match "subsystem" "DEV";
- action "/usr/sbin/automount -c";
-};
-
# Handle userland coredumps.
# This commented out handler makes it possible to run an
# automated debugging session after the core dump is generated.
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index c9c421090ab9..8df3e910e076 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -38,12 +38,12 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd December 1, 2022
+.Dd July 9, 2025
.Dt DEVD.CONF 5
.Os
.Sh NAME
.Nm devd.conf
-.Nd configuration file for
+.Nd configuration file format for
.Xr devd 8
.Sh DESCRIPTION
.Ss General Syntax
@@ -322,7 +322,7 @@ mechanism.
.\" for each of the tables so that things line up in columns nicely.
.\" Please do not omit the type column for notifiers that omit it.
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li ACPI Ta Ta Ta
Events related to the ACPI Subsystem.
@@ -346,13 +346,13 @@ Suspend notification.
Thermal zone events.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li AEON Ta Li power Ta Li press Ta
The power button on an Amiga has been pressed.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li CAM Ta Ta Ta
Events related to the
@@ -366,24 +366,24 @@ Generic errors.
Command timeouts.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li CARP Ta Ta Ta
Events related to the
.Xr carp 4
protocol.
-.It CARP Ta Ar vhid@inet Ta Ta
+.It Li CARP Ta Ar vhid@inet Ta Ta
The
.Dq subsystem
contains the actual CARP vhid and the name of the network interface
on which the event took place.
-.It CARP Ta Ar vhid@inet Ta MASTER Ta
+.It Li CARP Ta Ar vhid@inet Ta Li MASTER Ta
Node become the master for a virtual host.
-.It CARP Ta Ar vhid@inet Ta BACKUP Ta
+.It Li CARP Ta Ar vhid@inet Ta Li BACKUP Ta
Node become the backup for a virtual host.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "CORETEMP" "SUBSYSTEM" "TEMPERATURE" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li coretemp Ta Ta Ta
Events related to the
@@ -395,7 +395,7 @@ Notification that the CPU core has reached critical temperature.
String containing the temperature of the core that has become too hot.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li DEVFS
.It Li DEVFS Ta Li CDEV Ta Li CREATE Ta
@@ -408,7 +408,7 @@ The
node is destroyed.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li ETHERNET Ta Ar inet Ta IFATTACH Ta
Notification when the default VNET instance of the
@@ -416,7 +416,7 @@ Notification when the default VNET instance of the
interface is attached.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "GEOM::ROTATION_RATE" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li GEOM Ta Ta Ta
Events related to the
@@ -447,7 +447,7 @@ A
provider size has changed.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "LINK_DOWN" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li IFNET
.It Li IFNET Ta Em inet Ta Ta
@@ -471,7 +471,7 @@ The network interface address added.
The network interface address removed.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li kernel Ta Li signal Ta Li coredump Ta
Notification that a process has crashed and dumped core.
@@ -479,7 +479,49 @@ Notification that a process has crashed and dumped core.
Notification that the system has woken from the suspended state.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "SMART_ERROR" -compact
+.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
+.It Li nvme Ta Li controller Ta Ta
+Controller events provide the controller name
+.Pq for example, Li nvme0
+in $name.
+.It Li nvme Ta Li controller Ta Li SMART_ERROR Ta
+A SMART Critical Warning State change has happened.
+$state has a hex bitmask of the bits that changed, as defined
+in the NVMe Standard for Critical Warning field of log page 2
+.Dq SMART / Health Information Log :
+.Pp
+.Bl -tag -width "Bit Value" -compact
+.It Sy "Bit Value"
+.Sy Meaning
+.It 0x1
+Spare capacity below threshold
+.It 0x2
+Temperature outside acceptable range
+.It 0x4
+Reliability of media degraded
+.It 0x8
+Media placed into read-only mode
+.It 0x10
+Volatime memory backup failure
+.It 0x20
+Persistent memory read-only or degraded
+.El
+.It Li nvme Ta Li controller Ta Li RESET Ta
+A controller reset event has happened.
+$event is one of
+.Dq start ,
+.Dq success ,
+and
+.Dq timed_out
+representing the start of a controller reset, the successful completion of a
+controller reset, or a timeout while waiting for the controller to reset,
+respectively.
+.It Li nvme Ta Li controller Ta Li RECONNECT Ta
+An NVMe over Fabrics host has disconnected and is requesting a reconnect.
+.El
+.Pp
+.Bl -column "SYSTEM" "SUBSYSTEM" "SHUTDOWN-THRESHOLD" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li PMU Ta Ta Ta
Notification of events from various types of Power Management Units.
@@ -492,25 +534,25 @@ Power has been applied to the AC power line.
.It Li PMU Ta Li "AC" Ta Li unplugged Ta
Power has been removed from the AC power line.
.It Li PMU Ta Li Battery Ta Ta
-.It Li PMU Ta Li Battery Ta absent Ta
+.It Li PMU Ta Li Battery Ta Li absent Ta
Battery is no longer absent.
-.It Li PMU Ta Li Battery Ta charged Ta
+.It Li PMU Ta Li Battery Ta Li charged Ta
The battery has become charged.
-.It Li PMU Ta Li Battery Ta charging Ta
+.It Li PMU Ta Li Battery Ta Li charging Ta
The battery has started charging.
-.It Li PMU Ta Li Battery Ta disconnected Ta
+.It Li PMU Ta Li Battery Ta Li disconnected Ta
The battery has been disconnected.
-.It Li PMU Ta Li Battery Ta high-temp Ta
+.It Li PMU Ta Li Battery Ta Li high-temp Ta
The battery reported a temperature over the limit.
-.It Li PMU Ta Li Battery Ta low-temp Ta
+.It Li PMU Ta Li Battery Ta Li low-temp Ta
The battery reported a temperature under the limit.
-.It Li PMU Ta Li Battery Ta plugged Ta
+.It Li PMU Ta Li Battery Ta Li plugged Ta
The battery has become plugged (eg connected).
-.It Li PMU Ta Li Battery Ta shutdown-threshold Ta
+.It Li PMU Ta Li Battery Ta Li shutdown-threshold Ta
The power in the battery has fallen below the shutdown threshold.
-.It Li PMU Ta Li Battery Ta warning-threshold Ta
+.It Li PMU Ta Li Battery Ta Li warning-threshold Ta
The power in the battery has fallen below the warn the user threshold.
-.It Li PMU Ta Li Button Ta pressed Ta
+.It Li PMU Ta Li Button Ta Li pressed Ta
A button on a
.Xr adb 4
or
@@ -520,39 +562,39 @@ has been pressed.
One of the keys on the
.Xr adb 4
keyboard has been pressed.
-.It Li PMU Ta Li keys Ta brightness Ta
+.It Li PMU Ta Li keys Ta Li brightness Ta
A brightness level change has been requested.
Direction is in the $notify variable.
-.It Li PMU Ta Li keys Ta mute Ta
+.It Li PMU Ta Li keys Ta Li mute Ta
The mute key
-.It Li PMU Ta Li keys Ta volume Ta
+.It Li PMU Ta Li keys Ta Li volume Ta
A volume level change has been requested.
Direction is in the $notify variable.
-.It Li PMU Ta Li keys Ta eject Ta
+.It Li PMU Ta Li keys Ta Li eject Ta
An ejection has been requested.
-.It Li PMU Ta Li lid Ta close Ta
+.It Li PMU Ta Li lid Ta Li close Ta
The
.Xr pmc 4
device has detected the lid closing.
-.It Li PMU Ta Li lid Ta open Ta
+.It Li PMU Ta Li lid Ta Li open Ta
The
.Xr pmc 4
device has detected the lid openinging.
-.It Li PMU Ta Li POWER Ta ACLINE Ta
+.It Li PMU Ta Li POWER Ta Li ACLINE Ta
The
.Xr pmc 4
device has detected an AC line state ($notify=0x00 is offline, 0x01 is online).
-.It Li PMU Ta Li USB Ta overvoltage Ta
+.It Li PMU Ta Li USB Ta Li overvoltage Ta
An over-voltage condition on the power lines for the USB power pins.
-.It Li PMU Ta Li USB Ta plugged Ta
+.It Li PMU Ta Li USB Ta Li plugged Ta
A device has been plugged into a USB device.
-.It Li PMU Ta Li USB Ta undervoltage Ta
+.It Li PMU Ta Li USB Ta Li undervoltage Ta
An under-voltage condition on the power lines for the USB power pins.
-.It Li PMU Ta Li USB Ta unplugged Ta
-A device has been unplugged into a USB device.
+.It Li PMU Ta Li USB Ta Li unplugged Ta
+A device has been unplugged from a USB device.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li RCTL Ta Ta Ta
Events related to the
@@ -562,7 +604,7 @@ framework.
A rule with action specified as "devctl" was triggered.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li USB Ta Ta Ta
Events related to the USB subsystem.
@@ -576,7 +618,7 @@ USB interface is attached to a device.
USB interface is detached from a device.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li VFS Ta Ta Ta
Events from the vfs system.
@@ -590,18 +632,18 @@ Notification of a filesystem is remounted (whether or not the options actually c
Notification of a filesystem being unmounted.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
-.It Li VT Ta BELL Ta RING Ta
+.It Li VT Ta Li BELL Ta Li RING Ta
Notification that the console bell has rung.
See
.Xr vt 4
for details.
.El
.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
+.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
-.It Li ZFS Ta ZFS Ta Ta
+.It Li ZFS Ta Li ZFS Ta Ta
Events about the ZFS subsystem.
See
.Xr zfsd 8
@@ -610,6 +652,22 @@ and
for details.
.El
.Pp
+.Bl -column "System" "Subsystem" "1234567" -compact
+.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
+.It Li SND Ta Ta Ta
+Events related to the
+.Xr sound 4
+driver.
+.It Li SND Ta Li CONN Ta Li IN Ta
+Connected input device specified in
+.Pa cdev
+variable.
+.It Li SND Ta Li CONN Ta Li OUT Ta
+Connected output device specified in
+.Pa cdev
+variable.
+.El
+.Pp
.\"
.\" End of tables
.\"
@@ -666,6 +724,26 @@ For example:
// part of the previous comment.
.Ed
.Ss Notes on Variable Expansion
+Variables are expanded by preceding them by a
+.Dq $
+sign.
+Any text immediately following that sign, starting with a letter, a minus sign
+.Dq - ,
+an underscore
+.Dq _ ,
+or an asterisk
+.Dq *
+is considered an internal variable, and expanded accordingly.
+If that variable does not exist, it silently expands to an empty string.
+Consequently, if the intention is to pass a
+.Xr sh 1
+variable, it must be surrounded by braces to prevent it from being
+considered an internal variable.
+.Pp
+See
+.Sx EXAMPLES
+for a detailed example.
+.Pp
To prevent issues with special shell characters, the following happens for each
variable
.Ic $foo .
@@ -683,6 +761,10 @@ The value of the
.Ic foo
variable is inserted into the buffer with all single quote characters
prefixed by a backslash.
+.It
+A final
+.Dq '
+is inserted.
.El
.Pp
See
@@ -724,6 +806,14 @@ regardless of the value of the variable.
The
.Xr devd 8
configuration file.
+.It Pa /etc/devd
+A directory that
+.Nm devd
+searches for additional configuration files.
+.It Pa /usr/local/etc/devd
+A directory that
+.Nm devd
+searches for additional configuration files.
.El
.Sh EXAMPLES
.Bd -literal
@@ -786,6 +876,37 @@ detach 0 {
};
.Ed
.Pp
+The following example illustrates the difference betwen internal and shell variables:
+.Bd -literal
+attach 20 {
+ device-name "umodem[0-9]+";
+ match "vendor" "0x2047";
+ match "product" "0x001(0|3|4)";
+ match "interface" "0";
+ action "cd /dev; p=$product; dn=$device-name; \\
+ un=$(sysctl -n dev.umodem.${dn#umodem}.ttyname); \\
+ chmod 666 cua${un}; ln -sf cua${un} mspfet${p#0x}";
+};
+.Ed
+.Pp
+.Dq product ,
+and
+.Dq device-name
+are internal variables.
+Their contents are initially assigned to shell variables
+.Dq p ,
+and
+.Dq dn ,
+respectively.
+Then, variable
+.Dq dn
+is used inside a shell command substitution, assigning to shell variable
+.Dq un .
+Finally, this shell variable is used in two other shell statements, where
+it needs to be wrapped in braces in order to prevent it from being
+considered in internal variable to
+.Nm devd .
+.Pp
The installed
.Pa /etc/devd.conf
has many additional examples.
diff --git a/sbin/devd/devmatch.conf b/sbin/devd/devmatch.conf
index 085338eabca4..a7c27857c0bd 100644
--- a/sbin/devd/devmatch.conf
+++ b/sbin/devd/devmatch.conf
@@ -1,14 +1,32 @@
+# Implement the run-time component of devmatch by reacting to nomatch events.
+
#
+# Ignore those devices that can't possibly match. When there's neither a
+# location, nor a pnpinfo string, we know that there's nothing devmatch can
+# match on. When it's only a location, it'd debateable, but for nomatch
+# events, we can't disambiguate between the two reliably.
#
+nomatch 101 {
+ match "_" " +at +on .*";
+};
#
-# Example devd configuration file for automatically
-# loading what modules we can based on nomatch
-# events.
+# Ignore ACPI devices whose _HID is none. These cannot tell us what to load,
+# since 'none' is not a valid id. There's no need to call devvmatch for these either.
+#
+nomatch 101 {
+ match "_HID" "none";
+ match "bus" "acpi[0-9]+";
+};
+
#
# Generic NOMATCH event
+#
+# Note: It would be better to have some internal-to-devd action that will do
+# what devmatch does without re-parsing loader.hints for each invocation
+#
nomatch 100 {
- action "service devmatch quietstart '?'$_";
+ action "service devmatch quietstart $*";
};
# Add the following to devd.conf to prevent this from running:
diff --git a/sbin/devd/hyperv.conf b/sbin/devd/hyperv.conf
index 13695a0c75b6..70108ac36e54 100644
--- a/sbin/devd/hyperv.conf
+++ b/sbin/devd/hyperv.conf
@@ -103,5 +103,6 @@ notify 10 {
notify 10 {
match "system" "ETHERNET";
match "type" "IFATTACH";
+ match "vm_guest" "hv";
action "/usr/libexec/hyperv/hyperv_vfattach $subsystem 0";
};
diff --git a/sbin/devd/moused.conf b/sbin/devd/moused.conf
index 002edad9a8a9..8821c2bb8375 100644
--- a/sbin/devd/moused.conf
+++ b/sbin/devd/moused.conf
@@ -31,5 +31,14 @@ notify 100 {
match "type" "DESTROY";
match "cdev" "ums[0-9]+";
- action "service moused stop $cdev";
+ action "service moused quietstop $cdev";
+};
+
+notify 100 {
+ match "system" "DEVFS";
+ match "subsystem" "CDEV";
+ match "type" "CREATE";
+ match "cdev" "input/event[0-9]+";
+
+ action "service moused quietstart $cdev";
};
diff --git a/sbin/devd/nvmf.conf b/sbin/devd/nvmf.conf
new file mode 100644
index 000000000000..eaf3ebe86cec
--- /dev/null
+++ b/sbin/devd/nvmf.conf
@@ -0,0 +1,7 @@
+# Attempt to reconnect NVMeoF host devices when requested
+notify 100 {
+ match "system" "nvme";
+ match "subsystem" "controller";
+ match "type" "RECONNECT";
+ action "nvmecontrol reconnect $name";
+};
diff --git a/sbin/devd/snd.conf b/sbin/devd/snd.conf
new file mode 100644
index 000000000000..cf9cd9e94191
--- /dev/null
+++ b/sbin/devd/snd.conf
@@ -0,0 +1,23 @@
+# Audio redirection
+notify 0 {
+ match "system" "SND";
+ match "subsystem" "CONN";
+ match "type" "IN";
+ match "cdev" "dsp[0-9]+";
+
+ # FIXME: We are hardcoding /dev/vdsp.ctl here, simply because it is a
+ # common virtual_oss control device name. Until we find a proper way to
+ # define control devices here, /dev/vdsp.ctl can be changed to the
+ # control device of choice.
+ action "/usr/sbin/virtual_oss_cmd /dev/vdsp.ctl -R /dev/$cdev";
+};
+
+notify 0 {
+ match "system" "SND";
+ match "subsystem" "CONN";
+ match "type" "OUT";
+ match "cdev" "dsp[0-9]+";
+
+ # FIXME: See comment above.
+ action "/usr/sbin/virtual_oss_cmd /dev/vdsp.ctl -P /dev/$cdev";
+};
diff --git a/sbin/devd/tests/Makefile b/sbin/devd/tests/Makefile
index 7a51f488ac68..fba7176d5ae1 100644
--- a/sbin/devd/tests/Makefile
+++ b/sbin/devd/tests/Makefile
@@ -1,4 +1,3 @@
-
ATF_TESTS_C= client_test
TEST_METADATA.client_test= required_files="/var/run/devd.pid"
TEST_METADATA.client_test+= required_programs="devd"
diff --git a/sbin/devd/tests/client_test.c b/sbin/devd/tests/client_test.c
index 729c7a2f8bad..fdac3c98b3c6 100644
--- a/sbin/devd/tests/client_test.c
+++ b/sbin/devd/tests/client_test.c
@@ -22,15 +22,14 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include <stdbool.h>
-#include <stdio.h>
-
#include <sys/param.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include <atf-c.h>
const char create_pat[] = "!system=DEVFS subsystem=CDEV type=CREATE cdev=md";
@@ -134,29 +133,37 @@ ATF_TC_BODY(seqpacket, tc)
ATF_TC_WITHOUT_HEAD(stream);
ATF_TC_BODY(stream, tc)
{
+ char *event;
int s;
bool got_create_event = false;
bool got_destroy_event = false;
- ssize_t len = 0;
+ size_t len = 0, sz;
s = common_setup(SOCK_STREAM, "/var/run/devd.pipe");
+
+ /*
+ * Use a large buffer: we're reading from a stream socket so can't rely
+ * on record boundaries. Instead, we just keep appending to the buffer.
+ */
+ sz = 1024 * 1024;
+ event = malloc(sz);
+ ATF_REQUIRE(event != NULL);
+
/*
* Loop until both events are detected on the same or different reads.
* There may be extra events due to unrelated system activity.
* If we never get both events, then the test will timeout.
*/
- while (!(got_create_event && got_destroy_event)) {
- char event[1024];
+ while (!(got_create_event && got_destroy_event) && len < sz - 1) {
ssize_t newlen;
char *create_pos, *destroy_pos;
/* Read 1 less than sizeof(event) to allow space for NULL */
- newlen = read(s, &event[len], sizeof(event) - len - 1);
- ATF_REQUIRE(newlen != -1);
+ newlen = read(s, &event[len], sz - len - 1);
+ ATF_REQUIRE(newlen > 0);
len += newlen;
/* NULL terminate the result */
event[len] = '\0';
- printf("%s", event);
create_pos = strstr(event, create_pat);
if (create_pos != NULL)
@@ -166,7 +173,11 @@ ATF_TC_BODY(stream, tc)
if (destroy_pos != NULL)
got_destroy_event = true;
}
+ printf("%s", event);
+ if (len >= sz - 1)
+ atf_tc_fail("Event buffer overflowed");
+ free(event);
close(s);
}