From 2def03a2b97330720ccd4b75558d93aab66ea73f Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Mon, 22 Jun 2020 12:34:45 -0700 Subject: [PATCH] Add libdm and dmctl support for dm-user targets dm-user is very much a WIP and while this may change (we need to figure out how to get credentials to the dm-user daemon, for example) it seems like a somewhat safe bet to assume that the behavior will at least include a start/end range. Test: I just ran "dmctl create palmer user 0 1024", which created the device. Signed-off-by: Palmer Dabbelt Change-Id: Ic5f84de6a4f09bf906246035d450edd637cc38ed --- fs_mgr/libdm/dm_target.cpp | 7 +++++++ fs_mgr/libdm/include/libdm/dm_target.h | 8 ++++++++ fs_mgr/tools/dmctl.cpp | 2 ++ 3 files changed, 17 insertions(+) diff --git a/fs_mgr/libdm/dm_target.cpp b/fs_mgr/libdm/dm_target.cpp index 250cb82c5..8788b5a4b 100644 --- a/fs_mgr/libdm/dm_target.cpp +++ b/fs_mgr/libdm/dm_target.cpp @@ -280,5 +280,12 @@ std::string DmTargetDefaultKey::GetParameterString() const { return android::base::Join(argv, " "); } +std::string DmTargetUser::GetParameterString() const { + std::vector argv; + argv.push_back(std::to_string(start())); + argv.push_back(std::to_string(size())); + return android::base::Join(argv, " "); +} + } // namespace dm } // namespace android diff --git a/fs_mgr/libdm/include/libdm/dm_target.h b/fs_mgr/libdm/include/libdm/dm_target.h index f986cfee0..57e388447 100644 --- a/fs_mgr/libdm/include/libdm/dm_target.h +++ b/fs_mgr/libdm/include/libdm/dm_target.h @@ -309,6 +309,14 @@ class DmTargetDefaultKey final : public DmTarget { bool is_hw_wrapped_ = false; }; +class DmTargetUser final : public DmTarget { + public: + DmTargetUser(uint64_t start, uint64_t length) : DmTarget(start, length) {} + + std::string name() const override { return "user"; } + std::string GetParameterString() const override; +}; + } // namespace dm } // namespace android diff --git a/fs_mgr/tools/dmctl.cpp b/fs_mgr/tools/dmctl.cpp index 27384571a..7a3d9a930 100644 --- a/fs_mgr/tools/dmctl.cpp +++ b/fs_mgr/tools/dmctl.cpp @@ -174,6 +174,8 @@ class TargetParser final { } return std::make_unique(start_sector, num_sectors, base_device, cow_device, mode, chunk_size); + } else if (target_type == "user") { + return std::make_unique(start_sector, num_sectors); } else { std::cerr << "Unrecognized target type: " << target_type << std::endl; return nullptr;