Add partition size check to boot partitions
Since android devices are partitioned at the factory and the partitions
can't be resized aftwards, make allows you to specify that partition
size and asserts that the contents don't exceed it. Soong also needed
this check.
Bug: 377562951
Test: Manually modified BOARD_BOOTIMAGE_PARTITION_SIZE to test the warning and error
Change-Id: I2368b350fb99c4055b14baa84b4964012f4934ef
diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go
index 9eaec73..6fd4b7b 100644
--- a/fsgen/boot_imgs.go
+++ b/fsgen/boot_imgs.go
@@ -36,6 +36,15 @@
},
)
+ var partitionSize *int64
+ if partitionVariables.BoardBootimagePartitionSize != "" {
+ parsed, err := strconv.ParseInt(partitionVariables.BoardBootimagePartitionSize, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("BOARD_BOOTIMAGE_PARTITION_SIZE must be an int, got %s", partitionVariables.BoardBootimagePartitionSize))
+ }
+ partitionSize = &parsed
+ }
+
bootImageName := generatedModuleNameForPartition(ctx.Config(), "boot")
ctx.CreateModule(
@@ -43,6 +52,7 @@
&filesystem.BootimgProperties{
Kernel_prebuilt: proptools.StringPtr(":" + kernelFilegroupName),
Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
+ Partition_size: partitionSize,
},
&struct {
Name *string