Hi Sumit,

On 2026-09-28T06:40:33, Sumit Singh Dhami <[email protected]> wrote:
> cmd: gpt: report partition attributes via 'gpt setenv'
>
> 'gpt setenv' sets a series of gpt_partition_* environment variables
> describing a partition, but does not expose the GPT partition entry's
> attributes field.
>
> Set a new gpt_partition_attrs variable holding the full 64-bit
> attributes value as a hexadecimal string, when CONFIG_PARTITION_ATTR is
> enabled.
>
> Signed-off-by: Sumit Singh Dhami <[email protected]>
>
> cmd/gpt.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)

> diff --git a/cmd/gpt.c b/cmd/gpt.c
> @@ -796,6 +797,16 @@ static int gpt_setenv_part_variables(struct 
> disk_partition *pinfo, int i)
> +     if (CONFIG_IS_ENABLED(PARTITION_ATTR)) {
> +             char attrs_str[19];     /* "0x" + 16 hex digits + NUL */
> +
> +             snprintf(attrs_str, sizeof(attrs_str), "0x%016llx",
> +                     disk_partition_gpt_attr(pinfo));
> +             ret = env_set("gpt_partition_attrs", attrs_str);

The other hex variables set here (gpt_partition_addr,
gpt_partition_size, gpt_partition_entry) come from env_set_hex(), so
they have no 0x prefix and no zero padding. This one is formatted
differently, so scripts have to treat it specially. I suspect '%llx'
would be better so it matches the existing variables, unless there is
a reason for the prefix. What do you think?

> diff --git a/cmd/gpt.c b/cmd/gpt.c
> @@ -796,6 +797,16 @@ static int gpt_setenv_part_variables(struct 
> disk_partition *pinfo, int i)
> +             ret = env_set("gpt_partition_attrs", attrs_str);
> +             if (ret)
> +                     goto fail;
> +     }

Since you are adding a new feature you need a test, and this patch is
the natural place since it exposes the value where a test can check
it. Please can you enable CONFIG_PARTITION_ATTR in
configs/sandbox_defconfig and extend test_gpt_setenv() in
test/py/tests/test_gpt.py to check gpt_partition_attrs for part1
(bootable) and part2? That also covers the read path in patch 3 and,
with a 'gpt write' using attrs=, the write path in patches 2 and 4,
which currently have none.

Regards,
Simon

Reply via email to