blob: 882d1f7f2eca4edbd05abc29fc891bc490dad102 [file] [log] [blame]
Kelvin Zhang9b10dba2020-09-25 17:09:11 -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#include "update_engine/payload_consumer/snapshot_extent_writer.h"
17
18#include <algorithm>
19#include <cstdint>
20
21#include <libsnapshot/cow_writer.h>
22
23#include "update_engine/update_metadata.pb.h"
24
25namespace chromeos_update_engine {
26SnapshotExtentWriter::SnapshotExtentWriter(
27 android::snapshot::ICowWriter* cow_writer)
28 : cow_writer_(cow_writer) {
29 CHECK_NE(cow_writer, nullptr);
30}
31
32SnapshotExtentWriter::~SnapshotExtentWriter() {
33 CHECK(buffer_.empty());
34}
35
36bool SnapshotExtentWriter::Init(
37 FileDescriptorPtr /*fd*/,
38 const google::protobuf::RepeatedPtrField<Extent>& extents,
39 uint32_t /*block_size*/) {
40 // TODO(zhangkelvin) Implement this
41 return true;
42}
43
44// Returns true on success.
45// This will construct a COW_REPLACE operation and forward it to CowWriter. It
46// is important that caller does not perform SOURCE_COPY operation on this
47// class, otherwise raw data will be stored. Caller should find ways to use
48// COW_COPY whenever possible.
49bool SnapshotExtentWriter::Write(const void* bytes, size_t count) {
50 // TODO(zhangkelvin) Implement this
51 return true;
52}
53
54} // namespace chromeos_update_engine