public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Gary Bisson <gary.bisson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [PATCH] fastboot: getvar: fix partition-size return value
Date: Wed,  6 May 2020 10:12:28 +0200	[thread overview]
Message-ID: <20200506081228.8669-1-gary.bisson@boundarydevices.com> (raw)

The size returned by 'getvar partition-size' should be in bytes, not in
blocks as fastboot uses that value to generate empty partition when
running format [1].

[1]
https://android.googlesource.com/platform/system/core/+/refs/heads/android10-release/fastboot/fastboot.cpp#1500

Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
---
Hi,

Another test was to run 'fastboot getvar partition-size:system' on a
shipping Android phone, it will give you the size in bytes as well.

Regards,
Gary
---
 drivers/fastboot/fb_getvar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index 95cb434189..51a2bea86d 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -94,7 +94,7 @@ static const struct {
  *
  * @param[in] part_name Info for which partition name to look for
  * @param[in,out] response Pointer to fastboot response buffer
- * @param[out] size If not NULL, will contain partition size (in blocks)
+ * @param[out] size If not NULL, will contain partition size
  * @return Partition number or negative value on error
  */
 static int getvar_get_part_info(const char *part_name, char *response,
@@ -108,13 +108,13 @@ static int getvar_get_part_info(const char *part_name, char *response,
 	r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info,
 				       response);
 	if (r >= 0 && size)
-		*size = part_info.size;
+		*size = part_info.size * part_info.blksz;
 # elif CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
 	struct part_info *part_info;
 
 	r = fastboot_nand_get_part_info(part_name, &part_info, response);
 	if (r >= 0 && size)
-		*size = part_info->size;
+		*size = part_info->size * part_info.blksz;
 # else
 	fastboot_fail("this storage is not supported in bootloader", response);
 	r = -ENODEV;
-- 
2.26.2

             reply	other threads:[~2020-05-06  8:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  8:12 Gary Bisson [this message]
2020-06-24  9:00 ` [PATCH] fastboot: getvar: fix partition-size return value Gary Bisson
2020-08-26  9:01   ` Gary Bisson
2020-08-26  9:36     ` Lukasz Majewski
2020-08-26 10:14       ` Gary Bisson
2020-08-27  6:25         ` Lukasz Majewski
2020-08-27  7:46           ` Gary Bisson

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=20200506081228.8669-1-gary.bisson@boundarydevices.com \
    --to=gary.bisson@boundarydevices.com \
    --cc=u-boot@lists.denx.de \
    /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