| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "update_engine/delta_diff_generator.h" | 5 #include "update_engine/delta_diff_generator.h" | 
| 6 | 6 | 
| 7 #include <errno.h> | 7 #include <errno.h> | 
| 8 #include <fcntl.h> | 8 #include <fcntl.h> | 
| 9 #include <inttypes.h> | 9 #include <inttypes.h> | 
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> | 
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 253 // In the future we might consider intelligent diffing between this data | 253 // In the future we might consider intelligent diffing between this data | 
| 254 // and data in the previous image, but for now we just bzip2 compress it | 254 // and data in the previous image, but for now we just bzip2 compress it | 
| 255 // and include it in the update. | 255 // and include it in the update. | 
| 256 // Creates a new node in the graph to write these blocks and writes the | 256 // Creates a new node in the graph to write these blocks and writes the | 
| 257 // appropriate blob to blobs_fd. Reads and updates blobs_length; | 257 // appropriate blob to blobs_fd. Reads and updates blobs_length; | 
| 258 bool ReadUnwrittenBlocks(const vector<Block>& blocks, | 258 bool ReadUnwrittenBlocks(const vector<Block>& blocks, | 
| 259                          int blobs_fd, | 259                          int blobs_fd, | 
| 260                          off_t* blobs_length, | 260                          off_t* blobs_length, | 
| 261                          const string& image_path, | 261                          const string& image_path, | 
| 262                          Vertex* vertex) { | 262                          Vertex* vertex) { | 
|  | 263   vertex->file_name = "<rootfs-non-file-data>"; | 
|  | 264 | 
| 263   DeltaArchiveManifest_InstallOperation* out_op = &vertex->op; | 265   DeltaArchiveManifest_InstallOperation* out_op = &vertex->op; | 
| 264   int image_fd = open(image_path.c_str(), O_RDONLY, 000); | 266   int image_fd = open(image_path.c_str(), O_RDONLY, 000); | 
| 265   TEST_AND_RETURN_FALSE_ERRNO(image_fd >= 0); | 267   TEST_AND_RETURN_FALSE_ERRNO(image_fd >= 0); | 
| 266   ScopedFdCloser image_fd_closer(&image_fd); | 268   ScopedFdCloser image_fd_closer(&image_fd); | 
| 267 | 269 | 
| 268   string temp_file_path; | 270   string temp_file_path; | 
| 269   TEST_AND_RETURN_FALSE(utils::MakeTempFile("/tmp/CrAU_temp_data.XXXXXX", | 271   TEST_AND_RETURN_FALSE(utils::MakeTempFile("/tmp/CrAU_temp_data.XXXXXX", | 
| 270                                             &temp_file_path, | 272                                             &temp_file_path, | 
| 271                                             NULL)); | 273                                             NULL)); | 
| 272 | 274 | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 461   "BSDIFF" | 463   "BSDIFF" | 
| 462 }; | 464 }; | 
| 463 | 465 | 
| 464 void ReportPayloadUsage(const Graph& graph, | 466 void ReportPayloadUsage(const Graph& graph, | 
| 465                         const DeltaArchiveManifest& manifest) { | 467                         const DeltaArchiveManifest& manifest) { | 
| 466   vector<DeltaObject> objects; | 468   vector<DeltaObject> objects; | 
| 467   off_t total_size = 0; | 469   off_t total_size = 0; | 
| 468 | 470 | 
| 469   // Graph nodes with information about file names. | 471   // Graph nodes with information about file names. | 
| 470   for (Vertex::Index node = 0; node < graph.size(); node++) { | 472   for (Vertex::Index node = 0; node < graph.size(); node++) { | 
| 471     objects.push_back(DeltaObject(graph[node].file_name, | 473     const Vertex& vertex = graph[node]; | 
| 472                                   graph[node].op.type(), | 474     if (!vertex.valid) { | 
| 473                                   graph[node].op.data_length())); | 475       continue; | 
| 474     total_size += graph[node].op.data_length(); | 476     } | 
|  | 477     objects.push_back(DeltaObject(vertex.file_name, | 
|  | 478                                   vertex.op.type(), | 
|  | 479                                   vertex.op.data_length())); | 
|  | 480     total_size += vertex.op.data_length(); | 
| 475   } | 481   } | 
| 476 | 482 | 
| 477   // Final rootfs operation writing non-file-data. |  | 
| 478   const DeltaArchiveManifest_InstallOperation& final_op = |  | 
| 479       manifest.install_operations(manifest.install_operations_size() - 1); |  | 
| 480   objects.push_back(DeltaObject("<rootfs-final-operation>", |  | 
| 481                                 final_op.type(), |  | 
| 482                                 final_op.data_length())); |  | 
| 483   total_size += final_op.data_length(); |  | 
| 484 |  | 
| 485   // Kernel install operations. | 483   // Kernel install operations. | 
| 486   for (int i = 0; i < manifest.kernel_install_operations_size(); ++i) { | 484   for (int i = 0; i < manifest.kernel_install_operations_size(); ++i) { | 
| 487     const DeltaArchiveManifest_InstallOperation& op = | 485     const DeltaArchiveManifest_InstallOperation& op = | 
| 488         manifest.kernel_install_operations(i); | 486         manifest.kernel_install_operations(i); | 
| 489     objects.push_back(DeltaObject(StringPrintf("<kernel-operation-%d>", i), | 487     objects.push_back(DeltaObject(StringPrintf("<kernel-operation-%d>", i), | 
| 490                                   op.type(), | 488                                   op.type(), | 
| 491                                   op.data_length())); | 489                                   op.data_length())); | 
| 492     total_size += op.data_length(); | 490     total_size += op.data_length(); | 
| 493   } | 491   } | 
| 494 | 492 | 
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1486 | 1484 | 
| 1487   LOG(INFO) << "All done. Successfully created delta file."; | 1485   LOG(INFO) << "All done. Successfully created delta file."; | 
| 1488   return true; | 1486   return true; | 
| 1489 } | 1487 } | 
| 1490 | 1488 | 
| 1491 const char* const kBsdiffPath = "/usr/bin/bsdiff"; | 1489 const char* const kBsdiffPath = "/usr/bin/bsdiff"; | 
| 1492 const char* const kBspatchPath = "/usr/bin/bspatch"; | 1490 const char* const kBspatchPath = "/usr/bin/bspatch"; | 
| 1493 const char* const kDeltaMagic = "CrAU"; | 1491 const char* const kDeltaMagic = "CrAU"; | 
| 1494 | 1492 | 
| 1495 };  // namespace chromeos_update_engine | 1493 };  // namespace chromeos_update_engine | 
| OLD | NEW | 
|---|