diff mbox series

[v2] disk: dos: Add all options for EFI System Partitions

Message ID 20240225141457.48209-1-pbrobinson@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series [v2] disk: dos: Add all options for EFI System Partitions | expand

Commit Message

Peter Robinson Feb. 25, 2024, 2:14 p.m. UTC
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.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---

v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement

 disk/part_dos.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Mark Kettenis Feb. 25, 2024, 2:23 p.m. UTC | #1
> From: Peter Robinson <pbrobinson@gmail.com>
> Date: Sun, 25 Feb 2024 14:14:55 +0000
> 
> 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.
> 
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
> ---
> 
> v2:
> - Add 0x0c option
> - Make hex constants consistent
> - Move from if to switch statement

Erh...

>  disk/part_dos.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 567ead7511d..ab855adf347 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -40,10 +40,23 @@ static int get_bootable(dos_partition_t *p)
>  {
>  	int ret = 0;
>  
> -	if (p->sys_ind == 0xef)
> +	switch (p->sys_ind){
> +	case 0x01:
>  		ret |= PART_EFI_SYSTEM_PARTITION;
> -	if (p->boot_ind == 0x80)
> +	case 0x06:
> +		ret |= PART_EFI_SYSTEM_PARTITION;
> +	case 0x0b:
> +		ret |= PART_EFI_SYSTEM_PARTITION;
> +	case 0x0c:
> +		ret |= PART_EFI_SYSTEM_PARTITION;
> +	case 0xef:
> +		ret |= PART_EFI_SYSTEM_PARTITION;
> +	case 0x80:
>  		ret |= PART_BOOTABLE;
> +	default:
> +		break;
> +	}
> +

That really didn't go well.  The 0x80 check was for a different struct
member and there are missing break statements.  And I suppose the
suggestion to use a switch was to bunch up the EFI partition type
cases.

ENOCOFFEE?

>  	return ret;
>  }
>  
> -- 
> 2.43.2
> 
>
Peter Robinson March 2, 2024, 10:54 a.m. UTC | #2
On Sun, 25 Feb 2024 at 14:23, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>
> > From: Peter Robinson <pbrobinson@gmail.com>
> > Date: Sun, 25 Feb 2024 14:14:55 +0000
> >
> > 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.
> >
> > Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
> > ---
> >
> > v2:
> > - Add 0x0c option
> > - Make hex constants consistent
> > - Move from if to switch statement
>
> Erh...
>
> >  disk/part_dos.c | 17 +++++++++++++++--
> >  1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/disk/part_dos.c b/disk/part_dos.c
> > index 567ead7511d..ab855adf347 100644
> > --- a/disk/part_dos.c
> > +++ b/disk/part_dos.c
> > @@ -40,10 +40,23 @@ static int get_bootable(dos_partition_t *p)
> >  {
> >       int ret = 0;
> >
> > -     if (p->sys_ind == 0xef)
> > +     switch (p->sys_ind){
> > +     case 0x01:
> >               ret |= PART_EFI_SYSTEM_PARTITION;
> > -     if (p->boot_ind == 0x80)
> > +     case 0x06:
> > +             ret |= PART_EFI_SYSTEM_PARTITION;
> > +     case 0x0b:
> > +             ret |= PART_EFI_SYSTEM_PARTITION;
> > +     case 0x0c:
> > +             ret |= PART_EFI_SYSTEM_PARTITION;
> > +     case 0xef:
> > +             ret |= PART_EFI_SYSTEM_PARTITION;
> > +     case 0x80:
> >               ret |= PART_BOOTABLE;
> > +     default:
> > +             break;
> > +     }
> > +
>
> That really didn't go well.  The 0x80 check was for a different struct
> member and there are missing break statements.  And I suppose the
> suggestion to use a switch was to bunch up the EFI partition type
> cases.
>
> ENOCOFFEE?

It  was worse, no coffee and an early start for a flight.... OOPS!

> >       return ret;
> >  }
> >
> > --
> > 2.43.2
> >
> >
diff mbox series

Patch

diff --git a/disk/part_dos.c b/disk/part_dos.c
index 567ead7511d..ab855adf347 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -40,10 +40,23 @@  static int get_bootable(dos_partition_t *p)
 {
 	int ret = 0;
 
-	if (p->sys_ind == 0xef)
+	switch (p->sys_ind){
+	case 0x01:
 		ret |= PART_EFI_SYSTEM_PARTITION;
-	if (p->boot_ind == 0x80)
+	case 0x06:
+		ret |= PART_EFI_SYSTEM_PARTITION;
+	case 0x0b:
+		ret |= PART_EFI_SYSTEM_PARTITION;
+	case 0x0c:
+		ret |= PART_EFI_SYSTEM_PARTITION;
+	case 0xef:
+		ret |= PART_EFI_SYSTEM_PARTITION;
+	case 0x80:
 		ret |= PART_BOOTABLE;
+	default:
+		break;
+	}
+
 	return ret;
 }