jobsCv.notify_one();
}
-void stopKnownSystemdUnits()
-{
- std::vector<std::string> knownSystemdUnits;
- dbus::Connection& systemDBus = dbus::Connection::getSystem();
- dbus::VariantIterator iter;
-
- systemDBus.methodcall("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "ListUnits",
- -1, "(a(ssssssouso))", "")
- .get("(a(ssssssouso))", &iter);
-
- while (1) {
- unsigned int dataUint;
- char *dataStr[9];
- int ret;
-
- ret = iter.get("(ssssssouso)", dataStr, dataStr + 1, dataStr + 2,
- dataStr + 3, dataStr + 4, dataStr + 5,
- dataStr + 6, &dataUint, dataStr + 7,
- dataStr + 8);
-
- if (!ret) {
- break;
- }
-
- std::string unit(dataStr[0]);
- if (unit == "security-manager.socket" ||
- unit == "connman.socket") {
- knownSystemdUnits.insert(knownSystemdUnits.begin(), unit);
- } else if (unit.compare(0, 5, "user@") == 0 ||
- unit == "tlm.service" ||
- unit == "resourced.service" ||
- unit == "security-manager.service") {
- knownSystemdUnits.push_back(unit);
- }
- }
-
- JobWatch watch(systemDBus);
-
- for (const std::string& unit : knownSystemdUnits) {
- INFO(SINK, "Stopping unit: " + unit);
- const char* job = NULL;
- systemDBus.methodcall("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StopUnit",
- -1, "(o)", "(ss)", unit.c_str(), "flush").get("(o)", &job);
- INFO(SINK, "Waiting for job: " + std::string(job));
- if (!watch.waitForJob(job))
- throw runtime::Exception("Stopping unit: " + unit + " failed");
- }
-}
-
std::string getDecodedPath(const std::string &path, const std::string &prefix)
{
std::string ret = path;
INFO(SINK, "Closing all processes using internal storage.");
try {
- stopKnownSystemdUnits();
stopDependedSystemdUnits();
INFO(SINK, "Umounting internal storage.");
unmountInternalStorage("/dev/mapper/userdata");
runtime::File file("/opt/etc/.odeprogress");
file.create(0640);
- INFO(SINK, "Closing all known systemd services that might be using internal storage.");
- stopKnownSystemdUnits();
-
std::string source = engine->getSource();
auto mntPaths = findMountPointsByDevice(source);
file.create(0640);
if (engine->isMounted()) {
- INFO(SINK, "Closing all known systemd services that might be using internal storage.");
- stopKnownSystemdUnits();
INFO(SINK, "Closing all processes using internal storage.");
stopDependedSystemdUnits();