git: 439b219fed3e - main - devd/snd.conf: Handle absent control device properly

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Tue, 09 Jun 2026 15:14:16 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=439b219fed3eea8ad3e1204393a8605826b8bbca

commit 439b219fed3eea8ad3e1204393a8605826b8bbca
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-06-09 15:10:58 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-06-09 15:10:58 +0000

    devd/snd.conf: Handle absent control device properly
    
    If virtual_oss is not enabled when these rules run on startup, dmesg
    will show the following messages:
    
    Starting devd.
    virtual_oss_cmd: Could not open control device: /dev/vdsp.ctl: No such file or directory
    virtual_oss_cmd: Could not open control device: /dev/vdsp.ctl: No such file or directory
    
    Reported by:    olce, Mark Millard <marklmi@yahoo.com>
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sbin/devd/snd.conf | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/sbin/devd/snd.conf b/sbin/devd/snd.conf
index 3fc1cb9f0b0e..ecaec62bc6cc 100644
--- a/sbin/devd/snd.conf
+++ b/sbin/devd/snd.conf
@@ -7,8 +7,9 @@ notify 0 {
 
 	# Other audio servers or device switching commands can be used here
 	# instead of virtual_oss(8).
-	action			"/usr/sbin/virtual_oss_cmd \
-		/dev/$(sysrc -n virtual_oss_default_control_device) -R /dev/$cdev";
+	action			"\
+		vd=/dev/$(sysrc -n virtual_oss_default_control_device); \
+		test -e ${vd} && /usr/sbin/virtual_oss_cmd ${vd} -R /dev/$cdev";
 };
 
 notify 0 {
@@ -18,8 +19,9 @@ notify 0 {
 	match "cdev"		"dsp[0-9]+";
 
 	# See comment above.
-	action			"/usr/sbin/virtual_oss_cmd \
-		/dev/$(sysrc -n virtual_oss_default_control_device) -P /dev/$cdev";
+	action			"\
+		vd=/dev/$(sysrc -n virtual_oss_default_control_device); \
+		test -e ${vd} && /usr/sbin/virtual_oss_cmd ${vd} -P /dev/$cdev";
 };
 
 notify 0 {
@@ -29,6 +31,7 @@ notify 0 {
 
 	# No connected devices. Disable both recording and playback to avoid
 	# repeated virtual_oss error messages.
-	action			"/usr/sbin/virtual_oss_cmd \
-		/dev/$(sysrc -n virtual_oss_default_control_device) -f /dev/null";
+	action			"\
+		vd=/dev/$(sysrc -n virtual_oss_default_control_device); \
+		test -e ${vd} && /usr/sbin/virtual_oss_cmd ${vd} -f /dev/null";
 };