From abf9f467da41af7bcc04e0f12d581e5c1f433577 Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 27 Oct 2025 16:30:24 +0000 Subject: [PATCH] Before installing files, the syspatch ksh script checkfs() tries to check if the partitions have enough space by looking at the original files. It converts via stat(1) calling stat(2) st_dev to a device name by calling devname(), and then compares this against the mounted filesystems, to see how much space is left. This conversion via devname() went very wrong because dev_mkdb(8) does not maintain a 1:1 relationship between dev_t and name! The addition of rootdisk and rrootdisk which are aliased to sd0a or wd0a (to ease the future crossover to 52-partition support) breaks the 1:1 relationship. This commit rewrites the file checks to use statfs(2) via df(1) so that the same device-names are compared. ok bluhm mlarkin beck afresh1 robert This is part of 7.8 errata 001. On systems where /usr is not a seperate partition, but is part of /, syspatch will fail to install the errata and the following manual intervention will be required: sed -e 's/.checkfs/#checkfs/g' /usr/sbin/syspatch > /root/syspatch ksh /root/syspatch syspatch # re-run new syspatch command as instructed rm /root/syspatch dev_mkdb Most people use seperate /usr partition and won't need this because syspatch(8) will just work. --- usr.sbin/syspatch/syspatch.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh index b825d96b393..5b8f0b8dc2e 100644 --- a/usr.sbin/syspatch/syspatch.sh +++ b/usr.sbin/syspatch/syspatch.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: syspatch.sh,v 1.168 2023/12/13 17:50:23 ajacoutot Exp $ +# $OpenBSD: syspatch.sh,v 1.169 2025/10/27 16:30:24 deraadt Exp $ # # Copyright (c) 2016, 2017 Antoine Jacoutot # @@ -91,10 +91,15 @@ checkfs() set +e # ignore errors due to: # - nonexistent files (i.e. syspatch is installing new files) # - broken interpolation due to bogus devices like remote filesystems - eval $(cd / && - stat -qf "_dev=\"\${_dev} %Sd\"; - local %Sd=\"\${%Sd:+\${%Sd}\+}%Uz\"" ${_files}) \ - 2>/dev/null + for _f in ${_files}; do + _fdev=$(df /${_f} 2>/dev/null | grep "^/dev/" | \ + cut -d' ' -f1 | cut -d/ -f3) + [[ -n ${_fdev} ]] || continue + _dev="${_dev} ${_fdev}" + eval $(stat -qf "local ${_fdev}=\$((\$${_fdev}+%Uz))" /${_f} ) \ + 2>/dev/null + + done set -e for _d in $(printf '%s\n' ${_dev} | sort -u); do