libsnapshot: Only mount snapshots in MapAllSnapshots().
By accident, this was mounting partitions as well, which caused conflicts in partial updates where some partitions don't have snapshots. Test: update_device.py with partial OTA Change-Id: I2db0e6269f0a02cbe8164fa2a72b887c352f56d8
This commit is contained in:
parent
71ab9dbeba
commit
5283ae4a86
1 changed files with 35 additions and 3 deletions
|
@ -2172,12 +2172,44 @@ bool SnapshotManager::MapAllSnapshots(const std::chrono::milliseconds& timeout_m
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!UnmapAllSnapshots(lock.get())) {
|
||||
std::vector<std::string> snapshots;
|
||||
if (!ListSnapshots(lock.get(), &snapshots)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t slot = SlotNumberForSlotSuffix(device_->GetOtherSlotSuffix());
|
||||
return MapAllPartitions(lock.get(), device_->GetSuperDevice(slot), slot, timeout_ms);
|
||||
const auto& opener = device_->GetPartitionOpener();
|
||||
auto slot_suffix = device_->GetOtherSlotSuffix();
|
||||
auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
|
||||
auto super_device = device_->GetSuperDevice(slot_number);
|
||||
auto metadata = android::fs_mgr::ReadMetadata(opener, super_device, slot_number);
|
||||
if (!metadata) {
|
||||
LOG(ERROR) << "MapAllSnapshots could not read dynamic partition metadata for device: "
|
||||
<< super_device;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& snapshot : snapshots) {
|
||||
if (!UnmapPartitionWithSnapshot(lock.get(), snapshot)) {
|
||||
LOG(ERROR) << "MapAllSnapshots could not unmap snapshot: " << snapshot;
|
||||
return false;
|
||||
}
|
||||
|
||||
CreateLogicalPartitionParams params = {
|
||||
.block_device = super_device,
|
||||
.metadata = metadata.get(),
|
||||
.partition_name = snapshot,
|
||||
.partition_opener = &opener,
|
||||
.timeout_ms = timeout_ms,
|
||||
};
|
||||
if (!MapPartitionWithSnapshot(lock.get(), std::move(params), SnapshotContext::Mount,
|
||||
nullptr)) {
|
||||
LOG(ERROR) << "MapAllSnapshots failed to map: " << snapshot;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(INFO) << "MapAllSnapshots succeeded.";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SnapshotManager::UnmapAllSnapshots() {
|
||||
|
|
Loading…
Reference in a new issue