blob: ab4897fc403648adf5ca29b319477c90326cddf9 [file] [log] [blame]
Kelvin Zhang94f51cc2020-09-25 11:34:49 -04001//
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
17#include "update_engine/payload_consumer/vabc_partition_writer.h"
18
19#include <memory>
20
21#include <libsnapshot/cow_writer.h>
22
23#include "update_engine/common/utils.h"
24#include "update_engine/payload_consumer/extent_writer.h"
25#include "update_engine/payload_consumer/install_plan.h"
26#include "update_engine/payload_consumer/partition_writer.h"
27
28namespace chromeos_update_engine {
29bool VABCPartitionWriter::Init(const InstallPlan* install_plan,
30 bool source_may_exist) {
31 TEST_AND_RETURN_FALSE(PartitionWriter::Init(install_plan, source_may_exist));
32
33 // TODO(zhangkelvin) Add code specific to VABC. E.x. Convert InstallOps to
34 // CowOps, perform all SOURCE_COPY upfront according to merge sequence.
35 return true;
36}
37
38std::unique_ptr<ExtentWriter> VABCPartitionWriter::CreateBaseExtentWriter() {
39 // TODO(zhangkelvin) Return a SnapshotExtentWriter
40 return std::make_unique<DirectExtentWriter>();
41}
42
43[[nodiscard]] bool VABCPartitionWriter::PerformZeroOrDiscardOperation(
44 const InstallOperation& operation) {
45 // TODO(zhangkelvin) Create a COW_ZERO operation and send it to CowWriter
46 return PartitionWriter::PerformZeroOrDiscardOperation(operation);
47}
48
49[[nodiscard]] bool VABCPartitionWriter::PerformSourceCopyOperation(
50 const InstallOperation& operation, ErrorCode* error) {
51 // TODO(zhangkelvin) Probably just ignore SOURCE_COPY? They should be taken
52 // care of during Init();
53 return true;
54}
55
56VABCPartitionWriter::~VABCPartitionWriter() = default;
57
58} // namespace chromeos_update_engine