liblp: Modify NewForUpdate to accomodate two super partitions.
This method was designed for a single-super model, and now needs to change to accomodate two super partitions (system_a and system_b, for retrofitting). NewForUpdate is supposed to transition metadata from one block device to the next for updates. For normal devices this is a no-op, since metadata only exists on one partition (super). For retrofit devices, metadata exists on system_a and system_b. This has two implications. First, any references to the source slot must be rewritten. For example "vendor_b" must become "vendor_a". However this is not true of partition names. Partitions/extents are cleared in the updated metadata since they no longer have any meaning (the block device list has been rewritten). We also clear groups since they are re-added during OTA. The reason we have to do this rewriting is that slot suffixes are automatically applied in ReadMetadata. We do not have access to the original unsuffixed metadata that was written by the initial OTA. This was a conscious design decision, since it localizes retrofitting idiosyncracies to just a few places (ReadMetadata, NewForUpdate, and fastbootd), minimizing the number of external callers that have to understand auto-slot-suffixing. It would be arguably cleaner if retrofit metadata was always serialized *without* slot suffixes, thereby making NewForUpdate a no-op. However this would necessitate changes to the API elsewhere. The functions that read partition names would have to take a slot suffix, and this would further complicate MetadataBuilder and fastbootd. Another solution would be to augment LpMetadata to retain unsuffixed information, but this is probably not worthwhile given that retrofitting is intended to be surgical, and will have a shorter lifespan than the non-retrofit case. Bug: 116802789 Test: liblp_test gtest Change-Id: I33596d92b38c47bc70bc0aa37ed04f6f0b9d4b6f
Loading
Please register or sign in to comment