From c7d92071e1dd11c45999457b16554b4abaa73b28 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 2 Aug 2026 15:21:34 +0200 Subject: v0.5.5: crash reports go to a dedicated CRASHLOG USB stick The fault handler now writes crash.log to the volume labeled CRASHLOG (label-selected via fat::crash_vol), falling back to slot 0. On real hardware the boot USB may be unwritable, so a second stick labeled CRASHLOG survives the write; the shell auto-prints the previous crash report from it at next boot (read_crash_log resolves /disk//crash.log through the FAT path, since Disk nodes hold no cached children). - fat.rs: volume_label() + crash_vol() (no allocation) - fs.rs: write_crash_log targets crash_vol(); read_crash_log prefers the CRASHLOG disk node; drop now-unused first_disk() - mkdisk.sh: --label option - test-fault.sh: boots with a dedicated CRASHLOG stick (mkfs -F 32 -n CRASHLOG), verifies crash.log lands there and NOT on the ESP --- scripts/test-fault.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'scripts/test-fault.sh') diff --git a/scripts/test-fault.sh b/scripts/test-fault.sh index 49ba791..59f741f 100755 --- a/scripts/test-fault.sh +++ b/scripts/test-fault.sh @@ -52,12 +52,18 @@ echo "==> 2/5 deploy to ESP" mkdir -p "$ESP_DIR/EFI/BOOT" cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" -echo "==> 3/5 boot QEMU (headless)" +echo "==> 3/6 boot QEMU (headless, + dedicated CRASHLOG stick)" kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true sleep 1 rm -f "$SOCK" "$LOG" +# A second FAT32 stick labeled CRASHLOG: crash reports must land here +# (label-selected by the kernel), not on the boot device. +CRASH_IMG=/tmp/rsdos-crash.img +"$SCRIPT_DIR/mkdisk.sh" --fresh --label CRASHLOG --no-seed "$CRASH_IMG" >/dev/null "$QEMU" -bios "$OVMF" \ -drive file=fat:rw:"$ESP_DIR",format=raw \ + -drive file="$CRASH_IMG",format=raw,if=none,id=crash \ + -device ide-hd,drive=crash,bus=ide.2 \ -serial file:"$LOG" \ -monitor unix:"$SOCK",server,nowait \ -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ @@ -66,11 +72,12 @@ echo $! >"$QPID" wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" -echo "==> 4/5 boot diagnostics present" +echo "==> 4/6 boot diagnostics present" grep -aq "gop: fb base=" "$LOG" || fail "fb geometry diagnostic missing" grep -aq "gop: mode .* selected" "$LOG" || fail "mode-selection diagnostic missing" +grep -aq "CRASHLOG" "$LOG" || fail "CRASHLOG stick not mounted" -echo "==> 5/5 inject a page fault (fault command)" +echo "==> 5/6 inject a page fault (fault command)" python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "clear" \ "fault" @@ -83,8 +90,19 @@ grep -aq "cr2=0x400000000000" "$LOG" || fail "CR2 not reported (faulting address grep -aq "task=0 \"shell\"" "$LOG" || fail "faulting task not identified" grep -aq "!!! halting" "$LOG" || fail "no halt message" +echo "==> 6/6 crash.log persisted on the CRASHLOG stick" +grep -aq "crashlog: vol .* (CRASHLOG)" "$LOG" || fail "crashlog did not target the CRASHLOG stick" +grep -aq "crashlog: wrote" "$LOG" || fail "crashlog write did not complete" +mdir -i "$CRASH_IMG" "::" 2>/dev/null | grep -aqi "crash" \ + || fail "crash.log missing on the CRASHLOG stick" +# The boot ESP must NOT receive the crash log. +if [ -f "$ESP_DIR/crash.log" ]; then + fail "crash.log landed on the boot ESP instead of the CRASHLOG stick" +fi + # The screen dump itself is exercised in-kernel (dump_lines); the serial # path sharing the same format line is verified above. echo "" -echo "PASS — fault dump works (vec, err, rip, cr2, task → screen + serial)" -echo " every CPU exception now halts with a diagnosable dump, not a freeze" +echo "PASS — fault dump + crash.log on the CRASHLOG stick" +echo " every CPU exception halts with a diagnosable dump; the report" +echo " survives reboot on the dedicated CRASHLOG volume" -- cgit v1.2.3