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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ |
7 | 7 |
8 #include <inttypes.h> | 8 #include <inttypes.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 DeltaPerformer(PrefsInterface* prefs) | 28 DeltaPerformer(PrefsInterface* prefs) |
29 : prefs_(prefs), | 29 : prefs_(prefs), |
30 fd_(-1), | 30 fd_(-1), |
31 kernel_fd_(-1), | 31 kernel_fd_(-1), |
32 manifest_valid_(false), | 32 manifest_valid_(false), |
33 manifest_metadata_size_(0), | 33 manifest_metadata_size_(0), |
34 next_operation_num_(0), | 34 next_operation_num_(0), |
35 buffer_offset_(0), | 35 buffer_offset_(0), |
36 last_updated_buffer_offset_(kuint64max), | 36 last_updated_buffer_offset_(kuint64max), |
37 block_size_(0) {} | 37 block_size_(0), |
| 38 current_kernel_hash_(NULL), |
| 39 current_rootfs_hash_(NULL) {} |
38 | 40 |
39 // Opens the kernel. Should be called before or after Open(), but before | 41 // Opens the kernel. Should be called before or after Open(), but before |
40 // Write(). The kernel file will be close()d when Close() is called. | 42 // Write(). The kernel file will be close()d when Close() is called. |
41 bool OpenKernel(const char* kernel_path); | 43 bool OpenKernel(const char* kernel_path); |
42 | 44 |
43 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be | 45 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be |
44 // Open()ed again. | 46 // Open()ed again. |
45 int Open(const char* path, int flags, mode_t mode); | 47 int Open(const char* path, int flags, mode_t mode); |
46 | 48 |
47 // Wrapper around write. Returns bytes written on success or | 49 // Wrapper around write. Returns bytes written on success or |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // persistent preferences and the new update check response hash. | 89 // persistent preferences and the new update check response hash. |
88 static bool CanResumeUpdate(PrefsInterface* prefs, | 90 static bool CanResumeUpdate(PrefsInterface* prefs, |
89 std::string update_check_response_hash); | 91 std::string update_check_response_hash); |
90 | 92 |
91 // Resets the persistent update progress state to indicate that an update | 93 // Resets the persistent update progress state to indicate that an update |
92 // can't be resumed. Performs a quick update-in-progress reset if |quick| is | 94 // can't be resumed. Performs a quick update-in-progress reset if |quick| is |
93 // true, otherwise resets all progress-related update state. Returns true on | 95 // true, otherwise resets all progress-related update state. Returns true on |
94 // success, false otherwise. | 96 // success, false otherwise. |
95 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick); | 97 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick); |
96 | 98 |
| 99 void set_current_kernel_hash(const std::vector<char>* hash) { |
| 100 current_kernel_hash_ = hash; |
| 101 } |
| 102 |
| 103 void set_current_rootfs_hash(const std::vector<char>* hash) { |
| 104 current_rootfs_hash_ = hash; |
| 105 } |
| 106 |
97 private: | 107 private: |
98 friend class DeltaPerformerTest; | 108 friend class DeltaPerformerTest; |
99 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest); | 109 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest); |
100 | 110 |
101 static bool IsIdempotentOperation( | 111 static bool IsIdempotentOperation( |
102 const DeltaArchiveManifest_InstallOperation& op); | 112 const DeltaArchiveManifest_InstallOperation& op); |
103 | 113 |
| 114 // Verifies that the expected source partition hashes (if present) match the |
| 115 // hashes for the current partitions. Returns true if there're no expected |
| 116 // hashes in the payload (e.g., if it's a new-style full update) or if the |
| 117 // hashes match; returns false otherwise. |
| 118 bool VerifySourcePartitions(); |
| 119 |
104 // Returns true if enough of the delta file has been passed via Write() | 120 // Returns true if enough of the delta file has been passed via Write() |
105 // to be able to perform a given install operation. | 121 // to be able to perform a given install operation. |
106 bool CanPerformInstallOperation( | 122 bool CanPerformInstallOperation( |
107 const DeltaArchiveManifest_InstallOperation& operation); | 123 const DeltaArchiveManifest_InstallOperation& operation); |
108 | 124 |
109 // Returns true on success. | 125 // Returns true on success. |
110 bool PerformInstallOperation( | 126 bool PerformInstallOperation( |
111 const DeltaArchiveManifest_InstallOperation& operation); | 127 const DeltaArchiveManifest_InstallOperation& operation); |
112 | 128 |
113 // These perform a specific type of operation and return true on success. | 129 // These perform a specific type of operation and return true on success. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 190 |
175 // Calculates the payload hash. | 191 // Calculates the payload hash. |
176 OmahaHashCalculator hash_calculator_; | 192 OmahaHashCalculator hash_calculator_; |
177 | 193 |
178 // Saves the signed hash context. | 194 // Saves the signed hash context. |
179 std::string signed_hash_context_; | 195 std::string signed_hash_context_; |
180 | 196 |
181 // Signatures message blob extracted directly from the payload. | 197 // Signatures message blob extracted directly from the payload. |
182 std::vector<char> signatures_message_data_; | 198 std::vector<char> signatures_message_data_; |
183 | 199 |
| 200 // Hashes for the current partitions to be used for source partition |
| 201 // verification. |
| 202 const std::vector<char>* current_kernel_hash_; |
| 203 const std::vector<char>* current_rootfs_hash_; |
| 204 |
184 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); | 205 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); |
185 }; | 206 }; |
186 | 207 |
187 } // namespace chromeos_update_engine | 208 } // namespace chromeos_update_engine |
188 | 209 |
189 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ | 210 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ |
OLD | NEW |