Add flag file to check ode progress for mount unit 69/181969/1
authorseolheui kim <s414.kim@samsung.com>
Tue, 19 Jun 2018 08:14:25 +0000 (17:14 +0900)
committerseolheui kim <s414.kim@samsung.com>
Tue, 19 Jun 2018 08:14:25 +0000 (17:14 +0900)
- create & remove "/opt/etc/.odeprogress" file
- fix to use klay filesystem for flag files

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

index ed5b6fc..ef38a5f 100644 (file)
@@ -411,6 +411,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();
 
@@ -434,6 +437,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);
@@ -465,6 +470,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();
@@ -489,6 +497,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);
@@ -513,9 +523,8 @@ int InternalEncryptionServer::recovery()
        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 {