bootsmith_core/plan.rs
1//! `WritePlan` is the typed, fully-resolved description of "what we are going
2//! to do to this device." Building a plan is deterministic and pure; executing
3//! it is the only step that needs a real `Device`.
4//!
5//! The plan is the unit that gets dry-run, golden-tested, and executed.
6
7use std::path::PathBuf;
8
9/// The four boot-record families bootsmith understands. Resolved from
10/// `ModeRequest::Auto` via `bootsmith-iso` inspection, or supplied directly by
11/// the user.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum BootMode {
14 /// Raw write of a hybrid ISO9660 image. Most modern Linux/BSD distros.
15 Hybrid,
16
17 /// MBR + active FAT32 + bootmgr-loading PBR + file copy. Win 7 through 11.
18 Windows,
19
20 /// NT-family XP/2003-style install USB using GRUB4DOS + FiraDisk:
21 /// RAM-map the original ISO as a virtual CD, expose it to protected-mode
22 /// setup with FiraDisk, and drive-swap so the internal HDD is first.
23 WindowsNtXp,
24
25 /// Windows 2000 (NT 5.0) install USB. Same GRUB4DOS + RAM-mapped ISO
26 /// chain as [`WindowsNtXp`], but with SVBus in place of FiraDisk —
27 /// FiraDisk's SCSI miniport collides with the NT 5.0 storage stack
28 /// (0x7B INACCESSIBLE_BOOT_DEVICE / 0xC0000034). See
29 /// docs/WIN2K_SVBUS.md.
30 Windows2000,
31
32 /// MBR + active FAT32 + syslinux boot code + file copy. Older Linux ISOs
33 /// that aren't hybrid (e.g. some isolinux-only distros).
34 IsolinuxLinux,
35
36 /// GPT + ESP + EFI directory copy. Modern UEFI-only installers.
37 UefiOnly,
38}
39
40impl BootMode {
41 pub fn as_str(&self) -> &'static str {
42 match self {
43 BootMode::Hybrid => "hybrid",
44 BootMode::Windows => "windows",
45 BootMode::WindowsNtXp => "windows-ntxp",
46 BootMode::Windows2000 => "windows-2000",
47 BootMode::IsolinuxLinux => "linux",
48 BootMode::UefiOnly => "uefi",
49 }
50 }
51}
52
53#[derive(Debug, Clone)]
54pub struct WritePlan {
55 pub iso_path: PathBuf,
56 pub iso_bytes: u64,
57 pub mode: BootMode,
58 pub label: String,
59}