diff options
author | Yifan Hong <elsk@google.com> | 2019-11-26 15:47:09 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-11-26 15:47:09 -0800 |
commit | 5747dfa93154c54d7ed949ac7b8781e4dbac6ec6 (patch) | |
tree | 35badb689a088899ec2226c3261b395f70d1bc5d | |
parent | 89bc166320306cb05679a0da35c55005aa9fca8b (diff) | |
parent | ddbcba794e0a2ec9682f7ab2a4eb8e03ce556544 (diff) |
Merge "libsnapshot: bootloader rejects wipe in proper time."
am: ddbcba794e
Change-Id: I3e33496eaa7fb50a77e9f5d5c76855dc7f89cb90
-rw-r--r-- | fs_mgr/libsnapshot/snapshot.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 008ece722..50d04b160 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -1663,10 +1663,6 @@ bool SnapshotManager::WriteUpdateState(LockedFile* file, UpdateState state) { if (contents.empty()) return false; if (!Truncate(file)) return false; - if (!android::base::WriteStringToFd(contents, file->fd())) { - PLOG(ERROR) << "Could not write to state file"; - return false; - } #ifdef LIBSNAPSHOT_USE_HAL auto merge_status = MergeStatus::UNKNOWN; @@ -1692,7 +1688,21 @@ bool SnapshotManager::WriteUpdateState(LockedFile* file, UpdateState state) { LOG(ERROR) << "Unexpected update status: " << state; break; } - if (!device_->SetBootControlMergeStatus(merge_status)) { + + bool set_before_write = + merge_status == MergeStatus::SNAPSHOTTED || merge_status == MergeStatus::MERGING; + if (set_before_write && !device_->SetBootControlMergeStatus(merge_status)) { + return false; + } +#endif + + if (!android::base::WriteStringToFd(contents, file->fd())) { + PLOG(ERROR) << "Could not write to state file"; + return false; + } + +#ifdef LIBSNAPSHOT_USE_HAL + if (!set_before_write && !device_->SetBootControlMergeStatus(merge_status)) { return false; } #endif @@ -2150,6 +2160,15 @@ std::unique_ptr<AutoDevice> SnapshotManager::EnsureMetadataMounted() { } UpdateState SnapshotManager::InitiateMergeAndWait() { + { + auto lock = LockExclusive(); + // Sync update state from file with bootloader. + if (!WriteUpdateState(lock.get(), ReadUpdateState(lock.get()))) { + LOG(WARNING) << "Unable to sync write update state, fastboot may " + << "reject / accept wipes incorrectly!"; + } + } + LOG(INFO) << "Waiting for any previous merge request to complete. " << "This can take up to several minutes."; auto state = ProcessUpdateState(); |