Skip to content

Commit

Permalink
Support ESPs on ISO images
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Jul 4, 2024
1 parent 3beac42 commit e5f7552
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/boot/disk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ pub fn probe(
for (mbr.partitions(), 1..) |part, mbr_partn| {
const part_type = MbrPartitionType.fromValue(part.partType()) orelse continue;

if (part.isBootable() and
if ((part.isBootable() and
// BootLoaderSpec uses this partition type for MBR, see
// https://uapi-group.org/specifications/specs/boot_loader_specification/#the-partitionsl.
(part_type == .LinuxExtendedBoot or
// QEMU uses this partition type when using a FAT
// emulated drive with `-drive file=fat:rw:some/directory`.
part_type == .Fat16))
part_type == .Fat16)) or
// Many ISOs have this MBR table setup where the partition type
// is ESP and it is marked as non-bootable.
part_type == .EfiSystemPartition)
{
break :b mbr_partn;
}
Expand Down
2 changes: 2 additions & 0 deletions src/disk/partition_table.zig
Original file line number Diff line number Diff line change
Expand Up @@ -959,12 +959,14 @@ pub const MbrPartitionType = enum {
Fat16,
ProtectedMbr,
LinuxExtendedBoot,
EfiSystemPartition,

pub fn fromValue(val: u8) ?@This() {
return switch (val) {
0x06 => .Fat16,
0xea => .LinuxExtendedBoot,
0xee => .ProtectedMbr,
0xef => .EfiSystemPartition,
else => return null,
};
}
Expand Down

0 comments on commit e5f7552

Please sign in to comment.