Re: [PATCH v2 1/2] part: Add a function to find ESP partition

mchitale
2024-01-19T15:32:47Z

Hi Heinrich,

On Tue, 2024-01-16 at 17:14 +0100, Heinrich Schuchardt wrote:
> On 16.01.24 14:45, Heinrich Schuchardt wrote:
> > On 16.01.24 13:36, Mayuresh Chitale wrote:
> > > If a disk has an EFI system partition (ESP) then it can be used
> > > to
> > > locate the boot files. Add a function to find the ESP.
> > >
> > > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > > Reviewed-by: Heinrich Schuchardt <
> > > heinrich.schuchardt@canonical.com>
>
> I ran your patches through Gitlab CI and some issues came up:
>
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/771497
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/771498
>
> Could you, please, have a look at it.

I looked into the log files below:
https://u-boot.source-pages.denx.de/-/custodians/u-boot-efi/-/jobs/771497/artifacts/test-log.html
https://u-boot.source-pages.denx.de/-/custodians/u-boot-efi/-/jobs/771498/artifacts/test-log.html

If those logs are correct, I think the failure is probably because I
removed fallback to the user provided partition in case the ESP probe
failed for some reason. I think that fallback is required here.
>
> Best regards
>
> Heinrich
>
> > > ---
> > > disk/part.c | 16 ++++++++++++++++
> > > include/part.h | 11 +++++++++++
> > > 2 files changed, 27 insertions(+)
> > >
> > > diff --git a/disk/part.c b/disk/part.c
> > > index 36b88205eca..6b1fbc18637 100644
> > > --- a/disk/part.c
> > > +++ b/disk/part.c
> > > @@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
> > > return 0;
> > > }
> > > +
> > > +int part_get_esp(struct blk_desc *desc)
> > > +{
> > > + struct disk_partition info;
> > > + int p;
> > > +
> > > + for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
> > > + int ret;
> > > +
> > > + ret = part_get_info(desc, p, &info);
> > > + if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
> > > + return p;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > diff --git a/include/part.h b/include/part.h
> > > index db34bc6bb7d..30e049c8f19 100644
> > > --- a/include/part.h
> > > +++ b/include/part.h
> > > @@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
> > > */
> > > int part_get_bootable(struct blk_desc *desc);
> > > +/**
> > > + * part_get_esp() - Find the EFI system partition
> > > + *
> > > + * @desc: Block-device descriptor
> > > + * @Return the EFI system partition, or 0 if there is none
> >
> > We want to be able to add the include to our API documentation.
> > This
> > requires adhering to the Sphinx documentation style.
> >
> > %s/@Return the/Return:/
> >
> > Cf.
> > https://www.kernel.org/doc/html/v6.7/doc-guide/kernel-doc.html#function-documentation
> >
> > Best regards
> >
> > Heinrich
> >
> > > + */
> > > +int part_get_esp(struct blk_desc *desc);
> > > +
> > > #else
> > > static inline int part_driver_get_count(void)
> > > { return 0; }
> > > @@ -700,6 +708,9 @@ static inline struct part_driver
> > > *part_driver_get_first(void)
> > > static inline bool part_get_bootable(struct blk_desc *desc)
> > > { return false; }
> > > +static inline bool part_get_esp(struct blk_desc *desc)
> > > +{ return false; }
> > > +
> > > #endif /* CONFIG_PARTITIONS */
> > > #endif /* _PART_H */