From d4db07e9bbf7c606d20e88c1d8d4f36697718ce7 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 18 Oct 2018 17:46:27 -0700 Subject: Support updateable groups. Adds updateable group support to OTA. * DeltaPerformer combines partition sizes with dynamic_partition_metadata to BootControlInterface::PartitionMetadata. * BootControlAndroid::InitPartitionMetadata: * Copy all groups / partitions from source metadata slot * Remove all groups / partitions mentioned in the manifest (of the target slot) * Re-add all groups / partitions mentioned in the manifest. * BootControlAndroid::InitPartitionMetadata can check the incoming PartitionMetadata to see if a partition is dynamic or not. The guessing logic is completely removed. * Because a partition is removed then re-added, there is no need for preserving the entry with size 0 to indicate that a partition is removed. When update_engine sees a partition in a group "foo" on the device, but manifest contains group "foo" without the partition, it removes the partition. * Hence, Removing a partition does NOT require keeping the entry (i.e. RemovePartition is used instead of ShrinkPartition(0) ). This makes retrofitting dynamic partitions on older devices easier. The following is now allowed: - Adding / removing / resizing partitions - Adding / resizing groups It is not allowed to remove a group, but a group can always be resized to zero to deprecate it. Test: update_engine_unittests Bug: 117182932 Change-Id: I39d77f1d1d1fc52fc245f3de699635e6a429015e --- common/boot_control_interface.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'common/boot_control_interface.h') diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h index 1b76939a..43517ce2 100644 --- a/common/boot_control_interface.h +++ b/common/boot_control_interface.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,19 @@ namespace chromeos_update_engine { class BootControlInterface { public: using Slot = unsigned int; - using PartitionMetadata = std::map; + + struct PartitionMetadata { + struct Partition { + std::string name; + uint64_t size; + }; + struct Group { + std::string name; + uint64_t size; + std::vector partitions; + }; + std::vector groups; + }; static const Slot kInvalidSlot = UINT_MAX; @@ -80,10 +93,11 @@ class BootControlInterface { virtual bool MarkBootSuccessfulAsync(base::Callback callback) = 0; // Initialize metadata of underlying partitions for a given |slot|. - // Ensure that partitions at the specified |slot| has a given size, as - // specified by |partition_metadata|. |partition_metadata| has the format: - // {"vendor": 524288000, "system": 2097152000, ...}; values must be - // aligned to the logical block size of the super partition. + // Ensure that all updateable groups with the suffix GetSuffix(|slot|) exactly + // matches the layout specified in |partition_metadata|. Ensure that + // partitions at the specified |slot| has a given size and updateable group, + // as specified by |partition_metadata|. Sizes must be aligned to the logical + // block size of the super partition. virtual bool InitPartitionMetadata( Slot slot, const PartitionMetadata& partition_metadata) = 0; -- cgit v1.2.3