summaryrefslogtreecommitdiff
path: root/fs_mgr/libdm/dm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fs_mgr/libdm/dm.cpp')
-rw-r--r--fs_mgr/libdm/dm.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 791268849..bb7d8b311 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -427,6 +427,20 @@ bool DeviceMapper::GetDmDevicePathByName(const std::string& name, std::string* p
return true;
}
+// Accepts a device mapper device name (like system_a, vendor_b etc) and
+// returns its UUID.
+bool DeviceMapper::GetDmDeviceUuidByName(const std::string& name, std::string* uuid) {
+ struct dm_ioctl io;
+ InitIo(&io, name);
+ if (ioctl(fd_, DM_DEV_STATUS, &io) < 0) {
+ PLOG(WARNING) << "DM_DEV_STATUS failed for " << name;
+ return false;
+ }
+
+ *uuid = std::string(io.uuid);
+ return true;
+}
+
bool DeviceMapper::GetDeviceNumber(const std::string& name, dev_t* dev) {
struct dm_ioctl io;
InitIo(&io, name);