summaryrefslogtreecommitdiff
path: root/fs_mgr/tools/dmctl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fs_mgr/tools/dmctl.cpp')
-rw-r--r--fs_mgr/tools/dmctl.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/fs_mgr/tools/dmctl.cpp b/fs_mgr/tools/dmctl.cpp
index 7a3d9a930..9edcda705 100644
--- a/fs_mgr/tools/dmctl.cpp
+++ b/fs_mgr/tools/dmctl.cpp
@@ -38,6 +38,7 @@
#include <vector>
using namespace std::literals::string_literals;
+using namespace std::chrono_literals;
using namespace android::dm;
using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice;
@@ -49,6 +50,7 @@ static int Usage(void) {
std::cerr << " delete <dm-name>" << std::endl;
std::cerr << " list <devices | targets> [-v]" << std::endl;
std::cerr << " getpath <dm-name>" << std::endl;
+ std::cerr << " getuuid <dm-name>" << std::endl;
std::cerr << " info <dm-name>" << std::endl;
std::cerr << " status <dm-name>" << std::endl;
std::cerr << " resume <dm-name>" << std::endl;
@@ -241,8 +243,9 @@ static int DmCreateCmdHandler(int argc, char** argv) {
return ret;
}
+ std::string ignore_path;
DeviceMapper& dm = DeviceMapper::Instance();
- if (!dm.CreateDevice(name, table)) {
+ if (!dm.CreateDevice(name, table, &ignore_path, 5s)) {
std::cerr << "Failed to create device-mapper device with name: " << name << std::endl;
return -EIO;
}
@@ -391,6 +394,22 @@ static int GetPathCmdHandler(int argc, char** argv) {
return 0;
}
+static int GetUuidCmdHandler(int argc, char** argv) {
+ if (argc != 1) {
+ std::cerr << "Invalid arguments, see \'dmctl help\'" << std::endl;
+ return -EINVAL;
+ }
+
+ DeviceMapper& dm = DeviceMapper::Instance();
+ std::string uuid;
+ if (!dm.GetDmDeviceUuidByName(argv[0], &uuid)) {
+ std::cerr << "Could not query uuid of device \"" << argv[0] << "\"." << std::endl;
+ return -EINVAL;
+ }
+ std::cout << uuid << std::endl;
+ return 0;
+}
+
static int InfoCmdHandler(int argc, char** argv) {
if (argc != 1) {
std::cerr << "Invalid arguments, see \'dmctl help\'" << std::endl;
@@ -504,6 +523,7 @@ static std::map<std::string, std::function<int(int, char**)>> cmdmap = {
{"list", DmListCmdHandler},
{"help", HelpCmdHandler},
{"getpath", GetPathCmdHandler},
+ {"getuuid", GetUuidCmdHandler},
{"info", InfoCmdHandler},
{"table", TableCmdHandler},
{"status", StatusCmdHandler},