• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 size_t EstimateCowSize(
31     FileDescriptorPtr target_fd,
32     const google::protobuf::RepeatedPtrField<InstallOperation>& operations,
33     const google::protobuf::RepeatedPtrField<CowMergeOperation>&
34         merge_operations,
35     size_t block_size,
36     std::string compression);
37 
38 // Convert InstallOps to CowOps and apply the converted cow op to |cow_writer|
39 bool CowDryRun(
40     FileDescriptorPtr target_fd,
41     const google::protobuf::RepeatedPtrField<InstallOperation>& operations,
42     const google::protobuf::RepeatedPtrField<CowMergeOperation>&
43         merge_operations,
44     size_t block_size,
45     android::snapshot::CowWriter* cow_writer);
46 
47 }  // namespace chromeos_update_engine
48