Android-cuttlefish cvd tool
avb.h
Go to the documentation of this file.
1//
2// Copyright (C) 2023 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#pragma once
17
18#include <stdint.h>
19#include <sys/types.h>
20
21#include <string>
22#include <vector>
23
26
27namespace cuttlefish {
28
29// Taken from external/avb/avbtool.py; this define is not in the headers
30inline constexpr uint64_t kMaxAvbMetadataSize = 69632ul;
31
33 std::string name;
34 std::string rollback_index;
35 std::string key_path;
36};
37
38class Avb {
39 public:
40 Avb();
41 Avb(std::string avbtool_path);
42 Avb(std::string avbtool_path, std::string algorithm, std::string key);
43
52 Result<void> AddHashFooter(const std::string& image_path,
53 const std::string& partition_name,
54 off_t partition_size_bytes) const;
56 const std::string& output_path,
57 const std::vector<ChainPartition>& chained_partitions,
58 const std::vector<std::string>& included_partitions,
59 const std::vector<std::string>& extra_arguments);
60
61 private:
62 Command GenerateAddHashFooter(const std::string& image_path,
63 const std::string& partition_name,
64 off_t partition_size_bytes) const;
66 const std::string& output_path,
67 const std::vector<ChainPartition>& chained_partitions,
68 const std::vector<std::string>& included_partitions,
69 const std::vector<std::string>& extra_arguments);
70
71 std::string avbtool_path_;
72 std::string algorithm_;
73 std::string key_;
74};
75
76Result<void> EnforceVbMetaSize(const std::string& path);
77
78} // namespace cuttlefish
Definition: avb.h:38
Command GenerateMakeVbMetaImage(const std::string &output_path, const std::vector< ChainPartition > &chained_partitions, const std::vector< std::string > &included_partitions, const std::vector< std::string > &extra_arguments)
Definition: avb.cpp:93
std::string key_
Definition: avb.h:73
std::string avbtool_path_
Definition: avb.h:71
std::string algorithm_
Definition: avb.h:72
Command GenerateAddHashFooter(const std::string &image_path, const std::string &partition_name, off_t partition_size_bytes) const
Definition: avb.cpp:56
Result< void > AddHashFooter(const std::string &image_path, const std::string &partition_name, off_t partition_size_bytes) const
Definition: avb.cpp:82
Avb()
Definition: avb.cpp:46
Result< void > MakeVbMetaImage(const std::string &output_path, const std::vector< ChainPartition > &chained_partitions, const std::vector< std::string > &included_partitions, const std::vector< std::string > &extra_arguments)
Definition: avb.cpp:124
Definition: command.h:38
#define key
Definition: dict.c:55
Definition: alloc_driver.h:20
Result< void > EnforceVbMetaSize(const std::string &path)
Definition: avb.cpp:138
constexpr uint64_t kMaxAvbMetadataSize
Definition: avb.h:30
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
Definition: avb.h:32
std::string rollback_index
Definition: avb.h:34
std::string key_path
Definition: avb.h:35
std::string name
Definition: avb.h:33