From f1a13180dba9c0145ac7bec8371340ae303c81c1 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 19 Jan 2017 17:39:30 -0800 Subject: [PATCH] Remove verity blocks from care map When reading /dev/block/dm-X, update_verifier isn't able to access the verity meta blocks at the end of the system/vendor partition. So we need to remove these block ranges from the care_map. Bug: 34391662 Test: care_map generated successfully without verity meta blocks Change-Id: Id57c602b7e5fd1b0c9d1e1fe5fcdd74e85b6b255 --- tools/releasetools/add_img_to_target_files.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index c80d4bd9f..b9aef7c18 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -62,6 +62,7 @@ import zipfile import build_image import common +import rangelib import sparse_img OPTIONS = common.OPTIONS @@ -82,6 +83,16 @@ def GetCareMap(which, imgname): care_map_list = [] care_map_list.append(blk_device) care_map_list.append(simg.care_map.to_string_raw()) + + care_map_ranges = simg.care_map + key = which + "_adjusted_partition_size" + adjusted_blocks = OPTIONS.info_dict.get(key) + if adjusted_blocks: + assert adjusted_blocks > 0, "blocks should be positive for " + which + care_map_ranges = care_map_ranges.intersect(rangelib.RangeSet( + "0-%d" % (adjusted_blocks,))) + + care_map_list.append(care_map_ranges.to_string_raw()) return care_map_list @@ -212,6 +223,14 @@ def CreateImage(input_dir, info_dict, what, block_list=None): image_props, img) assert succ, "build " + what + ".img image failed" + is_verity_partition = "verity_block_device" in image_props + verity_supported = image_props.get("verity") == "true" + if is_verity_partition and verity_supported: + adjusted_blocks_value = image_props.get("partition_size") + if adjusted_blocks_value: + adjusted_blocks_key = what + "_adjusted_partition_size" + info_dict[adjusted_blocks_key] = int(adjusted_blocks_value)/4096 - 1 + return img -- 2.11.0