BmapCopy: fix image size validation
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 26 Nov 2012 15:34:15 +0000 (17:34 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 26 Nov 2012 16:15:44 +0000 (18:15 +0200)
... which did not work correctly because it should only be run for uncompressed
images in __init__, as well as for any images when there is no bmap.

Change-Id: I3e1dad253889df7fa8980c30df6bcb9dd4b5652d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptools/BmapCopy.py

index ff9a8b0..c362b62 100644 (file)
@@ -295,7 +295,6 @@ class BmapCopy:
                 self._bmap_path = bmap
                 self._open_bmap_file()
             self._parse_bmap()
-            self._validate_image_size()
         else:
             # There is no bmap. Initialize user-visible attributes to something
             # sensible with an assumption that we just have all blocks mapped.
@@ -309,6 +308,9 @@ class BmapCopy:
                 image_size = os.fstat(self._f_image.fileno()).st_size
                 self._initialize_sizes(image_size)
 
+        if not self._image_is_compressed:
+            self._validate_image_size()
+
         self._batch_blocks = self._batch_bytes / self.block_size
 
     def __del__(self):
@@ -506,7 +508,6 @@ class BmapCopy:
             # a compressed image. Initialize the corresponding class attributes
             # now, when we know the size.
             self._initialize_sizes(bytes_written)
-            self._validate_image_size()
 
         # This is just a sanity check - we should have written exactly
         # 'mapped_cnt' blocks.