Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 913682af authored by David Anderson's avatar David Anderson Committed by android-build-merger
Browse files

Merge "libdm: Add a helper function for GetState+DeleteDevice checks." am:...

Merge "libdm: Add a helper function for GetState+DeleteDevice checks." am: b21f3dd7 am: d84ebe94 am: df446727
am: f2350173

Change-Id: I9e7c67d0a174f7981099d327a712bfb739007420
parents 5af64ebc f2350173
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,13 @@ bool DeviceMapper::CreateDevice(const std::string& name, const std::string& uuid
    return true;
}

bool DeviceMapper::DeleteDeviceIfExists(const std::string& name) {
    if (GetState(name) == DmDeviceState::INVALID) {
        return true;
    }
    return DeleteDevice(name);
}

bool DeviceMapper::DeleteDevice(const std::string& name) {
    struct dm_ioctl io;
    InitIo(&io, name);
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ class DeviceMapper final {
    // Removes a device mapper device with the given name.
    // Returns 'true' on success, false otherwise.
    bool DeleteDevice(const std::string& name);
    bool DeleteDeviceIfExists(const std::string& name);

    // Fetches and returns the complete state of the underlying device mapper
    // device with given name.