Loading fs_mgr/libdm/dm.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,15 @@ bool DeviceMapper::GetDeviceUniquePath(const std::string& name, std::string* pat return true; } std::optional<DeviceMapper::Info> DeviceMapper::GetDetailedInfo(const std::string& name) const { struct dm_ioctl io; InitIo(&io, name); if (ioctl(fd_, DM_DEV_STATUS, &io) < 0) { return std::nullopt; } return Info(io.flags); } DmDeviceState DeviceMapper::GetState(const std::string& name) const { struct dm_ioctl io; InitIo(&io, name); Loading fs_mgr/libdm/include/libdm/dm.h +18 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <chrono> #include <memory> #include <optional> #include <string> #include <utility> #include <vector> Loading Loading @@ -70,10 +71,27 @@ class DeviceMapper final { uint64_t dev_; }; class Info { uint32_t flags_; public: explicit Info(uint32_t flags) : flags_(flags) {} bool IsActiveTablePresent() const { return flags_ & DM_ACTIVE_PRESENT_FLAG; } bool IsBufferFull() const { return flags_ & DM_BUFFER_FULL_FLAG; } bool IsInactiveTablePresent() const { return flags_ & DM_INACTIVE_PRESENT_FLAG; } bool IsReadOnly() const { return flags_ & DM_READONLY_FLAG; } bool IsSuspended() const { return flags_ & DM_SUSPEND_FLAG; } }; // Removes a device mapper device with the given name. // Returns 'true' on success, false otherwise. bool DeleteDevice(const std::string& name); // Fetches and returns the complete state of the underlying device mapper // device with given name. std::optional<Info> GetDetailedInfo(const std::string& name) const; // Returns the current state of the underlying device mapper device // with given name. // One of INVALID, SUSPENDED or ACTIVE. Loading Loading
fs_mgr/libdm/dm.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,15 @@ bool DeviceMapper::GetDeviceUniquePath(const std::string& name, std::string* pat return true; } std::optional<DeviceMapper::Info> DeviceMapper::GetDetailedInfo(const std::string& name) const { struct dm_ioctl io; InitIo(&io, name); if (ioctl(fd_, DM_DEV_STATUS, &io) < 0) { return std::nullopt; } return Info(io.flags); } DmDeviceState DeviceMapper::GetState(const std::string& name) const { struct dm_ioctl io; InitIo(&io, name); Loading
fs_mgr/libdm/include/libdm/dm.h +18 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <chrono> #include <memory> #include <optional> #include <string> #include <utility> #include <vector> Loading Loading @@ -70,10 +71,27 @@ class DeviceMapper final { uint64_t dev_; }; class Info { uint32_t flags_; public: explicit Info(uint32_t flags) : flags_(flags) {} bool IsActiveTablePresent() const { return flags_ & DM_ACTIVE_PRESENT_FLAG; } bool IsBufferFull() const { return flags_ & DM_BUFFER_FULL_FLAG; } bool IsInactiveTablePresent() const { return flags_ & DM_INACTIVE_PRESENT_FLAG; } bool IsReadOnly() const { return flags_ & DM_READONLY_FLAG; } bool IsSuspended() const { return flags_ & DM_SUSPEND_FLAG; } }; // Removes a device mapper device with the given name. // Returns 'true' on success, false otherwise. bool DeleteDevice(const std::string& name); // Fetches and returns the complete state of the underlying device mapper // device with given name. std::optional<Info> GetDetailedInfo(const std::string& name) const; // Returns the current state of the underlying device mapper device // with given name. // One of INVALID, SUSPENDED or ACTIVE. Loading