1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-24 06:04:47 +00:00

Scan both dmesg.boot and dmesg(8) output for devices

This allows us to detect newly plugged in devices that need firmware
added while still making sure to detect devices available at boot
even if dmesg rolls over with noisy messages.

fixes and ok kn@
I think this is good deraadt@
This commit is contained in:
afresh1
2025-12-26 18:19:46 +00:00
parent 5ce3a7f811
commit 4fc47a7985
2 changed files with 23 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
.\" $OpenBSD: fw_update.8,v 1.8 2025/03/22 19:51:29 jmc Exp $
.\" $OpenBSD: fw_update.8,v 1.9 2025/12/26 18:19:46 afresh1 Exp $
.\"
.\" Copyright (c) 2011 Alexander Hall <alexander@beard.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 22 2025 $
.Dd $Mdocdate: December 26 2025 $
.Dt FW_UPDATE 8
.Os
.Sh NAME
@@ -59,11 +59,11 @@ If used in conjunction with
.Fl a ,
delete firmware for all drivers.
.It Fl D Ar path
Use the
.Xr dmesg 8
output from
Use the content of
.Ar path
rather than
rather than output from
.Xr dmesg 8
and
.Pa /var/run/dmesg.boot
to determine which firmware are needed.
.It Fl F

View File

@@ -1,5 +1,5 @@
#!/bin/ksh
# $OpenBSD: fw_update.sh,v 1.65 2025/05/12 23:48:12 afresh1 Exp $
# $OpenBSD: fw_update.sh,v 1.66 2025/12/26 18:19:46 afresh1 Exp $
#
# Copyright (c) 2021,2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
@@ -239,12 +239,25 @@ verify_existing() {
}
devices_in_dmesg() {
if [ "${DMESG:-}" ]; then
_devices_in_dmesg "$DMESG"
return
fi
dmesg > "$FD_DIR/dmesg"
_devices_in_dmesg /var/run/dmesg.boot
_devices_in_dmesg "$FD_DIR/dmesg"
}
_devices_in_dmesg() {
local _dmesg=$1
local IFS
local _d _m _dmesgtail _last='' _nl='
'
# The dmesg can contain multiple boots, only look in the last one
_dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' "$DMESG" )"
_dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' "$_dmesg" )"
grep -v '^[[:space:]]*#' "$FWPATTERNS" |
while read -r _d _m; do
@@ -489,7 +502,7 @@ set_fw_paths() {
if [ ! "$_version" ]; then
_version=$(sed -nE \
'/^OpenBSD ([0-9]+\.[0-9][^ ]*) .*/{s//\1/;h;};${g;p;}' \
"$DMESG")
"${DMESG:-/var/run/dmesg.boot}")
# If VNAME was set in the environment instead of the DMESG,
# looking in the DMESG for "current" is wrong.
@@ -514,7 +527,6 @@ usage() {
ALL=false
LIST=false
DMESG=/var/run/dmesg.boot
while getopts :adD:Flnp:v name
do
@@ -561,7 +573,7 @@ if [ "${FWURL:-}" ] && ! "$INSTALL" ; then
usage
fi
if [ ! -s "$DMESG" ]; then
if [ "${DMESG:-}" ] && [ ! -s "$DMESG" ]; then
warn "${0##*/}: $DMESG: No such file or directory"
exit 1
fi