From 95cd286e5018e6d12bae869406e38397a3d069c1 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Tue, 18 Aug 2026 22:10:28 -0400 Subject: fwstart: make the directory before mounting on it, and let go of the console if(! test -d /mnt/fw) mntgen /mnt/fw mount(2) needs its mount point to exist, so mntgen cannot create /mnt/fw -- and this ran it only when /mnt/fw was missing, which is exactly the case where it fails: mntgen: mount /tmp/mg/fw: file does not exist: '/tmp/mg' So on a machine that had never had a /mnt/fw, the control directories never appeared, and fw's own "not touching the card until the mountpoint exists" check then refused every card in the file. The script has never worked on a fresh machine. It has also never been run by the suite, which is the other half of why nobody noticed. Now the directory first, then mntgen only if it is not already there -- under mntgen every name exists, which is the test. Both mntgen and fw leave a server behind, and a server started from a shell keeps that shell's descriptors, so at boot they sit on the console's input and it reads as a wedged terminal. This is the trap CLAUDE.md documents; the script was walking into it. They get /dev/null. Three checks, and fwstart now gets run at all: a control directory appears, a card that is not there is reported and skipped, and nothing left running holds the descriptors we started it with. The first fails against the old script. The third does not, because the old script never started anything for want of the directory -- it guards the fix from here, not the bug that was there. Co-Authored-By: Claude Opus 5 --- fw/lib/fwstart | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'fw/lib') diff --git a/fw/lib/fwstart b/fw/lib/fwstart index 00b4d3a..ce89691 100755 --- a/fw/lib/fwstart +++ b/fw/lib/fwstart @@ -38,9 +38,23 @@ fn rulesfor { ' $cfg } -# each card gets its own control directory; mntgen makes them appear +# Each card gets its own control directory; mntgen makes them appear. +# +# mount(2) needs the mount point to exist, so mntgen cannot make /mnt/fw +# and this used to run it only when /mnt/fw was missing - which is the +# one case where it fails. So the directory first, and then mntgen only +# if it is not already there: under mntgen every name exists, which is +# the test. +# +# mntgen and fw both leave a server behind, and a server started from a +# shell keeps that shell's file descriptors. Started from the console - +# or from a serial shell, which is where this gets tried first - that +# means a daemon sitting on the console's input, which looks exactly +# like a wedged terminal. Give them nothing to hold. if(! test -d /mnt/fw) - mntgen /mnt/fw + mkdir -p /mnt/fw +if(! test -d /mnt/fw/is-mntgen-here) + mntgen /mnt/fw /dev/null >[2]/dev/null for(name in `{cards}){ dev=/net/$name @@ -52,7 +66,7 @@ for(name in `{cards}){ if not if(! test -f $rules) echo fwstart: $rules missing, $name skipped >[1=2] if not { - fw -m /mnt/fw/$name -e $dev $rules + fw -m /mnt/fw/$name -e $dev $rules /dev/null if(~ $status '') echo fwstart: $name filtered by $rules if not -- cgit v1.2.3