| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2012 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 16 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #include "update_engine/payload_consumer/filesystem_verifier_action.h" | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 18 |  | 
|  | 19 | #include <errno.h> | 
|  | 20 | #include <fcntl.h> | 
|  | 21 | #include <sys/stat.h> | 
|  | 22 | #include <sys/types.h> | 
|  | 23 |  | 
|  | 24 | #include <algorithm> | 
|  | 25 | #include <cstdlib> | 
|  | 26 | #include <string> | 
|  | 27 |  | 
| Alex Deymo | 20c9920 | 2015-07-09 16:14:16 -0700 | [diff] [blame] | 28 | #include <base/bind.h> | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 29 | #include <brillo/data_encoding.h> | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 30 | #include <brillo/streams/file_stream.h> | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 31 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 32 | #include "update_engine/common/utils.h" | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 33 |  | 
| Sen Jiang | 2703ef4 | 2017-03-16 13:36:21 -0700 | [diff] [blame] | 34 | using brillo::data_encoding::Base64Encode; | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 35 | using std::string; | 
|  | 36 |  | 
|  | 37 | namespace chromeos_update_engine { | 
|  | 38 |  | 
|  | 39 | namespace { | 
| Alex Deymo | 20c9920 | 2015-07-09 16:14:16 -0700 | [diff] [blame] | 40 | const off_t kReadFileBufferSize = 128 * 1024; | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 41 | }  // namespace | 
|  | 42 |  | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 43 | void FilesystemVerifierAction::PerformAction() { | 
|  | 44 | // Will tell the ActionProcessor we've failed if we return. | 
|  | 45 | ScopedActionCompleter abort_action_completer(processor_, this); | 
|  | 46 |  | 
|  | 47 | if (!HasInputObject()) { | 
|  | 48 | LOG(ERROR) << "FilesystemVerifierAction missing input object."; | 
|  | 49 | return; | 
|  | 50 | } | 
|  | 51 | install_plan_ = GetInputObject(); | 
|  | 52 |  | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 53 | if (install_plan_.partitions.empty()) { | 
|  | 54 | LOG(INFO) << "No partitions to verify."; | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 55 | if (HasOutputPipe()) | 
|  | 56 | SetOutputObject(install_plan_); | 
|  | 57 | abort_action_completer.set_code(ErrorCode::kSuccess); | 
|  | 58 | return; | 
|  | 59 | } | 
|  | 60 |  | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 61 | StartPartitionHashing(); | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 62 | abort_action_completer.set_should_complete(false); | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | void FilesystemVerifierAction::TerminateProcessing() { | 
| Alex Deymo | 20c9920 | 2015-07-09 16:14:16 -0700 | [diff] [blame] | 66 | cancelled_ = true; | 
|  | 67 | Cleanup(ErrorCode::kSuccess);  // error code is ignored if canceled_ is true. | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 68 | } | 
|  | 69 |  | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 70 | void FilesystemVerifierAction::Cleanup(ErrorCode code) { | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 71 | src_stream_.reset(); | 
| Alex Deymo | 20c9920 | 2015-07-09 16:14:16 -0700 | [diff] [blame] | 72 | // This memory is not used anymore. | 
|  | 73 | buffer_.clear(); | 
|  | 74 |  | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 75 | if (cancelled_) | 
|  | 76 | return; | 
|  | 77 | if (code == ErrorCode::kSuccess && HasOutputPipe()) | 
|  | 78 | SetOutputObject(install_plan_); | 
|  | 79 | processor_->ActionComplete(this, code); | 
|  | 80 | } | 
|  | 81 |  | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 82 | void FilesystemVerifierAction::StartPartitionHashing() { | 
|  | 83 | if (partition_index_ == install_plan_.partitions.size()) { | 
| Sen Jiang | a35896c | 2016-05-25 11:08:41 -0700 | [diff] [blame] | 84 | Cleanup(ErrorCode::kSuccess); | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 85 | return; | 
|  | 86 | } | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 87 | const InstallPlan::Partition& partition = | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 88 | install_plan_.partitions[partition_index_]; | 
|  | 89 |  | 
|  | 90 | string part_path; | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 91 | switch (verifier_step_) { | 
|  | 92 | case VerifierStep::kVerifySourceHash: | 
| Sen Jiang | e6e4bb9 | 2016-04-05 14:59:12 -0700 | [diff] [blame] | 93 | part_path = partition.source_path; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 94 | partition_size_ = partition.source_size; | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 95 | break; | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 96 | case VerifierStep::kVerifyTargetHash: | 
| Sen Jiang | e6e4bb9 | 2016-04-05 14:59:12 -0700 | [diff] [blame] | 97 | part_path = partition.target_path; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 98 | partition_size_ = partition.target_size; | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 99 | break; | 
|  | 100 | } | 
|  | 101 | LOG(INFO) << "Hashing partition " << partition_index_ << " (" | 
|  | 102 | << partition.name << ") on device " << part_path; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 103 | if (part_path.empty()) { | 
|  | 104 | Cleanup(ErrorCode::kFilesystemVerifierError); | 
|  | 105 | return; | 
|  | 106 | } | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 107 |  | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 108 | brillo::ErrorPtr error; | 
|  | 109 | src_stream_ = brillo::FileStream::Open( | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 110 | base::FilePath(part_path), | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 111 | brillo::Stream::AccessMode::READ, | 
|  | 112 | brillo::FileStream::Disposition::OPEN_EXISTING, | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 113 | &error); | 
|  | 114 |  | 
|  | 115 | if (!src_stream_) { | 
|  | 116 | LOG(ERROR) << "Unable to open " << part_path << " for reading"; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 117 | Cleanup(ErrorCode::kFilesystemVerifierError); | 
|  | 118 | return; | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 119 | } | 
|  | 120 |  | 
|  | 121 | buffer_.resize(kReadFileBufferSize); | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 122 | hasher_ = std::make_unique<HashCalculator>(); | 
|  | 123 |  | 
|  | 124 | offset_ = 0; | 
|  | 125 | if (verifier_step_ == VerifierStep::kVerifyTargetHash) { | 
|  | 126 | if (!verity_writer_->Init(partition)) { | 
|  | 127 | Cleanup(ErrorCode::kVerityCalculationError); | 
|  | 128 | return; | 
|  | 129 | } | 
|  | 130 | } | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 131 |  | 
|  | 132 | // Start the first read. | 
|  | 133 | ScheduleRead(); | 
|  | 134 | } | 
|  | 135 |  | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 136 | void FilesystemVerifierAction::ScheduleRead() { | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 137 | const InstallPlan::Partition& partition = | 
|  | 138 | install_plan_.partitions[partition_index_]; | 
|  | 139 |  | 
|  | 140 | // We can only start reading anything past |hash_tree_offset| after we have | 
|  | 141 | // already read all the data blocks that the hash tree covers. The same | 
|  | 142 | // applies to FEC. | 
|  | 143 | uint64_t read_end = partition_size_; | 
|  | 144 | if (partition.hash_tree_size != 0 && | 
|  | 145 | offset_ < partition.hash_tree_data_offset + partition.hash_tree_data_size) | 
|  | 146 | read_end = std::min(read_end, partition.hash_tree_offset); | 
|  | 147 | if (partition.fec_size != 0 && | 
|  | 148 | offset_ < partition.fec_data_offset + partition.fec_data_size) | 
|  | 149 | read_end = std::min(read_end, partition.fec_offset); | 
|  | 150 | size_t bytes_to_read = | 
|  | 151 | std::min(static_cast<uint64_t>(buffer_.size()), read_end - offset_); | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 152 | if (!bytes_to_read) { | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 153 | FinishPartitionHashing(); | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 154 | return; | 
|  | 155 | } | 
|  | 156 |  | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 157 | bool read_async_ok = src_stream_->ReadAsync( | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 158 | buffer_.data(), | 
|  | 159 | bytes_to_read, | 
|  | 160 | base::Bind(&FilesystemVerifierAction::OnReadDoneCallback, | 
|  | 161 | base::Unretained(this)), | 
|  | 162 | base::Bind(&FilesystemVerifierAction::OnReadErrorCallback, | 
|  | 163 | base::Unretained(this)), | 
|  | 164 | nullptr); | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 165 |  | 
|  | 166 | if (!read_async_ok) { | 
|  | 167 | LOG(ERROR) << "Unable to schedule an asynchronous read from the stream."; | 
|  | 168 | Cleanup(ErrorCode::kError); | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 169 | } | 
|  | 170 | } | 
|  | 171 |  | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 172 | void FilesystemVerifierAction::OnReadDoneCallback(size_t bytes_read) { | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 173 | if (cancelled_) { | 
|  | 174 | Cleanup(ErrorCode::kError); | 
|  | 175 | return; | 
|  | 176 | } | 
|  | 177 |  | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 178 | if (bytes_read == 0) { | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 179 | LOG(ERROR) << "Failed to read the remaining " << partition_size_ - offset_ | 
|  | 180 | << " bytes from partition " | 
|  | 181 | << install_plan_.partitions[partition_index_].name; | 
|  | 182 | Cleanup(ErrorCode::kFilesystemVerifierError); | 
|  | 183 | return; | 
|  | 184 | } | 
|  | 185 |  | 
|  | 186 | if (!hasher_->Update(buffer_.data(), bytes_read)) { | 
|  | 187 | LOG(ERROR) << "Unable to update the hash."; | 
|  | 188 | Cleanup(ErrorCode::kError); | 
|  | 189 | return; | 
|  | 190 | } | 
|  | 191 |  | 
|  | 192 | if (verifier_step_ == VerifierStep::kVerifyTargetHash) { | 
|  | 193 | if (!verity_writer_->Update(offset_, buffer_.data(), bytes_read)) { | 
|  | 194 | Cleanup(ErrorCode::kVerityCalculationError); | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 195 | return; | 
|  | 196 | } | 
|  | 197 | } | 
|  | 198 |  | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 199 | offset_ += bytes_read; | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 200 |  | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 201 | if (offset_ == partition_size_) { | 
|  | 202 | FinishPartitionHashing(); | 
|  | 203 | return; | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 204 | } | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 205 |  | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 206 | ScheduleRead(); | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 207 | } | 
|  | 208 |  | 
|  | 209 | void FilesystemVerifierAction::OnReadErrorCallback( | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 210 | const brillo::Error* error) { | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 211 | // TODO(deymo): Transform the read-error into an specific ErrorCode. | 
|  | 212 | LOG(ERROR) << "Asynchronous read failed."; | 
|  | 213 | Cleanup(ErrorCode::kError); | 
|  | 214 | } | 
|  | 215 |  | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 216 | void FilesystemVerifierAction::FinishPartitionHashing() { | 
|  | 217 | if (!hasher_->Finalize()) { | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 218 | LOG(ERROR) << "Unable to finalize the hash."; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 219 | Cleanup(ErrorCode::kError); | 
|  | 220 | return; | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 221 | } | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 222 | InstallPlan::Partition& partition = | 
|  | 223 | install_plan_.partitions[partition_index_]; | 
| Sen Jiang | 2703ef4 | 2017-03-16 13:36:21 -0700 | [diff] [blame] | 224 | LOG(INFO) << "Hash of " << partition.name << ": " | 
|  | 225 | << Base64Encode(hasher_->raw_hash()); | 
| Alex Deymo | b9e8e26 | 2015-08-03 20:23:03 -0700 | [diff] [blame] | 226 |  | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 227 | switch (verifier_step_) { | 
|  | 228 | case VerifierStep::kVerifyTargetHash: | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 229 | if (partition.target_hash != hasher_->raw_hash()) { | 
|  | 230 | LOG(ERROR) << "New '" << partition.name | 
|  | 231 | << "' partition verification failed."; | 
| Sen Jiang | cdd5206 | 2017-05-18 15:33:10 -0700 | [diff] [blame] | 232 | if (partition.source_hash.empty()) { | 
|  | 233 | // No need to verify source if it is a full payload. | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 234 | Cleanup(ErrorCode::kNewRootfsVerificationError); | 
|  | 235 | return; | 
| Sen Jiang | cdd5206 | 2017-05-18 15:33:10 -0700 | [diff] [blame] | 236 | } | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 237 | // If we have not verified source partition yet, now that the target | 
| Sen Jiang | 65566a3 | 2016-04-06 13:35:36 -0700 | [diff] [blame] | 238 | // partition does not match, and it's not a full payload, we need to | 
|  | 239 | // switch to kVerifySourceHash step to check if it's because the source | 
|  | 240 | // partition does not match either. | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 241 | verifier_step_ = VerifierStep::kVerifySourceHash; | 
| Sen Jiang | 1ad42ad | 2015-11-17 15:04:02 -0800 | [diff] [blame] | 242 | } else { | 
|  | 243 | partition_index_++; | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 244 | } | 
|  | 245 | break; | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 246 | case VerifierStep::kVerifySourceHash: | 
| Sen Jiang | 1ad42ad | 2015-11-17 15:04:02 -0800 | [diff] [blame] | 247 | if (partition.source_hash != hasher_->raw_hash()) { | 
|  | 248 | LOG(ERROR) << "Old '" << partition.name | 
|  | 249 | << "' partition verification failed."; | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 250 | LOG(ERROR) << "This is a server-side error due to mismatched delta" | 
|  | 251 | << " update image!"; | 
|  | 252 | LOG(ERROR) << "The delta I've been given contains a " << partition.name | 
|  | 253 | << " delta update that must be applied over a " | 
|  | 254 | << partition.name << " with a specific checksum, but the " | 
|  | 255 | << partition.name | 
|  | 256 | << " we're starting with doesn't have that checksum! This" | 
|  | 257 | " means that the delta I've been given doesn't match my" | 
|  | 258 | " existing system. The " | 
|  | 259 | << partition.name << " partition I have has hash: " | 
| Sen Jiang | 2703ef4 | 2017-03-16 13:36:21 -0700 | [diff] [blame] | 260 | << Base64Encode(hasher_->raw_hash()) | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 261 | << " but the update expected me to have " | 
| Sen Jiang | 2703ef4 | 2017-03-16 13:36:21 -0700 | [diff] [blame] | 262 | << Base64Encode(partition.source_hash) << " ."; | 
| Sen Jiang | fef85fd | 2016-03-25 15:32:49 -0700 | [diff] [blame] | 263 | LOG(INFO) << "To get the checksum of the " << partition.name | 
|  | 264 | << " partition run this command: dd if=" | 
|  | 265 | << partition.source_path | 
|  | 266 | << " bs=1M count=" << partition.source_size | 
|  | 267 | << " iflag=count_bytes 2>/dev/null | openssl dgst -sha256 " | 
|  | 268 | "-binary | openssl base64"; | 
|  | 269 | LOG(INFO) << "To get the checksum of partitions in a bin file, " | 
|  | 270 | << "run: .../src/scripts/sha256_partitions.sh .../file.bin"; | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 271 | Cleanup(ErrorCode::kDownloadStateInitializationError); | 
|  | 272 | return; | 
| Sen Jiang | 1ad42ad | 2015-11-17 15:04:02 -0800 | [diff] [blame] | 273 | } | 
| Sen Jiang | a35896c | 2016-05-25 11:08:41 -0700 | [diff] [blame] | 274 | // The action will skip kVerifySourceHash step if target partition hash | 
|  | 275 | // matches, if we are in this step, it means target hash does not match, | 
|  | 276 | // and now that the source partition hash matches, we should set the error | 
|  | 277 | // code to reflect the error in target partition. | 
|  | 278 | // We only need to verify the source partition which the target hash does | 
|  | 279 | // not match, the rest of the partitions don't matter. | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 280 | Cleanup(ErrorCode::kNewRootfsVerificationError); | 
|  | 281 | return; | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 282 | } | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 283 | // Start hashing the next partition, if any. | 
| Alex Deymo | e5e5fe9 | 2015-10-05 09:28:19 -0700 | [diff] [blame] | 284 | hasher_.reset(); | 
|  | 285 | buffer_.clear(); | 
|  | 286 | src_stream_->CloseBlocking(nullptr); | 
|  | 287 | StartPartitionHashing(); | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 288 | } | 
|  | 289 |  | 
|  | 290 | }  // namespace chromeos_update_engine |