Skip to content

Commit 705993e

Browse files
committed
allow setting legacy boot flag on gpt disks
1 parent ea31930 commit 705993e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/BuildInterface.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ const ContentWriter = struct {
155155
.gpt_part_table => |data| {
156156
try cw.code.writeAll("gpt-part\n");
157157

158+
if(data.legacy_bootable) {
159+
try cw.code.writeAll(" legacy-bootable\n");
160+
}
161+
158162
for (data.partitions) |part| {
159163
try cw.code.writeAll(" part\n");
160164
try cw.code.writeAll(" type ");
@@ -353,6 +357,7 @@ pub const MbrPartTable = struct {
353357
};
354358

355359
pub const GptPartTable = struct {
360+
legacy_bootable: bool = false,
356361
partitions: []const Partition,
357362

358363
pub const Partition = struct {

src/components/part/GptPartitionTable.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const PartTable = @This();
77
const block_size = 512; // TODO support other block sizes
88

99
disk_id: ?Guid,
10+
legacy_bootable: bool = false,
1011
partitions: []Partition,
1112

1213
pub fn parse(ctx: dim.Context) !dim.Content {
@@ -22,6 +23,7 @@ pub fn parse(ctx: dim.Context) !dim.Content {
2223
guid,
2324
part,
2425
endgpt,
26+
@"legacy-bootable",
2527
});
2628
switch (kw) {
2729
.guid => {
@@ -33,6 +35,7 @@ pub fn parse(ctx: dim.Context) !dim.Content {
3335
return ctx.report_fatal_error("Invalid disk GUID: {}", .{err});
3436
},
3537
.part => (try partitions.addOne()).* = try parsePartition(ctx),
38+
.@"legacy-bootable" => pt.legacy_bootable = true,
3639
.endgpt => break :loop,
3740
}
3841
}
@@ -220,7 +223,7 @@ pub fn render(table: *PartTable, stream: *dim.BinaryStream) dim.Content.RenderEr
220223
.partitions = .{ .{
221224
.offset = block_size,
222225
.size = null,
223-
.bootable = false,
226+
.bootable = table.legacy_bootable,
224227
.type = 0xee,
225228
.contains = .empty,
226229
}, null, null, null },

0 commit comments

Comments
 (0)