[U-Boot] [PATCH v2 5/5] cmd: gpt: solve issue for swap
Patrick Delaunay
patrick.delaunay at st.com
Mon Oct 16 16:17:35 UTC 2017
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 swap
Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---
Changes in v2: None
cmd/gpt.c | 12 ++++++------
test/py/tests/test_gpt.py | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 27dd987..707d861 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=");
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
index 2554f1f..74bc81c 100644
--- a/test/py/tests/test_gpt.py
+++ b/test/py/tests/test_gpt.py
@@ -130,8 +130,8 @@ def test_gpt_rename_partition(state_disk_image, u_boot_console):
output = u_boot_console.run_command('gpt read host 0')
assert 'name second' in output
output = u_boot_console.run_command('part list host 0')
- assert '0x00000800 0x000007ff "first"' in output
- assert '0x00001000 0x000017ff "second"' in output
+ assert '0x00000800 0x00000a00 "first"' in output
+ assert '0x00001000 0x00001200 "second"' in output
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpt')
@@ -143,12 +143,12 @@ def test_gpt_swap_partitions(state_disk_image, u_boot_console):
u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
output = u_boot_console.run_command('part list host 0')
- assert '0x00000800 0x000007ff "first"' in output
- assert '0x00001000 0x000017ff "second"' in output
+ assert '0x00000800 0x00000a00 "first"' in output
+ assert '0x00001000 0x00001200 "second"' in output
u_boot_console.run_command('gpt swap host 0 first second')
output = u_boot_console.run_command('part list host 0')
- assert '0x00000800 0x000007ff "second"' in output
- assert '0x00001000 0x000017ff "first"' in output
+ assert '0x00000800 0x00000a00 "second"' in output
+ assert '0x00001000 0x00001200 "first"' in output
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpt')
--
2.7.4
More information about the U-Boot
mailing list