Catch internal mount/umount error messages 01/147501/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 4 Sep 2017 13:16:51 +0000 (15:16 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 11 Sep 2017 11:26:20 +0000 (13:26 +0200)
Change-Id: Ic72c3352914600b2bdafa270600e556c0e9385e8

server/internal-encryption.cpp

index cfb9099..7704078 100644 (file)
@@ -272,13 +272,19 @@ int InternalEncryption::mount()
                return 0;
        }
 
-       engine->mount(mountKey, getOptions());
-       mountKey.clear();
+       try {
+               INFO(SINK, "Mount internal storage...");
+               engine->mount(mountKey, getOptions());
+               mountKey.clear();
 
-       context.notify("InternalEncryption::mount");
+               context.notify("InternalEncryption::mount");
 
-       runtime::File("/tmp/.lazy_mount").create(O_WRONLY);
-       runtime::File("/tmp/.unlock_mnt").create(O_WRONLY);
+               runtime::File("/tmp/.lazy_mount").create(O_WRONLY);
+               runtime::File("/tmp/.unlock_mnt").create(O_WRONLY);
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, "Mount failed - " + std::string(e.what()));
+               return -1;
+       }
 
        return 0;
 }
@@ -294,10 +300,15 @@ int InternalEncryption::umount()
                return 0;
        }
 
-       INFO(SINK, "Close all processes using internal storage...");
-       stopDependedSystemdServices();
-       INFO(SINK, "Umount internal storage...");
-       engine->umount();
+       try {
+               INFO(SINK, "Close all processes using internal storage...");
+               stopDependedSystemdServices();
+               INFO(SINK, "Umount internal storage...");
+               engine->umount();
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, "Umount failed - " + std::string(e.what()));
+               return -1;
+       }
 
        return 0;
 }