diff options
Diffstat (limited to 'fs_mgr/libdm/dm.cpp')
-rw-r--r-- | fs_mgr/libdm/dm.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp index d5b8a6113..c4874b8d1 100644 --- a/fs_mgr/libdm/dm.cpp +++ b/fs_mgr/libdm/dm.cpp @@ -35,6 +35,10 @@ #include "utility.h" +#ifndef DM_DEFERRED_REMOVE +#define DM_DEFERRED_REMOVE (1 << 17) +#endif + namespace android { namespace dm { @@ -133,6 +137,25 @@ bool DeviceMapper::DeleteDevice(const std::string& name) { return DeleteDevice(name, 0ms); } +bool DeviceMapper::DeleteDeviceDeferred(const std::string& name) { + struct dm_ioctl io; + InitIo(&io, name); + + io.flags |= DM_DEFERRED_REMOVE; + if (ioctl(fd_, DM_DEV_REMOVE, &io)) { + PLOG(ERROR) << "DM_DEV_REMOVE with DM_DEFERRED_REMOVE failed for [" << name << "]"; + return false; + } + return true; +} + +bool DeviceMapper::DeleteDeviceIfExistsDeferred(const std::string& name) { + if (GetState(name) == DmDeviceState::INVALID) { + return true; + } + return DeleteDeviceDeferred(name); +} + static std::string GenerateUuid() { uuid_t uuid_bytes; uuid_generate(uuid_bytes); |