aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zheng <zhengdaniel@google.com>2024-04-03 15:53:14 -0700
committerDaniel Zheng <zhengdaniel@google.com>2024-04-08 14:01:37 -0700
commit0b735f6cd2f9c09a469343a13d2190a6f22178da (patch)
treec4f88ea825744e53aee908c3f7aa56353e9cb764
parent1ab64159027c1b22c6582653e86dbc8cb1abe4b6 (diff)
downloadupdate_engine-0b735f6cd2f9c09a469343a13d2190a6f22178da.tar.gz
cow estimator: terminate on bad write
If a write failure occurs, we should log an error and then terminate estimation. Otherwise we might have a false positive, and have a faulty OTA package generated Bug: 332640740 Test: th Change-Id: Ib72a7b66b7f0c25b89be64172ce68d1de077077e
-rw-r--r--payload_generator/cow_size_estimator.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/payload_generator/cow_size_estimator.cc b/payload_generator/cow_size_estimator.cc
index cc1034dd..2a97b068 100644
--- a/payload_generator/cow_size_estimator.cc
+++ b/payload_generator/cow_size_estimator.cc
@@ -99,7 +99,12 @@ bool CowDryRun(
PLOG(ERROR) << "Failed to read target data at " << ext;
return false;
}
- writer->Write(new_data.data(), ext.num_blocks() * block_size);
+ if (!writer->Write(new_data.data(),
+ ext.num_blocks() * block_size)) {
+ LOG(ERROR) << "Failed to write XOR operation for extent: "
+ << ext.start_block();
+ return false;
+ }
}
cow_writer->AddLabel(0);
break;
@@ -122,7 +127,11 @@ bool CowDryRun(
PLOG(ERROR) << "Failed to read new block data at " << ext;
return false;
}
- extent_writer.Write(data.data(), data.size());
+ if (!extent_writer.Write(data.data(), data.size())) {
+ LOG(ERROR) << "Failed to write REPLACE op for extent: "
+ << ext.start_block();
+ return false;
+ }
}
cow_writer->AddLabel(0);
break;