Add to ignore the case of /opt/usr partition label accepted/tizen/unified/20170427.180137 submit/tizen/20170424.075155 submit/tizen/20170427.015729
authorSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 24 Apr 2017 06:48:26 +0000 (15:48 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 24 Apr 2017 07:48:24 +0000 (16:48 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: Ifdc0bea05bbcb4da58e243dd87e7a9b9c659ddda

server/internal-encryption.cpp

index 5c48016..deeb064 100644 (file)
@@ -14,6 +14,7 @@
  *  limitations under the License
  */
 #include <set>
+#include <algorithm>
 
 #include <fcntl.h>
 #include <signal.h>
@@ -37,8 +38,9 @@
 #include "rmi/internal-encryption.h"
 
 #define INTERNAL_ENGINE        DMCryptEngine
-#define INTERNAL_DEV   "/dev/disk/by-partlabel/USER"
-#define INTERNAL_PATH  "/opt/usr"
+#define INTERNAL_DEV_PATH      "/dev/disk/by-partlabel"
+#define INTERNAL_DEV_NAME      "USER"
+#define INTERNAL_PATH          "/opt/usr"
 #define INTERNAL_STATE_VCONF_KEY                                       VCONFKEY_ODE_CRYPTO_STATE
 #define INTERNAL_OPTION_ONLY_USED_REGION_VCONF_KEY     VCONFKEY_ODE_FAST_ENCRYPTION
 
@@ -211,8 +213,28 @@ InternalEncryption::InternalEncryption(ODEControlContext& ctx) :
 
        context.createNotification("InternalEncryption::mount");
 
+       std::string source = INTERNAL_DEV_PATH "/" INTERNAL_DEV_NAME;
+       try {
+               runtime::DirectoryIterator iter(INTERNAL_DEV_PATH), end;
+
+               while (iter != end) {
+                       const std::string& path = (*iter).getPath();
+                       std::string name = path.substr(path.rfind('/') + 1);
+                       std::string upper;
+                       upper.reserve(name.size());
+                       for (char c : name) {
+                               upper += std::toupper(c);
+                       }
+                       if (upper == INTERNAL_DEV_NAME) {
+                               source = path;
+                               break;
+                       }
+                       ++iter;
+               }
+       } catch (runtime::Exception &e) {}
+
        engine.reset(new INTERNAL_ENGINE(
-               INTERNAL_DEV, INTERNAL_PATH,
+               source, INTERNAL_PATH,
                ProgressBar([](int v) {
                        ::vconf_set_str(VCONFKEY_ODE_ENCRYPT_PROGRESS,
                                                        std::to_string(v).c_str());