Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk: rename all DOS type ID consts to match GUIDs #1099

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/otk/osbuild-gen-partition-table/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func makePartitionTableFromOtkInput(input *Input) (*disk.PartitionTable, error)
part.UUID = disk.EFISystemPartitionUUID
case otkdisk.PartTypeDOS:
part.Bootable = true
part.Type = disk.DosFat16B
part.Type = disk.FAT16BDOSID
default:
return nil, fmt.Errorf("unsupported partition type: %v", input)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/otk/osbuild-gen-partition-table/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func TestGenPartitionTableIntegrationPPC(t *testing.T) {
Name: "ppc-boot",
Bootable: true,
Size: "4 MiB",
PartType: disk.DosPRePID,
PartType: disk.PRepPartitionDOSID,
PartUUID: "",
},
{
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestGenPartitionTableIntegrationPPC(t *testing.T) {
Bootable: true,
Start: 1048576,
Size: 4194304,
Type: disk.DosPRePID,
Type: disk.PRepPartitionDOSID,
},
{
Start: 5242880,
Expand Down Expand Up @@ -497,7 +497,7 @@ func TestGenPartitionTableCustomizationExtraMp(t *testing.T) {
{
Start: 2148532224,
Size: 13744734208,
Type: "8e",
Type: disk.LVMPartitionDOSID,
Payload: &disk.LVMVolumeGroup{
Name: "rootvg",
Description: "created via lvm2 and osbuild",
Expand Down
40 changes: 21 additions & 19 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
// rounded to the next MiB.
DefaultGrainBytes = uint64(1048576) // 1 MiB

// UUIDs
// UUIDs for GPT disks
BIOSBootPartitionGUID = "21686148-6449-6E6F-744E-656564454649"
BIOSBootPartitionUUID = "FAC7F1FB-3E8D-4137-A512-961DE09A5549"

Expand All @@ -61,40 +61,42 @@ const (
// Extended Boot Loader Partition
XBootLDRPartitionGUID = "BC13C2FF-59E6-4262-A352-B275FD6F7172"

// DosFat16B used for the ESP-System partition
DosFat16B = "06"

// Partition type ID for any native Linux filesystem on dos
DosLinuxTypeID = "83"

// Partition type ID for LVM on dos
DosLVMTypeID = "8e"
// Partition type IDs for DOS disks

// Partition type ID for BIOS boot partition on dos.
// Type ID is for 'empty'.
// TODO: drop this completely when we convert the bios BOOT space to a
// partitionless gap/offset.
DosBIOSBootID = "00"
BIOSBootPartitionDOSID = "00"

// Partition type ID for any native Linux filesystem on dos
FilesystemLinuxDOSID = "83"

// FAT16BDOSID used for the ESP-System partition
FAT16BDOSID = "06"

// Partition type ID for LVM on dos
LVMPartitionDOSID = "8e"

// Partition type ID for ESP on dos
DosESPID = "ef"
EFISystemPartitionDOSID = "ef"

// Partition type ID for swap
DosSwapID = "82"
SwapPartitionDOSID = "82"

// Partition type ID for PRep on dos
DosPRePID = "41"
PRepPartitionDOSID = "41"
)

// pt type -> type -> ID mapping for convenience
var idMap = map[PartitionTableType]map[string]string{
PT_DOS: {
"bios": DosBIOSBootID,
"boot": DosLinuxTypeID,
"data": DosLinuxTypeID,
"esp": DosESPID,
"lvm": DosLVMTypeID,
"swap": DosSwapID,
"bios": BIOSBootPartitionDOSID,
"boot": FilesystemLinuxDOSID,
"data": FilesystemLinuxDOSID,
"esp": EFISystemPartitionDOSID,
"lvm": LVMPartitionDOSID,
"swap": SwapPartitionDOSID,
},
PT_GPT: {
"bios": BIOSBootPartitionGUID,
Expand Down
4 changes: 2 additions & 2 deletions pkg/disk/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func (p *Partition) IsBIOSBoot() bool {
return false
}

return p.Type == BIOSBootPartitionGUID || p.Type == DosBIOSBootID
return p.Type == BIOSBootPartitionGUID || p.Type == BIOSBootPartitionDOSID
}

func (p *Partition) IsPReP() bool {
if p == nil {
return false
}

return p.Type == DosPRePID || p.Type == PRePartitionGUID
return p.Type == PRepPartitionDOSID || p.Type == PRePartitionGUID
}

func (p *Partition) MarshalJSON() ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/disk/partition_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (pt *PartitionTable) ensureLVM() error {
if pt.Type == PT_GPT {
part.Type = LVMPartitionGUID
} else {
part.Type = "8e"
part.Type = LVMPartitionDOSID
}

} else {
Expand Down
Loading
Loading