From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 7/7] fastboot: evaluate fastboot partitions when used
Date: Thu, 15 Feb 2024 08:47:57 +0100 [thread overview]
Message-ID: <20240215074757.960200-8-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240215074757.960200-1-s.hauer@pengutronix.de>
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@pengutronix.de>
---
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);
pr_debug("getvar: \"%s\"\n", cmd);
if (!strcmp_l1(cmd, "all")) {
- list_for_each_entry(var, &fb->variables, list) {
+ list_for_each_entry(var, &fb->variables, list)
fastboot_tx_print(fb, FASTBOOT_MSG_INFO, "%s: %s",
var->name, var->value);
- }
+
+ list_for_each_entry(var, &partition_list, list)
+ fastboot_tx_print(fb, FASTBOOT_MSG_INFO, "%s: %s",
+ var->name, var->value);
+
fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
- return;
+ goto out;
}
list_for_each_entry(var, &fb->variables, list) {
if (!strcmp(cmd, var->name)) {
fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, var->value);
- return;
+ goto out;
+ }
+ }
+
+ list_for_each_entry(var, &partition_list, list) {
+ if (!strcmp(cmd, var->name)) {
+ fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, var->value);
+ goto out;
}
}
fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
+out:
+ fastboot_free_variables(&partition_list);
}
int fastboot_handle_download_data(struct fastboot *fb, const void *buffer,
--
2.39.2
next prev parent reply other threads:[~2024-02-15 7:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 7:47 [PATCH 0/7] Detect partition changes at runtime Sascha Hauer
2024-02-15 7:47 ` [PATCH 1/7] fs: move cdev open count to cdev_open()/cdev_close() Sascha Hauer
2024-02-15 7:47 ` [PATCH 2/7] common: partitions: efi: fix memory leak Sascha Hauer
2024-02-15 7:47 ` [PATCH 3/7] partition: allow to reparse a partition table Sascha Hauer
2024-02-15 11:07 ` Marco Felsch
2024-02-16 11:14 ` Sascha Hauer
2024-02-15 7:47 ` [PATCH 4/7] block: reparse partition table when necessary Sascha Hauer
2024-02-15 12:52 ` Marco Felsch
2024-02-16 11:16 ` Sascha Hauer
2024-02-15 7:47 ` [PATCH 5/7] fastboot: pass list to fb_addvar() Sascha Hauer
2024-02-15 7:47 ` [PATCH 6/7] fastboot: add function to free a list of fastboot variables Sascha Hauer
2024-02-15 7:47 ` Sascha Hauer [this message]
2024-02-15 12:51 ` [PATCH 7/7] fastboot: evaluate fastboot partitions when used Marco Felsch
2024-02-16 11:15 ` Sascha Hauer
2024-02-15 8:31 ` [PATCH 0/7] Detect partition changes at runtime Ahmad Fatoum
2024-02-15 12:54 ` Marco Felsch
2024-02-16 11:13 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240215074757.960200-8-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox