#include <sys/mount.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
#include <klay/audit/logger.h>
initDMIoctl(buf, sizeof(buf), cryptoBlkDev, 0);
ret = ioctl(fd, DM_DEV_REMOVE, buf);
+ int err = errno;
close(fd);
- if (ret != 0) {
+ if (ret != 0 && err != ENXIO) {
throw runtime::Exception("Cannot remove dm-crypt device");
}
}
void DMCryptEngine::umount()
{
- if (::umount(destination.c_str()))
+ if (::umount(destination.c_str()) && errno != EINVAL)
throw runtime::Exception(runtime::GetSystemErrorMessage());
destroyCryptoBlkDev(DM_DEFAULT_LABEL_NAME);