Re: [PATCH v1 1/2] part: Add a function to find ESP partition
On Thu, 2023-09-14 at 12:29 -0400, Tom Rini wrote: > On Thu, Sep 14, 2023 at 03:38:20PM +0530, 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 > > Reviewed-by: Heinrich Schuchardt > > > > --- > > disk/part.c| 16 > > include/part.h | 10 ++ > > 2 files changed, 26 insertions(+) > > > > diff --git a/disk/part.c b/disk/part.c > > index 72241b7b23..2be0866671 100644 > > --- a/disk/part.c > > +++ b/disk/part.c > > @@ -841,3 +841,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, ); > > + if (!ret && (info.bootable & > > PART_EFI_SYSTEM_PARTITION)) > > + return p; > > + } > > + > > + return 0; > > +} > > diff --git a/include/part.h b/include/part.h > > index db34bc6bb7..036f9fd762 100644 > > --- a/include/part.h > > +++ b/include/part.h > > @@ -689,6 +689,13 @@ int part_get_type_by_name(const char *name); > > * @return first bootable partition, or 0 if there is none > > */ > > int part_get_bootable(struct blk_desc *desc); > > +/** > > Missing blank line? > Ok, I will add it.
Re: [PATCH v1 1/2] part: Add a function to find ESP partition
On Thu, Sep 14, 2023 at 03:38:20PM +0530, 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 > Reviewed-by: Heinrich Schuchardt > --- > disk/part.c| 16 > include/part.h | 10 ++ > 2 files changed, 26 insertions(+) > > diff --git a/disk/part.c b/disk/part.c > index 72241b7b23..2be0866671 100644 > --- a/disk/part.c > +++ b/disk/part.c > @@ -841,3 +841,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, ); > + if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION)) > + return p; > + } > + > + return 0; > +} > diff --git a/include/part.h b/include/part.h > index db34bc6bb7..036f9fd762 100644 > --- a/include/part.h > +++ b/include/part.h > @@ -689,6 +689,13 @@ int part_get_type_by_name(const char *name); > * @return first bootable partition, or 0 if there is none > */ > int part_get_bootable(struct blk_desc *desc); > +/** Missing blank line? -- Tom signature.asc Description: PGP signature
[PATCH v1 1/2] part: Add a function to find ESP partition
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 Reviewed-by: Heinrich Schuchardt --- disk/part.c| 16 include/part.h | 10 ++ 2 files changed, 26 insertions(+) diff --git a/disk/part.c b/disk/part.c index 72241b7b23..2be0866671 100644 --- a/disk/part.c +++ b/disk/part.c @@ -841,3 +841,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, ); + if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION)) + return p; + } + + return 0; +} diff --git a/include/part.h b/include/part.h index db34bc6bb7..036f9fd762 100644 --- a/include/part.h +++ b/include/part.h @@ -689,6 +689,13 @@ int part_get_type_by_name(const char *name); * @return first bootable partition, or 0 if there is none */ 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 + */ +int part_get_esp(struct blk_desc *desc); #else static inline int part_driver_get_count(void) @@ -700,6 +707,9 @@ static inline struct part_driver *part_driver_get_first(void) static inline bool part_get_bootable(struct blk_desc *desc) { return false; } +static int part_get_esp(struct blk_desc *desc) +{ return 0; } + #endif /* CONFIG_PARTITIONS */ #endif /* _PART_H */ -- 2.34.1