From ab9c7e6d04c896ddcbfc2e3bc99ab00e6a892288 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 18 Feb 2020 23:29:44 -0800 Subject: [PATCH] Exclude holes from the block map. e2fsdroid can export holes as a "0" block, in order to make sure logical and physical block assignments are maintained properly. Exclude these hole blocks from range sets in LoadFileBlockMap. Bug: 139201772 Test: m dist on non-A/B Change-Id: Ic04e869572229678fdeaaa6fbf6f464d6c672051 --- tools/releasetools/sparse_img.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py index a2490813e5..6a91cf4541 100644 --- a/tools/releasetools/sparse_img.py +++ b/tools/releasetools/sparse_img.py @@ -251,6 +251,12 @@ class SparseImage(object): for line in f: fn, ranges_text = line.rstrip().split(None, 1) ranges = rangelib.RangeSet.parse(ranges_text) + + # Note: e2fsdroid records holes in the extent tree as "0" blocks. + # This causes confusion because clobbered_blocks always includes + # the superblock (physical block #0). Since the 0 blocks here do + # not represent actual physical blocks, remove them from the set. + ranges = ranges.subtract(rangelib.RangeSet("0")) ranges.extra['text_str'] = ranges_text if allow_shared_blocks: