On Thu, Feb 15, 2024 at 01:51:18PM +0100, Marco Felsch wrote: > On 24-02-15, Sascha Hauer wrote: > > So far we have evaluated the fastboot partition description during > > initialization of the fastboot gadget. Let's make this more flexible > > and parse it when actually needed. > > This gives us the possibility to first write an image including a > > partition table to a disk and afterwards write an image to a single > > partition created by the first whole disk write. > > > > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> > > --- > > common/fastboot.c | 40 +++++++++++++++++++++++++--------------- > > 1 file changed, 25 insertions(+), 15 deletions(-) > > > > diff --git a/common/fastboot.c b/common/fastboot.c > > index f41c02a576..acf138af8a 100644 > > --- a/common/fastboot.c > > +++ b/common/fastboot.c > > @@ -80,7 +80,7 @@ static struct fb_variable *fb_addvar(struct fastboot *fb, struct list_head *list > > return var; > > } > > > > -static int fastboot_add_partition_variables(struct fastboot *fb, > > +static int fastboot_add_partition_variables(struct fastboot *fb, struct list_head *list, > > struct file_list_entry *fentry) > > { > > struct stat s; > > @@ -152,9 +152,9 @@ static int fastboot_add_partition_variables(struct fastboot *fb, > > if (ret) > > return ret; > > > > - var = fb_addvar(fb, &fb->variables, "partition-size:%s", fentry->name); > > + var = fb_addvar(fb, list, "partition-size:%s", fentry->name); > > fb_setvar(var, "%08zx", size); > > - var = fb_addvar(fb, &fb->variables, "partition-type:%s", fentry->name); > > + var = fb_addvar(fb, list, "partition-type:%s", fentry->name); > > fb_setvar(var, "%s", type); > > > > return ret; > > @@ -162,8 +162,6 @@ static int fastboot_add_partition_variables(struct fastboot *fb, > > > > int fastboot_generic_init(struct fastboot *fb, bool export_bbu) > > { > > - int ret; > > - struct file_list_entry *fentry; > > struct fb_variable *var; > > > > INIT_LIST_HEAD(&fb->variables); > > @@ -186,12 +184,6 @@ int fastboot_generic_init(struct fastboot *fb, bool export_bbu) > > if (export_bbu) > > bbu_append_handlers_to_file_list(fb->files); > > > > - file_list_for_each_entry(fb->files, fentry) { > > - ret = fastboot_add_partition_variables(fb, fentry); > > - if (ret) > > - return ret; > > - } > > - > > return 0; > > } > > > > @@ -305,26 +297,44 @@ static int strcmp_l1(const char *s1, const char *s2) > > static void cb_getvar(struct fastboot *fb, const char *cmd) > > { > > struct fb_variable *var; > > + LIST_HEAD(partition_list); > > + struct file_list_entry *fentry; > > + > > + file_list_for_each_entry(fb->files, fentry) > > + fastboot_add_partition_variables(fb, &partition_list, fentry); > > Albeit we can ignore it, I would check the return code and print a > warning like: > > file_list_for_each_entry(fb->files, fentry) { > int ret; > > ret = fastboot_add_partition_variables(fb, &partition_list, fentry); > if (ret) { > pr_warn("Failed to add partition variables"); > return; > } > } Yes, did it like this. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |