::vconf_set_bool(VCONFKEY_ODE_FAST_ENCRYPTION, value);
}
+void unmountInternalStorage(const std::string& source)
+{
+ while(true) {
+ auto mntPaths = findMountPointsByDevice(source);
+ if(mntPaths.empty())
+ break;
+
+ bool unmounted = true;
+ for(const auto& path : mntPaths) {
+ INFO(SINK, "Unmounting " + path);
+ if (::umount(path.c_str()) == -1) {
+ // If it's busy or was already unmounted ignore the error
+ if (errno != EBUSY && errno != EINVAL) {
+ throw runtime::Exception("umount() error: " + runtime::GetSystemErrorMessage());
+ }
+ unmounted = false;
+ }
+ }
+ if (!unmounted)
+ stopDependedSystemdServices();
+ }
+}
+
}
InternalEncryptionServer::InternalEncryptionServer(ServerContext& srv,
auto encryptWorker = [masterKey, options, this]() {
try {
std::string source = engine->getSource();
- std::string mntPath = findMountPointByDevice(source);
+ auto mntPaths = findMountPointsByDevice(source);
- if (!mntPath.empty()) {
+ if (!mntPaths.empty()) {
INFO(SINK, "Closing all known systemd services that might be using internal storage.");
stopKnownSystemdServices();
INFO(SINK, "Closing all processes using internal storage.");
stopDependedSystemdServices();
- }
- while (!mntPath.empty()) {
- INFO(SINK, "Umounting internal storage.");
- while (::umount(mntPath.c_str()) == -1) {
- if (errno != EBUSY) {
- throw runtime::Exception("Umount error: " + runtime::GetSystemErrorMessage());
- }
- stopDependedSystemdServices();
- }
- mntPath = findMountPointByDevice(source);
+ INFO(SINK, "Unmounting internal storage.");
+ unmountInternalStorage(source);
}
showProgressUI("Encrypting");
}
-std::string findMountPointByDevice(const std::string &devPath)
+std::vector<std::string> findMountPointsByDevice(const std::string &devPath)
{
- std::string ret;
+ std::vector<std::string> ret;
Mtab mtab;
struct ::mntent* entry = NULL;
while ((entry = mtab.next()) != NULL) {
- if (devPath == entry->mnt_fsname) {
- ret = entry->mnt_dir;
- break;
- }
+ if (devPath == entry->mnt_fsname)
+ ret.push_back(entry->mnt_dir);
}
return ret;