summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2018-07-25 21:29:12 -0500
committerGerrit Code Review2018-07-25 21:29:12 -0500
commit56f76ec018e63490a4cb07f698ade0250bba43f5 (patch)
treedd98a5401f5386356c941da7531b8ac752a6a4db
parent7b7e416649e92b93ad488d7f41153d2e14ac067e (diff)
parentefc54790859ee672b317692690461b7e0f0e47b3 (diff)
downloadplatform-system-core-56f76ec018e63490a4cb07f698ade0250bba43f5.tar.gz
platform-system-core-56f76ec018e63490a4cb07f698ade0250bba43f5.tar.xz
platform-system-core-56f76ec018e63490a4cb07f698ade0250bba43f5.zip
Merge changes Ica6bf5c6,I3f626433
* changes: fs_mgr: libdm: add support android-verity target. dmctl: Do not skip argument if not matched with '-ro'.
-rw-r--r--fs_mgr/libdm/dm_target.cpp4
-rw-r--r--fs_mgr/libdm/include/libdm/dm_target.h14
-rw-r--r--fs_mgr/tools/dmctl.cpp13
3 files changed, 30 insertions, 1 deletions
diff --git a/fs_mgr/libdm/dm_target.cpp b/fs_mgr/libdm/dm_target.cpp
index 20b26df37..7c1826766 100644
--- a/fs_mgr/libdm/dm_target.cpp
+++ b/fs_mgr/libdm/dm_target.cpp
@@ -111,5 +111,9 @@ std::string DmTargetVerity::GetParameterString() const {
111 return base + " " + std::to_string(optional_args_.size()) + " " + optional; 111 return base + " " + std::to_string(optional_args_.size()) + " " + optional;
112} 112}
113 113
114std::string DmTargetAndroidVerity::GetParameterString() const {
115 return keyid_ + " " + block_device_;
116}
117
114} // namespace dm 118} // namespace dm
115} // namespace android 119} // namespace android
diff --git a/fs_mgr/libdm/include/libdm/dm_target.h b/fs_mgr/libdm/include/libdm/dm_target.h
index d5974f4f1..31863c8fa 100644
--- a/fs_mgr/libdm/include/libdm/dm_target.h
+++ b/fs_mgr/libdm/include/libdm/dm_target.h
@@ -128,6 +128,20 @@ class DmTargetVerity final : public DmTarget {
128 bool valid_; 128 bool valid_;
129}; 129};
130 130
131class DmTargetAndroidVerity final : public DmTarget {
132 public:
133 DmTargetAndroidVerity(uint64_t start, uint64_t length, const std::string& block_device,
134 const std::string& keyid)
135 : DmTarget(start, length), keyid_(keyid), block_device_(block_device) {}
136
137 std::string name() const override { return "android-verity"; }
138 std::string GetParameterString() const override;
139
140 private:
141 std::string keyid_;
142 std::string block_device_;
143};
144
131// This is the same as DmTargetVerity, but the table may be specified as a raw 145// This is the same as DmTargetVerity, but the table may be specified as a raw
132// string. This code exists only for fs_mgr_verity and should be avoided. Use 146// string. This code exists only for fs_mgr_verity and should be avoided. Use
133// DmTargetVerity for new code instead. 147// DmTargetVerity for new code instead.
diff --git a/fs_mgr/tools/dmctl.cpp b/fs_mgr/tools/dmctl.cpp
index 5e11c8423..45a81af2d 100644
--- a/fs_mgr/tools/dmctl.cpp
+++ b/fs_mgr/tools/dmctl.cpp
@@ -40,6 +40,7 @@ using DmTable = ::android::dm::DmTable;
40using DmTarget = ::android::dm::DmTarget; 40using DmTarget = ::android::dm::DmTarget;
41using DmTargetLinear = ::android::dm::DmTargetLinear; 41using DmTargetLinear = ::android::dm::DmTargetLinear;
42using DmTargetZero = ::android::dm::DmTargetZero; 42using DmTargetZero = ::android::dm::DmTargetZero;
43using DmTargetAndroidVerity = ::android::dm::DmTargetAndroidVerity;
43using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo; 44using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo;
44using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice; 45using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice;
45 46
@@ -96,6 +97,16 @@ class TargetParser final {
96 } 97 }
97 return std::make_unique<DmTargetLinear>(start_sector, num_sectors, block_device, 98 return std::make_unique<DmTargetLinear>(start_sector, num_sectors, block_device,
98 physical_sector); 99 physical_sector);
100 } else if (target_type == "android-verity") {
101 if (!HasArgs(2)) {
102 std::cerr << "Expected \"android-verity\" <public-key-id> <block_device>"
103 << std::endl;
104 return nullptr;
105 }
106 std::string keyid = NextArg();
107 std::string block_device = NextArg();
108 return std::make_unique<DmTargetAndroidVerity>(start_sector, num_sectors, keyid,
109 block_device);
99 } else { 110 } else {
100 std::cerr << "Unrecognized target type: " << target_type << std::endl; 111 std::cerr << "Unrecognized target type: " << target_type << std::endl;
101 return nullptr; 112 return nullptr;
@@ -132,11 +143,11 @@ static int DmCreateCmdHandler(int argc, char** argv) {
132 while (arg_index < argc && argv[arg_index][0] == '-') { 143 while (arg_index < argc && argv[arg_index][0] == '-') {
133 if (strcmp(argv[arg_index], "-ro") == 0) { 144 if (strcmp(argv[arg_index], "-ro") == 0) {
134 table.set_readonly(true); 145 table.set_readonly(true);
146 arg_index++;
135 } else { 147 } else {
136 std::cerr << "Unrecognized option: " << argv[arg_index] << std::endl; 148 std::cerr << "Unrecognized option: " << argv[arg_index] << std::endl;
137 return -EINVAL; 149 return -EINVAL;
138 } 150 }
139 arg_index++;
140 } 151 }
141 152
142 // Parse everything else as target information. 153 // Parse everything else as target information.