disk: dos: Add all options for EFI System Partitions
PATCH v3 1/1 disk: dos: Add all options for EFI System Partitions
The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of 0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of 0xef so also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.
---
v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
disk/part_dos.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
disk/part_dos.c +13 -2
@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p) {int ret =0 ; -if (p->sys_ind ==0xef ) +switch (p->sys_ind) { +case 0x01 : +case 0x06 : +case 0x0b : +case 0x0c : +case 0xef : ret |=PART_EFI_SYSTEM_PARTITION ; -if (p->boot_ind ==0x80 ) +break ; +case 0x80 : ret |=PART_BOOTABLE ; +break ; +default : +break ; + } +return ret; }
Signature · 1 line
2.44.0
Quoted 2 lines
From: Peter Robinson <[email protected]>
Date: Sat, 2 Mar 2024 10:54:36 +0000
Hi Peter,
Quoted 8 lines
The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of
0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of0xefso also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.Signed-off-by Peter Robinson <[email protected]>
Quoted 8 lines
---
v2:
- Add0x0coption
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
Sorry, still not quite right...
Quoted 10 lines
disk/part_dos.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)disk/part_dos.c +0
-0@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p) {int ret =0 ;
disk/part_dos.c static int get_bootable(dos_partition_t *p) · line 45
Quoted 10 lines
disk/part_dos.c +6
-2-if (p->sys_ind ==0xef ) +switch (p->sys_ind) { +case 0x01 : +case 0x06 : +case 0x0b : +case 0x0c : +case 0xef : ret |=PART_EFI_SYSTEM_PARTITION ; -if (p->boot_ind ==0x80 )
The boot flag is part of p->boot_ind but the switch is for p->sys_ind (the partition type). You can't handle the boot flag in the same switch! Probably best to keep the if-statement for that bit.
Quoted 15 lines
disk/part_dos.c +7
-0+break ; +case 0x80 : ret |=PART_BOOTABLE ; +break ; +default : +break ; + } +return ret; }Signature · 1 line
2.44.0