Android-cuttlefish cvd tool
disk_builder.h
Go to the documentation of this file.
1//
2// Copyright (C) 2022 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 <optional>
19#include <string>
20#include <vector>
21
24
25namespace cuttlefish {
26
28 public:
29 DiskBuilder& EntireDisk(std::string path) &;
30 DiskBuilder EntireDisk(std::string path) &&;
31
32 DiskBuilder& Partitions(std::vector<ImagePartition> partitions) &;
33 DiskBuilder Partitions(std::vector<ImagePartition> partitions) &&;
34
35 DiskBuilder& HeaderPath(std::string header_path) &;
36 DiskBuilder HeaderPath(std::string header_path) &&;
37
38 DiskBuilder& FooterPath(std::string footer_path) &;
39 DiskBuilder FooterPath(std::string footer_path) &&;
40
41 DiskBuilder& CrosvmPath(std::string crosvm_path) &;
42 DiskBuilder CrosvmPath(std::string crosvm_path) &&;
43
44 DiskBuilder& VmmSupportsCompositeDisks(bool vmm_supports_composite_disks) &;
45 DiskBuilder VmmSupportsCompositeDisks(bool vmm_supports_composite_disks) &&;
46
47 DiskBuilder& ConfigPath(std::string config_path) &;
48 DiskBuilder ConfigPath(std::string config_path) &&;
49
50 DiskBuilder& CompositeDiskPath(std::string composite_disk_path) &;
51 DiskBuilder CompositeDiskPath(std::string composite_disk_path) &&;
52
53 DiskBuilder& OverlayPath(std::string overlay_path) &;
54 DiskBuilder OverlayPath(std::string overlay_path) &&;
55
56 DiskBuilder& ResumeIfPossible(bool resume_if_possible) &;
57 DiskBuilder ResumeIfPossible(bool resume_if_possible) &&;
58
59 DiskBuilder& ReadOnly(bool read_only) &;
60 DiskBuilder ReadOnly(bool read_only) &&;
61
67
68 private:
70
71 std::vector<ImagePartition> partitions_;
72 std::string entire_disk_;
73 std::string header_path_;
74 std::string footer_path_;
75 std::optional<bool> vmm_supports_composite_disks_;
76 std::string crosvm_path_;
77 std::string config_path_;
79 std::string overlay_path_;
81 bool read_only_ = true;
82};
83
84} // namespace cuttlefish
Definition: disk_builder.h:27
bool resume_if_possible_
Definition: disk_builder.h:80
std::string crosvm_path_
Definition: disk_builder.h:76
std::vector< ImagePartition > partitions_
Definition: disk_builder.h:71
std::string overlay_path_
Definition: disk_builder.h:79
std::string entire_disk_
Definition: disk_builder.h:72
Result< std::string > TextConfig()
Definition: disk_builder.cpp:156
bool read_only_
Definition: disk_builder.h:81
DiskBuilder & VmmSupportsCompositeDisks(bool vmm_supports_composite_disks) &
Definition: disk_builder.cpp:100
std::optional< bool > vmm_supports_composite_disks_
Definition: disk_builder.h:75
DiskBuilder & CrosvmPath(std::string crosvm_path) &
Definition: disk_builder.cpp:91
DiskBuilder & FooterPath(std::string footer_path) &
Definition: disk_builder.cpp:82
DiskBuilder & Partitions(std::vector< ImagePartition > partitions) &
Definition: disk_builder.cpp:64
DiskBuilder & CompositeDiskPath(std::string composite_disk_path) &
Definition: disk_builder.cpp:120
DiskBuilder & ConfigPath(std::string config_path) &
Definition: disk_builder.cpp:111
Result< bool > BuildCompositeDiskIfNecessary()
Definition: disk_builder.cpp:211
Result< bool > BuildOverlayIfNecessary()
Definition: disk_builder.cpp:240
DiskBuilder & HeaderPath(std::string header_path) &
Definition: disk_builder.cpp:73
std::string composite_disk_path_
Definition: disk_builder.h:78
DiskBuilder & OverlayPath(std::string overlay_path) &
Definition: disk_builder.cpp:129
DiskBuilder & ResumeIfPossible(bool resume_if_possible) &
Definition: disk_builder.cpp:138
std::string header_path_
Definition: disk_builder.h:73
DiskBuilder & EntireDisk(std::string path) &
Definition: disk_builder.cpp:55
std::string config_path_
Definition: disk_builder.h:77
DiskBuilder & ReadOnly(bool read_only) &
Definition: disk_builder.cpp:147
Result< bool > WillRebuildCompositeDisk()
Definition: disk_builder.cpp:176
std::string footer_path_
Definition: disk_builder.h:74
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30