All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Protsenko <semen.protsenko@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/3] fastboot: Check if partition really exist in getvar_has_slot()
Date: Thu, 13 Jun 2019 00:20:01 +0300	[thread overview]
Message-ID: <CAKaJLVtCbeN771-=3W0D-T4a_7i0ooP8qYYEA6f7o4zYfjkd0Q@mail.gmail.com> (raw)
In-Reply-To: <20190612211411.15250-4-semen.protsenko@linaro.org>

Hi Tom,

We have broken fastboot right now... Can we please apply this series,
so that it appears in v2019.07?

Thanks!

On Thu, Jun 13, 2019 at 12:14 AM Sam Protsenko
<semen.protsenko@linaro.org> wrote:
>
> From: Igor Opaniuk <igor.opaniuk@toradex.com>
>
> Currently getvar_has_slot() invocation for "boot" and "system"
> partitions always returns affirmative response regardless the fact of
> existence of these partitions, which leads to impossibility to flash them
> on old non-A/B AOSP setups, where _a/_b suffixes aren't used:
>
> $ fastboot flash boot boot.img
> Sending 'boot__a' (11301 KB)    OKAY [  0.451s]
> Writing 'boot__a'               FAILED (remote: 'cannot find partition')
> fastboot: error: Command failed
>
> Although partition layout is:
> -> part list mmc 0
> Partition Map for MMC device 0  --   Partition Type: EFI
>
> Part    Start LBA       End LBA         Name
>         Attributes
>         Type GUID
>         Partition GUID
>   1     0x00000800      0x000107ff      "boot"
>         attrs:  0x0000000000000000
>         type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>         guid:   ea2e2470-db4a-d646-b828-10167f736d63
>   2     0x00010800      0x000127ff      "environment"
>         attrs:  0x0000000000000000
>         type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>         guid:   10a819d2-6004-3d48-bd87-114e2a796db9
>   3     0x00012800      0x0001a7ff      "recovery"
>         attrs:  0x0000000000000000
>         type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>         guid:   9ea116e4-8a34-0c48-8cf5-2fe9480f56cd
>   4     0x0001a800      0x0031a7ff      "system"
>         attrs:  0x0000000000000000
> ......
>
> This patch adds checks of existence for requested partitions
> on eMMC/NAND.
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  drivers/fastboot/fb_getvar.c | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
> index b23880089e..563bda0088 100644
> --- a/drivers/fastboot/fb_getvar.c
> +++ b/drivers/fastboot/fb_getvar.c
> @@ -179,11 +179,29 @@ static void getvar_slot_suffixes(char *var_parameter, char *response)
>
>  static void getvar_has_slot(char *part_name, char *response)
>  {
> -       if (part_name && (!strcmp(part_name, "boot") ||
> -                         !strcmp(part_name, "system")))
> +       char part_name_wslot[PART_NAME_LEN];
> +       size_t len;
> +       int r;
> +
> +       if (!part_name)
> +               goto no;
> +
> +       /* Append "_a" prefix to part_name */
> +       len = strlcpy(part_name_wslot, part_name, PART_NAME_LEN - 3);
> +       if (len > PART_NAME_LEN - 3) {
> +               fastboot_fail("too long partition name", response);
> +               return;
> +       }
> +       strcat(part_name_wslot, "_a");
> +
> +       /* Check if this partition exists */
> +       r = getvar_get_part_info(part_name_wslot, response, NULL);
> +       if (r >= 0) {
>                 fastboot_okay("yes", response);
> -       else
> -               fastboot_okay("no", response);
> +               return;
> +       }
> +no:
> +       fastboot_okay("no", response);
>  }
>
>  #if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
> --
> 2.20.1
>

  reply	other threads:[~2019-06-12 21:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 21:14 [U-Boot] [PATCH v2 0/3] fastboot: Fix getvar "has-slot" and cleanup Sam Protsenko
2019-06-12 21:14 ` [U-Boot] [PATCH v2 1/3] fastboot: Use const qualifier for char *part_name Sam Protsenko
2019-06-13  5:45   ` Lukasz Majewski
2019-06-13  8:12   ` Igor Opaniuk
2019-06-12 21:14 ` [U-Boot] [PATCH v2 2/3] fastboot: getvar: Refactor fastboot_*_get_part_info() usage Sam Protsenko
2019-06-13  5:46   ` Lukasz Majewski
2019-06-13  8:11   ` Igor Opaniuk
2019-06-12 21:14 ` [U-Boot] [PATCH v2 3/3] fastboot: Check if partition really exist in getvar_has_slot() Sam Protsenko
2019-06-12 21:20   ` Sam Protsenko [this message]
2019-06-13  5:47     ` Lukasz Majewski
2019-06-13 12:01       ` Lukasz Majewski
2019-06-13 18:12         ` Sam Protsenko
2019-06-13  5:46   ` Lukasz Majewski
2019-06-13 11:30   ` Eugeniu Rosca

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='CAKaJLVtCbeN771-=3W0D-T4a_7i0ooP8qYYEA6f7o4zYfjkd0Q@mail.gmail.com' \
    --to=semen.protsenko@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.