Add flag file to check ode progress for mount unit 59/182559/2 accepted/tizen/4.0/unified/20180626.233629 submit/tizen_4.0/20180626.081405
authorseolheui kim <s414.kim@samsung.com>
Tue, 26 Jun 2018 06:29:16 +0000 (15:29 +0900)
committerseolheui kim <s414.kim@samsung.com>
Tue, 26 Jun 2018 08:02:46 +0000 (17:02 +0900)
- create & remove "/opt/etc/.odeprogress" file
- fix to use klay filesystem for flag files

Change-Id: Id0188a59468bc8a4aeb94f058cdf0bdec2916e66
Signed-off-by: seolheui kim <s414.kim@samsung.com>
server/internal-encryption.cpp

index aaeb9e2..0c310f0 100644 (file)
@@ -424,6 +424,9 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int
                        showProgressUI("encrypt");
                        ::sleep(1);
 
+                       runtime::File file("/opt/etc/.odeprogress");
+                       file.create(0640);
+
                        INFO(SINK, "Closing all known systemd services that might be using internal storage.");
                        stopKnownSystemdUnits();
 
@@ -447,6 +450,8 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int
                        ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "encrypted");
                        server.notify("InternalEncryptionServer::mount");
 
+                       file.remove();
+
                        INFO(SINK, "Syncing disk and rebooting.");
                        ::sync();
                        ::reboot(RB_AUTOBOOT);
@@ -478,6 +483,9 @@ int InternalEncryptionServer::decrypt(const std::string& password)
                        showProgressUI("decrypt");
                        ::sleep(1);
 
+                       runtime::File file("/opt/etc/.odeprogress");
+                       file.create(0640);
+
                        if (engine->isMounted()) {
                                INFO(SINK, "Closing all known systemd services that might be using internal storage.");
                                stopKnownSystemdUnits();
@@ -502,6 +510,8 @@ int InternalEncryptionServer::decrypt(const std::string& password)
                        INFO(SINK, "Decryption complete.");
                        ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "unencrypted");
 
+                       file.remove();
+
                        INFO(SINK, "Syncing disk and rebooting.");
                        ::sync();
                        ::reboot(RB_AUTOBOOT);
@@ -523,12 +533,8 @@ int InternalEncryptionServer::recovery()
        if (state == State::Unencrypted)
                return error::NoSuchDevice;
 
-       if (state == State::Corrupted)
-               Ext4Tool::mkfs(engine->getSource());
-
-       std::fstream fs;
-       fs.open("/opt/.factoryreset", std::ios::out);
-       fs.close();
+       runtime::File file("/opt/.factoryreset");
+       file.create(0640);
 
        ::sync();
        try {