SET(SERVER_SRCS main.cpp
server.cpp
launchpad.cpp
+ misc.cpp
ext4-tool.cpp
app-bundle.cpp
file-footer.cpp
*/
#include <mutex>
-#include <signal.h>
#include <unistd.h>
#include <sys/mount.h>
-#include <stdio.h>
-#include <mntent.h>
#include <klay/file-user.h>
#include <klay/filesystem.h>
#include <klay/dbus/variant.h>
#include <klay/dbus/connection.h>
+#include "misc.h"
#include "logger.h"
#include "ext4-tool.h"
#include "engine/encryption/cryptsetup-engine.h"
std::mutex stateGuard;
std::condition_variable storagedCv;
-std::string findMntPath(const std::string &devPath)
-{
- std::string ret;
-
- FILE* mtab = setmntent("/etc/mtab", "r");
- struct mntent* entry = NULL;
- while ((entry = getmntent(mtab)) != NULL) {
- if (devPath == entry->mnt_fsname) {
- ret = entry->mnt_dir;
- break;
- }
- }
- endmntent(mtab);
-
- return ret;
-}
-
-void killDependedApplications(const std::string &mntPath)
-{
- for (pid_t pid : runtime::FileUser::getList(mntPath, true)) {
- INFO(SINK, "Close process - " + std::to_string(pid));
- ::kill(pid, SIGKILL);
- }
-}
-
bool findKillAndUmount(const std::string &devPath)
{
std::string realMntPath = findMntPath(devPath);
if (!realMntPath.empty()) {
INFO(SINK, "Closing all applications using an SD card...");
- killDependedApplications(realMntPath);
+ killDependentApplications(realMntPath);
int ret = ::umount(realMntPath.c_str());
if (ret != 0) {
if (isMounted()) {
INFO(SINK, "Close all applications using extension storage...");
- killDependedApplications(info[Device::MAP].mntPath);
+ killDependentApplications(info[Device::MAP].mntPath);
INFO(SINK, "Ask storaged to umount extension storage...");
if (!storagedUnmount(stateLock)) {
#include <fstream>
#include <sstream>
-#include <signal.h>
#include <unistd.h>
#include <sys/mount.h>
#include <klay/dbus/variant.h>
#include <klay/dbus/connection.h>
+#include "misc.h"
#include "logger.h"
#include "launchpad.h"
#include "app-bundle.h"
KeyManager::data mountKey;
bool isBootCompleted = false;
-void killDependedApplications()
-{
- for (pid_t pid : runtime::FileUser::getList(EXTERNAL_PATH, true)) {
- INFO(SINK, "Close process - " + std::to_string(pid));
- ::kill(pid, SIGKILL);
- }
-}
-
void externalCallback(dbus::Variant parameters)
{
int intparams[6];
}
INFO(SINK, "Close all applications using external storage...");
- killDependedApplications();
+ killDependentApplications(EXTERNAL_PATH);
INFO(SINK, "Umount external storage...");
engine->umount();
auto encryptWorker = [MasterKey, options, this]() {
try {
INFO(SINK, "Close all applications using external storage...");
- killDependedApplications();
+ killDependentApplications(EXTERNAL_PATH);
INFO(SINK, "Encryption started...");
engine->encrypt(MasterKey, options);
setOptions(options & getSupportedOptions());
auto decryptWorker = [MasterKey, this]() {
try {
INFO(SINK, "Close all applications using external storage...");
- killDependedApplications();
+ killDependentApplications(EXTERNAL_PATH);
INFO(SINK, "Umount external storage...");
while (1) {
try {
engine->umount();
break;
} catch (runtime::Exception &e) {
- killDependedApplications();
+ killDependentApplications(EXTERNAL_PATH);
}
}
#include <unistd.h>
#include <sys/mount.h>
#include <sys/reboot.h>
-#include <stdio.h>
-#include <mntent.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <klay/filesystem.h>
#include <klay/dbus/connection.h>
+#include "misc.h"
#include "logger.h"
#include "progress-bar.h"
#include "engine/encryption/dmcrypt-engine.h"
return devPath;
}
-std::string findMntPath(const std::string &devPath)
-{
- std::string ret;
-
- FILE* mtab = ::setmntent("/etc/mtab", "r");
- struct mntent* entry = NULL;
- while ((entry = ::getmntent(mtab)) != NULL) {
- if (devPath == entry->mnt_fsname) {
- ret = entry->mnt_dir;
- break;
- }
- }
- ::endmntent(mtab);
-
- return ret;
-}
-
void stopKnownSystemdServices() {
std::vector<std::string> knownSystemdServices;
dbus::Connection& systemDBus = dbus::Connection::getSystem();
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+#include <signal.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <mntent.h>
+
+#include <klay/file-user.h>
+
+#include "logger.h"
+#include "misc.h"
+
+namespace ode {
+
+std::string findMntPath(const std::string &devPath)
+{
+ std::string ret;
+
+ FILE* mtab = ::setmntent("/etc/mtab", "r");
+ struct ::mntent* entry = NULL;
+ while ((entry = ::getmntent(mtab)) != NULL) {
+ if (devPath == entry->mnt_fsname) {
+ ret = entry->mnt_dir;
+ break;
+ }
+ }
+ ::endmntent(mtab);
+
+ return ret;
+}
+
+void killDependentApplications(const std::string &mntPath)
+{
+ for (pid_t pid : runtime::FileUser::getList(mntPath, true)) {
+ INFO(SINK, "Close process - " + std::to_string(pid));
+ ::kill(pid, SIGKILL);
+ }
+}
+
+} // namespace ode
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __MISC_H__
+#define __MISC_H__
+
+#include <string>
+
+namespace ode {
+
+std::string findMntPath(const std::string &devPath);
+void killDependentApplications(const std::string &mntPath);
+
+} // namespace ode
+#endif // __MISC_H__