Merge "libdm: dm-user target creation takes an additional argument" am: ba0b4bb900
am: 04f62185f2
am: 1f98ef3a53
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1455620 Change-Id: Id344c7c114a1c99bb5b0be8d1105effb1064b5d4
This commit is contained in:
commit
1f4f88a5c3
3 changed files with 13 additions and 2 deletions
|
@ -284,6 +284,7 @@ std::string DmTargetUser::GetParameterString() const {
|
|||
std::vector<std::string> argv;
|
||||
argv.push_back(std::to_string(start()));
|
||||
argv.push_back(std::to_string(size()));
|
||||
argv.push_back(control_device());
|
||||
return android::base::Join(argv, " ");
|
||||
}
|
||||
|
||||
|
|
|
@ -311,10 +311,15 @@ class DmTargetDefaultKey final : public DmTarget {
|
|||
|
||||
class DmTargetUser final : public DmTarget {
|
||||
public:
|
||||
DmTargetUser(uint64_t start, uint64_t length) : DmTarget(start, length) {}
|
||||
DmTargetUser(uint64_t start, uint64_t length, std::string control_device)
|
||||
: DmTarget(start, length), control_device_(control_device) {}
|
||||
|
||||
std::string name() const override { return "user"; }
|
||||
std::string control_device() const { return control_device_; }
|
||||
std::string GetParameterString() const override;
|
||||
|
||||
private:
|
||||
std::string control_device_;
|
||||
};
|
||||
|
||||
} // namespace dm
|
||||
|
|
|
@ -177,7 +177,12 @@ class TargetParser final {
|
|||
return std::make_unique<DmTargetSnapshot>(start_sector, num_sectors, base_device,
|
||||
cow_device, mode, chunk_size);
|
||||
} else if (target_type == "user") {
|
||||
return std::make_unique<DmTargetUser>(start_sector, num_sectors);
|
||||
if (!HasArgs(1)) {
|
||||
std::cerr << "Expected \"user\" <control_device_name>" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
std::string control_device = NextArg();
|
||||
return std::make_unique<DmTargetUser>(start_sector, num_sectors, control_device);
|
||||
} else {
|
||||
std::cerr << "Unrecognized target type: " << target_type << std::endl;
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in a new issue