Index | Thread | Search

From:
Andrew Hewus Fresh <andrew@afresh1.com>
Subject:
Use dmesg(8) in fw_update(8) instead of dmesg.boot
To:
tech@openbsd.org
Date:
Thu, 25 Dec 2025 08:01:28 -0800

Download raw body.

Thread
I got a report that it is expected for fw_update(8) to find firmware for                            
newly plugged in devices, not just what was available at boot.                                      
That seems reasonable.

The previous implementation looked at both,  I assume in case anything
had "fallen off" the dmesg filling up.  I think it is OK not to make
that more intrusive change because we would have checked at boot and we
also look for updates to already installed firmware.  The only failure
point I see is if dmesg had filled up past dmesg.boot, new firmware came
to be that didn't previously exist, and someone wanted to install it
without rebooting.

https://github.com/openbsd/src/blob/master/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm#L158-L175

comments, manpage improvements, reasons we need to check dmesg.boot, OK?

(I should probably rename FD_DIR, it's filling up a bit)

Index: fw_update.8
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.8,v
diff -u -p -r1.8 fw_update.8
--- fw_update.8	22 Mar 2025 19:51:29 -0000	1.8
+++ fw_update.8	25 Dec 2025 15:50:13 -0000
@@ -63,8 +63,7 @@ Use the
 .Xr dmesg 8
 output from
 .Ar path
-rather than
-.Pa /var/run/dmesg.boot
+rather than running dmesg
 to determine which firmware are needed.
 .It Fl F
 Download SHA256.sig and firmware .tgz to the current directory.
Index: fw_update.sh
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v
diff -u -p -r1.65 fw_update.sh
--- fw_update.sh	12 May 2025 23:48:12 -0000	1.65
+++ fw_update.sh	25 Dec 2025 15:50:13 -0000
@@ -514,7 +514,7 @@ usage() {
 
 ALL=false
 LIST=false
-DMESG=/var/run/dmesg.boot
+DMESG=
 
 while getopts :adD:Flnp:v name
 do
@@ -561,6 +561,13 @@ if [ "${FWURL:-}" ] && ! "$INSTALL" ; th
 	usage
 fi
 
+FD_DIR="$( tmpdir "${DESTDIR}/tmp/${0##*/}-fd" )"
+
+if [ ! "$DMESG" ]; then
+	DMESG=$FD_DIR/dmesg
+	dmesg > "$DMESG"
+fi
+
 if [ ! -s "$DMESG" ]; then
 	warn "${0##*/}: $DMESG: No such file or directory"
 	exit 1
@@ -581,7 +588,6 @@ fi
 
 set -sA devices -- "$@"
 
-FD_DIR="$( tmpdir "${DESTDIR}/tmp/${0##*/}-fd" )"
 # When being verbose, save the status line for the end.
 if ((VERBOSE)); then
 	exec 3>"${FD_DIR}/status"