entries: report a Windows install as a boot entry of its own

A Windows image has no vmlinuz, so `boot::scan` found nothing and every
command could only answer "no boot artifacts" — indistinguishable from a
Linux image whose /boot we failed to parse. A VM manager needs that
difference: there is no kernel to direct-boot, and the image can only be
started as a plain disk under UEFI firmware.

Windows is not a separate question, so it doesn't get a separate command:
it is another entry in `entries`/`boot-info`, carrying what starting it
takes (firmware, architecture, boot manager) where a Linux entry carries
kernel/initrd/cmdline. JSON entries gain `type` ("linux"/"windows") plus
`firmware`/`arch`/`loader`, null on the kind they don't apply to; the
array shape is unchanged, so existing consumers keep parsing.

An entry comes either from a config's `chainloader` item (os-prober's
dual-boot menu already declares Windows) or, when nothing declares it,
from detection. Windows keeps its system files on NTFS, which we
deliberately don't read, so detection works from the readable parts: the
boot manager on the FAT ESP — whose PE machine field also gives the guest
architecture — partition types only Windows creates, NTFS/ReFS magic,
and, for BIOS installs, Windows' MBR bootstrap together with a VBR that
chains to BOOTMGR/NTLDR.

Keeping chainloader items also fixes a silent wrong answer: they have no
kernel, so drop_stale_entries deleted them, and a `set default` pointing
at Windows fell back to the first Linux entry with no hint. On a dual-boot
image lbx now reports what GRUB would actually boot.

Supporting changes: fsys detects ntfs/exfat/refs (and still never reads
them), GPT/MBR learn the Microsoft partition types, and Partition gains a
machine-readable `type_id` so callers match on the type instead of on
`kind`'s wording. scripts/make-windows-test-image.sh builds the three
layouts — uefi, bios, dual — this was verified against.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kh6FTGzsmY3wv9Kb8Deeah
This commit is contained in:
HuJK 2026-09-09 02:53:19 +08:00
commit e5950ee1f0
12 changed files with 1114 additions and 73 deletions