summaryrefslogtreecommitdiffstats
path: root/tools/releasetools/common.py
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-05-12 11:42:31 -0700
committerTao Bao <tbao@google.com>2015-05-13 12:26:04 -0700
commit5ece99d64efe82fc1ca97a96f079ce69ea588a24 (patch)
tree55b6713bc22d1a1695fd41a111680f75d7a65e98 /tools/releasetools/common.py
parentc0ba40b8a17669b9938008f826cef88aa791c828 (diff)
downloadbuild-5ece99d64efe82fc1ca97a96f079ce69ea588a24.zip
build-5ece99d64efe82fc1ca97a96f079ce69ea588a24.tar.gz
build-5ece99d64efe82fc1ca97a96f079ce69ea588a24.tar.bz2
Add support for clobbered blocks
In ext4 filesystems, some blocks might be changed even being mounted R/O, such as the superblock (block 0). We need to exclude such blocks from integrity verification. Plus such blocks should always be written to the target by copying instead of patching. Bug: http://b/20939131 Change-Id: I657025b7b1ad50d4365e7b18dc39308facfe864e (cherry picked from commit ff7778166bd13a90c89fa333591ee2037f587a11)
Diffstat (limited to 'tools/releasetools/common.py')
-rw-r--r--tools/releasetools/common.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index ab58fa7..8ab98e7 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1148,6 +1148,9 @@ class BlockDifference(object):
self.partition = partition
self.check_first_block = check_first_block
+ # Due to http://b/20939131, check_first_block is disabled temporarily.
+ assert not self.check_first_block
+
if version is None:
version = 1
if OPTIONS.info_dict:
@@ -1181,18 +1184,18 @@ class BlockDifference(object):
if not self.src:
script.Print("Image %s will be patched unconditionally." % (partition,))
else:
+ ranges = self.src.care_map.subtract(self.src.clobbered_blocks)
+ ranges_str = ranges.to_string_raw()
if self.version >= 3:
script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
'block_image_verify("%s", '
'package_extract_file("%s.transfer.list"), '
'"%s.new.dat", "%s.patch.dat")) then') % (
- self.device, self.src.care_map.to_string_raw(),
- self.src.TotalSha1(),
+ self.device, ranges_str, self.src.TotalSha1(),
self.device, partition, partition, partition))
else:
script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
- self.device, self.src.care_map.to_string_raw(),
- self.src.TotalSha1()))
+ self.device, ranges_str, self.src.TotalSha1()))
script.Print('Verified %s image...' % (partition,))
script.AppendExtra('else')
@@ -1240,6 +1243,9 @@ class BlockDifference(object):
return ctx.hexdigest()
+ # TODO(tbao): Due to http://b/20939131, block 0 may be changed without
+ # remounting R/W. Will change the checking to a finer-grained way to
+ # mask off those bits.
def _CheckFirstBlock(self, script):
r = rangelib.RangeSet((0, 1))
srchash = self._HashBlocks(self.src, r)