Continue operation if /opt/usr is not mounted 62/128062/6
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 4 May 2017 10:08:34 +0000 (12:08 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 24 May 2017 09:04:32 +0000 (11:04 +0200)
Also skip ENXIO error when device mapper entry is being removed

Change-Id: I339b43ae73ce68928abe8453021add42061cd18e

server/engine/encryption/dmcrypt-engine.cpp

index 7c4d16d..0820e49 100644 (file)
@@ -19,6 +19,7 @@
 #include <sys/mount.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>
 
 #include <klay/audit/logger.h>
 
@@ -186,9 +187,10 @@ void destroyCryptoBlkDev(const std::string &cryptoBlkDev)
 
        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");
        }
 }
@@ -252,7 +254,7 @@ void DMCryptEngine::mount(const DMCryptEngine::data &key, unsigned int options)
 
 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);