Merge "Create_cow: Hash of target blocks should not be stored." into main am: a2cd2202f0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2759698
Change-Id: Ib652154e55c271260cbf0070af9c96f674c31709
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
index 4e07fe3..efb1035 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
@@ -240,9 +240,11 @@
SHA256(bufptr, BLOCK_SZ, checksum);
std::string hash = ToHexString(checksum, sizeof(checksum));
- if (create_snapshot_patch_ && !WriteSnapshot(bufptr, blkindex, hash)) {
- LOG(ERROR) << "WriteSnapshot failed for block: " << blkindex;
- return false;
+ if (create_snapshot_patch_) {
+ if (!WriteSnapshot(bufptr, blkindex, hash)) {
+ LOG(ERROR) << "WriteSnapshot failed for block: " << blkindex;
+ return false;
+ }
} else {
std::lock_guard<std::mutex> lock(source_block_hash_lock_);
{
@@ -256,7 +258,7 @@
num_blocks -= 1;
}
- file_offset += (skip_blocks * kBlockSizeToRead);
+ file_offset += (skip_blocks * to_read);
if (file_offset >= dev_sz) {
break;
}