summaryrefslogtreecommitdiff
path: root/cmd/gpt.c
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2017-10-18 15:11:08 +0200
committerTom Rini <trini@konsulko.com>2017-10-23 17:28:11 -0400
commit3a2605fa875bc02962d62b5a21c795640621bf45 (patch)
tree86d87bda4b5945780c8d06ebc700c23a759c5aaf /cmd/gpt.c
parent0cf02ff612c05800cb65fb496ac55454c36df64b (diff)
cmd: gpt: solve issue for swap and rename command
don't use prettyprint_part_size() in create_gpt_partitions_list() that avoid to align offset and size to 1 MiB and increase precision for start and size. This patch avoid the risk to change partition size and lost data during rename or swap. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Acked-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'cmd/gpt.c')
-rw-r--r--cmd/gpt.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 27dd98755a..707d861766 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -282,14 +282,14 @@ static int create_gpt_partitions_list(int numparts, const char *guid,
strcat(partitions_list, "name=");
strncat(partitions_list, (const char *)curr->gpt_part_info.name,
PART_NAME_LEN + 1);
- strcat(partitions_list, ",start=");
- prettyprint_part_size(partstr, (unsigned long)curr->gpt_part_info.start,
- (unsigned long) curr->gpt_part_info.blksz);
+ sprintf(partstr, ",start=0x%llx",
+ (unsigned long long)curr->gpt_part_info.start *
+ curr->gpt_part_info.blksz);
/* one extra byte for NULL */
strncat(partitions_list, partstr, PART_NAME_LEN + 1);
- strcat(partitions_list, ",size=");
- prettyprint_part_size(partstr, curr->gpt_part_info.size,
- curr->gpt_part_info.blksz);
+ sprintf(partstr, ",size=0x%llx",
+ (unsigned long long)curr->gpt_part_info.size *
+ curr->gpt_part_info.blksz);
strncat(partitions_list, partstr, PART_NAME_LEN + 1);
strcat(partitions_list, ",uuid=");