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
19
20#include <sys/types.h>
21
22#include <cstdint>
23#include <string>
24#include <vector>
25
28
29namespace cuttlefish {
30
31// Taken from external/avb/avbtool.py; this define is not in the headers
32inline constexpr uint64_t kMaxAvbMetadataSize = 69632ul;
33
35 std::string name;
36 std::string rollback_index;
37 std::string key_path;
38};
39
40class Avb {
41 public:
42 Avb();
43 Avb(std::string avbtool_path, std::string algorithm, std::string key);
44
53 Result<void> AddHashFooter(const std::string& image_path,
54 const std::string& partition_name,
55 off_t partition_size_bytes) const;
56 Result<std::string> InfoImage(const std::string& image_path) const;
58 const std::string& output_path,
59 const std::vector<ChainPartition>& chained_partitions,
60 const std::vector<std::string>& included_partitions,
61 const std::vector<std::string>& extra_arguments);
62
63 private:
64 Command GenerateAddHashFooter(const std::string& image_path,
65 const std::string& partition_name,
66 off_t partition_size_bytes) const;
67 Command GenerateInfoImage(const std::string& image_path,
68 const SharedFD& output_path) const;
70 const std::string& output_path,
71 const std::vector<ChainPartition>& chained_partitions,
72 const std::vector<std::string>& included_partitions,
73 const std::vector<std::string>& extra_arguments);
74
75 std::string avbtool_path_;
76 std::string algorithm_;
77 std::string key_;
78};
79
80Result<void> EnforceVbMetaSize(const std::string& path);
81
82} // namespace cuttlefish
Definition: expected.h:86
Definition: avb.h:40
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:97
std::string key_
Definition: avb.h:77
std::string avbtool_path_
Definition: avb.h:75
std::string algorithm_
Definition: avb.h:76
Command GenerateInfoImage(const std::string &image_path, const SharedFD &output_path) const
Command GenerateAddHashFooter(const std::string &image_path, const std::string &partition_name, off_t partition_size_bytes) const
Definition: avb.cpp:52
Result< std::string > InfoImage(const std::string &image_path) const
Definition: avb.cpp:89
Result< void > AddHashFooter(const std::string &image_path, const std::string &partition_name, off_t partition_size_bytes) const
Definition: avb.cpp:78
Avb()
Definition: avb.cpp:45
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:128
Definition: subprocess.h:139
Definition: shared_fd.h:129
Definition: alloc_utils.cpp:23
Result< void > EnforceVbMetaSize(const std::string &path)
Definition: avb.cpp:142
constexpr uint64_t kMaxAvbMetadataSize
Definition: avb.h:32
Definition: avb.h:34
std::string rollback_index
Definition: avb.h:36
std::string key_path
Definition: avb.h:37
std::string name
Definition: avb.h:35