From 257e7f052dff0da3053344f9e986c9543b521e6d Mon Sep 17 00:00:00 2001 From: seolheui kim Date: Tue, 19 Jun 2018 17:14:25 +0900 Subject: [PATCH] Add flag file to check ode progress for mount unit - create & remove "/opt/etc/.odeprogress" file - fix to use klay filesystem for flag files Change-Id: Iae42716b6edd907ebe8fd21a7050cfa1f488a4bd Signed-off-by: seolheui kim --- server/internal-encryption.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/internal-encryption.cpp b/server/internal-encryption.cpp index ed5b6fc..ef38a5f 100644 --- a/server/internal-encryption.cpp +++ b/server/internal-encryption.cpp @@ -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 { -- 2.34.1