From 009d6f8c73fd2519ba1401fb3bea04b517566fc8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 12 Nov 2021 02:01:29 +0000 Subject: [PATCH] build_image: Query the actual image size after invoking the final mkfs. It's not guaranteed that the requested image size to mkfs is precisely respected, due to metadata alignment and such. For accurate care maps use the real image size rather than requested. Bug: 205541521 Test: smartsync to 7892270, check that care_map.pb has the right block count Change-Id: I60fe64f720db13d3c3c4f1d8968341d7293217c9 --- tools/releasetools/build_image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index 8a5d627b36..34aa1a61c6 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -651,6 +651,10 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None): if not mkfs_output: mkfs_output = BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config) + # Update the image (eg filesystem size). This can be different eg if mkfs + # rounds the requested size down due to alignment. + prop_dict["image_size"] = common.sparse_img.GetImagePartitionSize(out_file) + # Check if there's enough headroom space available for ext4 image. if "partition_headroom" in prop_dict and fs_type.startswith("ext4"): CheckHeadroom(mkfs_output, prop_dict)