The 'gpt write' partition list syntax only allows setting the legacy
BIOS-bootable bit via the 'bootable' key.

Parse an optional 'attrs=<value>' key when CONFIG_PARTITION_ATTR is
enabled and store it via disk_partition_set_gpt_attr(),
so that gpt_fill_pte() writes the requested 64-bit attributes value
into the partition's GPT entry.

Signed-off-by: Sumit Singh Dhami <[email protected]>
---
 cmd/gpt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 205f696c807..f610c7aa6b5 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -592,6 +592,17 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 
                offset += parts[i].size + parts[i].start;
 
+               if (CONFIG_IS_ENABLED(PARTITION_ATTR)) {
+                       /* attrs */
+                       val = extract_val(tok, "attrs");
+                       if (val) {      /* 'attrs' is optional */
+                               if (extract_env(val, &p))
+                                       p = val;
+                               disk_partition_set_gpt_attr(&parts[i], 
simple_strtoull(p, NULL, 0));
+                               free(val);
+                       }
+               }
+
                /* bootable */
                if (found_key(tok, "bootable"))
                        parts[i].bootable = PART_BOOTABLE;
-- 
2.55.0

Reply via email to