1 // 2 // Copyright (C) 2020 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 // 16 #include <cstddef> 17 #include <string> 18 19 #include <libsnapshot/cow_writer.h> 20 #include <update_engine/update_metadata.pb.h> 21 22 #include "update_engine/payload_consumer/file_descriptor.h" 23 24 namespace chromeos_update_engine { 25 // Given file descriptor to the target image, and list of 26 // operations, estimate the size of COW image if the operations are applied on 27 // Virtual AB Compression enabled device. This is intended to be used by update 28 // generators to put an estimate cow size in OTA payload. When installing an OTA 29 // update, libsnapshot will take this estimate as a hint to allocate spaces. 30 // If |xor_enabled| is true, then |source_fd| must be non-null. 31 android::snapshot::CowSizeInfo EstimateCowSizeInfo( 32 FileDescriptorPtr source_fd, 33 FileDescriptorPtr target_fd, 34 const google::protobuf::RepeatedPtrField<InstallOperation>& operations, 35 const google::protobuf::RepeatedPtrField<CowMergeOperation>& 36 merge_operations, 37 const size_t block_size, 38 std::string compression, 39 const size_t new_partition_size, 40 const size_t old_partition_size, 41 bool xor_enabled, 42 uint32_t cow_version, 43 uint64_t compression_factor); 44 45 // Convert InstallOps to CowOps and apply the converted cow op to |cow_writer| 46 bool CowDryRun( 47 FileDescriptorPtr source_fd, 48 FileDescriptorPtr target_fd, 49 const google::protobuf::RepeatedPtrField<InstallOperation>& operations, 50 const google::protobuf::RepeatedPtrField<CowMergeOperation>& 51 merge_operations, 52 size_t block_size, 53 android::snapshot::ICowWriter* cow_writer, 54 const size_t new_partition_size, 55 const size_t old_partition_size, 56 bool xor_enabled); 57 58 } // namespace chromeos_update_engine 59