gpt_parser: bugfix: correctly update alternate GPT header
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 16 May 2013 10:44:02 +0000 (13:44 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 16 May 2013 10:46:27 +0000 (13:46 +0300)
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 <artem.bityutskiy@intel.com>
mic/utils/gpt_parser.py

index 7ca0a78..5d43b70 100644 (file)
@@ -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'],