From 650a192cff243f1a44025a8aea4e4c307d9972bb Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 16 May 2013 13:44:02 +0300 Subject: gpt_parser: bugfix: correctly update alternate GPT header This patch is a bug-fix which fixes the --part-type option. The sysmptom of the issue was the following warning from kpartx: GPT: partition_entry_array_crc32 values don't match: 0xa24d9e34 != 0xc4e77ef0 GPT: Use GNU Parted to correct GPT errors. The reason of the issue was that we did not update the alternate partition array. The root-cause is that we cannot rely on the 'offs' element of the partition entry dictionary because it points to the primary prition array offset, while we needed the alternate. Instead, we have to calculate the offset ourselves. Change-Id: Iec35ebefa28ba8f7a65c414177c909747b6512ed Signed-off-by: Artem Bityutskiy --- mic/utils/gpt_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mic/utils/gpt_parser.py b/mic/utils/gpt_parser.py index 7ca0a78..5d43b70 100644 --- a/mic/utils/gpt_parser.py +++ b/mic/utils/gpt_parser.py @@ -299,7 +299,9 @@ class GptParser: entry['name'].encode('UTF-16')) # Write the updated entry to the disk - self._write_disk(entry['offs'], raw_entry) + entry_offs = header['ptable_offs'] + \ + header['entry_size'] * entry['index'] + self._write_disk(entry_offs, raw_entry) # Calculate and update partition table CRC32 raw_ptable = self._read_disk(header['ptable_offs'], -- cgit v1.2.3