Home | History | Annotate | Download | only in applypatch

Lines Matching refs:partition

49 static bool GenerateTarget(const Partition& target, const FileContents& source_file,
69 // Reads the contents of a Partition to the given FileContents buffer.
70 static bool ReadPartitionToBuffer(const Partition& partition, FileContents* out,
73 if (ParseSha1(partition.hash, expected_sha1) != 0) {
74 LOG(ERROR) << "Failed to parse target hash \"" << partition.hash << "\"";
78 android::base::unique_fd dev(open(partition.name.c_str(), O_RDONLY));
80 PLOG(ERROR) << "Failed to open eMMC partition \"" << partition << "\"";
82 std::vector<unsigned char> buffer(partition.size);
84 PLOG(ERROR) << "Failed to read " << buffer.size() << " bytes of data for partition "
85 << partition;
96 LOG(ERROR) << "Partition contents don't have the expected checksum";
105 LOG(ERROR) << "Both of partition contents and backup don't have the expected checksum";
135 // Writes a memory buffer to 'target' Partition.
136 static bool WriteBufferToPartition(const FileContents& file_contents, const Partition& partition) {
142 android::base::unique_fd fd(open(partition.name.c_str(), O_RDWR));
144 PLOG(ERROR) << "Failed to open \"" << partition << "\"";
149 PLOG(ERROR) << "Failed to seek to " << start << " on \"" << partition << "\"";
154 PLOG(ERROR) << "Failed to write " << len - start << " bytes to \"" << partition << "\"";
159 PLOG(ERROR) << "Failed to sync \"" << partition << "\"";
163 PLOG(ERROR) << "Failed to close \"" << partition << "\"";
167 fd.reset(open(partition.name.c_str(), O_RDONLY));
169 PLOG(ERROR) << "Failed to reopen \"" << partition << "\" for verification";
185 PLOG(ERROR) << "Failed to seek to 0 on " << partition;
198 PLOG(ERROR) << "Failed to verify-read " << partition << " at " << p;
216 PLOG(ERROR) << "Failed to close " << partition;
256 bool PatchPartitionCheck(const Partition& target, const Partition& source) {
268 bool PatchPartition(const Partition& target, const Partition& source, const Value& patch,
290 bool FlashPartition(const Partition& partition, const std::string& source_filename) {
291 LOG(INFO) << "Flashing " << partition;
295 if (ReadPartitionToBuffer(partition, &target_file, false)) {
298 LOG(INFO) << " already " << partition.hash.substr(0, 8);
309 if (ParseSha1(partition.hash, expected_sha1) != 0) {
310 LOG(ERROR) << "Failed to parse source hash \"" << partition.hash << "\"";
317 LOG(ERROR) << "expected: " << partition.hash.substr(0, 8)
321 if (!WriteBufferToPartition(source_file, partition)) {
322 LOG(ERROR) << "Failed to write to " << partition;
328 static bool GenerateTarget(const Partition& target, const FileContents& source_file,
353 // We write the original source to cache, in case the partition write is interrupted.
411 // Write back the temp file to the partition.
424 bool CheckPartition(const Partition& partition) {
426 return ReadPartitionToBuffer(partition, &target_file, false);
429 Partition Partition::Parse(const std::string& input_str, std::string* err) {
442 return Partition(pieces[1], size, pieces[3]);
445 std::string Partition::ToString() const {
449 return "<invalid-partition>";
452 std::ostream& operator<<(std::ostream& os, const Partition& partition) {
453 os << partition.ToString();