| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 #include <sys/stat.h> | 6 #include <sys/stat.h> |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 #include <bzlib.h> | 15 #include <bzlib.h> |
| 16 #include "chromeos/obsolete_logging.h" | 16 #include "chromeos/obsolete_logging.h" |
| 17 #include "update_engine/bzip.h" | 17 #include "update_engine/bzip.h" |
| 18 #include "update_engine/cycle_breaker.h" | 18 #include "update_engine/cycle_breaker.h" |
| 19 #include "update_engine/extent_mapper.h" | 19 #include "update_engine/extent_mapper.h" |
| 20 #include "update_engine/file_writer.h" | 20 #include "update_engine/file_writer.h" |
| 21 #include "update_engine/filesystem_iterator.h" | 21 #include "update_engine/filesystem_iterator.h" |
| 22 #include "update_engine/graph_types.h" | 22 #include "update_engine/graph_types.h" |
| 23 #include "update_engine/graph_utils.h" | 23 #include "update_engine/graph_utils.h" |
| 24 #include "update_engine/subprocess.h" | 24 #include "update_engine/subprocess.h" |
| 25 #include "update_engine/topological_sort.h" | 25 #include "update_engine/topological_sort.h" |
| 26 #include "update_engine/update_metadata.pb.h" | 26 #include "update_engine/update_metadata.pb.h" |
| 27 #include "update_engine/utils.h" | 27 #include "update_engine/utils.h" |
| 28 | 28 |
| 29 using std::make_pair; | 29 using std::make_pair; |
| 30 using std::max; |
| 30 using std::min; | 31 using std::min; |
| 31 using std::set; | 32 using std::set; |
| 32 using std::string; | 33 using std::string; |
| 33 using std::vector; | 34 using std::vector; |
| 34 | 35 |
| 35 namespace chromeos_update_engine { | 36 namespace chromeos_update_engine { |
| 36 | 37 |
| 37 typedef DeltaDiffGenerator::Block Block; | 38 typedef DeltaDiffGenerator::Block Block; |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 << "Old and new images are different sizes."; | 750 << "Old and new images are different sizes."; |
| 750 LOG_IF(FATAL, new_image_stbuf.st_size % kBlockSize) | 751 LOG_IF(FATAL, new_image_stbuf.st_size % kBlockSize) |
| 751 << "New image not a multiple of block size " << kBlockSize; | 752 << "New image not a multiple of block size " << kBlockSize; |
| 752 LOG_IF(FATAL, old_image_stbuf.st_size % kBlockSize) | 753 LOG_IF(FATAL, old_image_stbuf.st_size % kBlockSize) |
| 753 << "Old image not a multiple of block size " << kBlockSize; | 754 << "Old image not a multiple of block size " << kBlockSize; |
| 754 | 755 |
| 755 // Sanity check kernel partition args | 756 // Sanity check kernel partition args |
| 756 TEST_AND_RETURN_FALSE(utils::FileSize(old_kernel_part) >= 0); | 757 TEST_AND_RETURN_FALSE(utils::FileSize(old_kernel_part) >= 0); |
| 757 TEST_AND_RETURN_FALSE(utils::FileSize(new_kernel_part) >= 0); | 758 TEST_AND_RETURN_FALSE(utils::FileSize(new_kernel_part) >= 0); |
| 758 | 759 |
| 759 vector<Block> blocks(min(old_image_stbuf.st_size / kBlockSize, | 760 vector<Block> blocks(max(old_image_stbuf.st_size / kBlockSize, |
| 760 new_image_stbuf.st_size / kBlockSize)); | 761 new_image_stbuf.st_size / kBlockSize)); |
| 761 LOG(INFO) << "invalid: " << Vertex::kInvalidIndex; | 762 LOG(INFO) << "invalid: " << Vertex::kInvalidIndex; |
| 762 LOG(INFO) << "len: " << blocks.size(); | 763 LOG(INFO) << "len: " << blocks.size(); |
| 763 for (vector<Block>::size_type i = 0; i < blocks.size(); i++) { | 764 for (vector<Block>::size_type i = 0; i < blocks.size(); i++) { |
| 764 CHECK(blocks[i].reader == Vertex::kInvalidIndex); | 765 CHECK(blocks[i].reader == Vertex::kInvalidIndex); |
| 765 CHECK(blocks[i].writer == Vertex::kInvalidIndex); | 766 CHECK(blocks[i].writer == Vertex::kInvalidIndex); |
| 766 } | 767 } |
| 767 Graph graph; | 768 Graph graph; |
| 768 CheckGraph(graph); | 769 CheckGraph(graph); |
| 769 | 770 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 | 938 |
| 938 LOG(INFO) << "All done. Successfully created delta file."; | 939 LOG(INFO) << "All done. Successfully created delta file."; |
| 939 return true; | 940 return true; |
| 940 } | 941 } |
| 941 | 942 |
| 942 const char* const kBsdiffPath = "/usr/bin/bsdiff"; | 943 const char* const kBsdiffPath = "/usr/bin/bsdiff"; |
| 943 const char* const kBspatchPath = "/usr/bin/bspatch"; | 944 const char* const kBspatchPath = "/usr/bin/bspatch"; |
| 944 const char* const kDeltaMagic = "CrAU"; | 945 const char* const kDeltaMagic = "CrAU"; |
| 945 | 946 |
| 946 }; // namespace chromeos_update_engine | 947 }; // namespace chromeos_update_engine |
| OLD | NEW |