Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97870085 authored by Nikita Ioffe's avatar Nikita Ioffe Committed by Automerger Merge Worker
Browse files

Merge "Reboot sequence: Unmount active apexes before unmounting /data" am:...

Merge "Reboot sequence: Unmount active apexes before unmounting /data" am: b2551953 am: d60f0708 am: 64697dcd

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1327913

Change-Id: Ib09a3d7ac483cb16167acf83f8ce58879d7ad5fa
parents ad3790ad 64697dcd
Loading
Loading
Loading
Loading
+17 −12
Original line number Original line Diff line number Diff line
@@ -544,6 +544,18 @@ static int StopServicesAndLogViolations(const std::vector<Service*>& services,
    return still_running;
    return still_running;
}
}


static Result<void> UnmountAllApexes() {
    const char* args[] = {"/system/bin/apexd", "--unmount-all"};
    int status;
    if (logwrap_fork_execvp(arraysize(args), args, &status, false, LOG_KLOG, true, nullptr) != 0) {
        return ErrnoError() << "Failed to call '/system/bin/apexd --unmount-all'";
    }
    if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
        return {};
    }
    return Error() << "'/system/bin/apexd --unmount-all' failed : " << status;
}

//* Reboot / shutdown the system.
//* Reboot / shutdown the system.
// cmd ANDROID_RB_* as defined in android_reboot.h
// cmd ANDROID_RB_* as defined in android_reboot.h
// reason Reason string like "reboot", "shutdown,userrequested"
// reason Reason string like "reboot", "shutdown,userrequested"
@@ -701,6 +713,11 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str
    // 5. drop caches and disable zram backing device, if exist
    // 5. drop caches and disable zram backing device, if exist
    KillZramBackingDevice();
    KillZramBackingDevice();


    LOG(INFO) << "Ready to unmount apexes. So far shutdown sequence took " << t;
    // 6. unmount active apexes, otherwise they might prevent clean unmount of /data.
    if (auto ret = UnmountAllApexes(); !ret.ok()) {
        LOG(ERROR) << ret.error();
    }
    UmountStat stat =
    UmountStat stat =
            TryUmountAndFsck(cmd, run_fsck, shutdown_timeout - t.duration(), &reboot_semaphore);
            TryUmountAndFsck(cmd, run_fsck, shutdown_timeout - t.duration(), &reboot_semaphore);
    // Follow what linux shutdown is doing: one more sync with little bit delay
    // Follow what linux shutdown is doing: one more sync with little bit delay
@@ -739,18 +756,6 @@ static void LeaveShutdown() {
    StartSendingMessages();
    StartSendingMessages();
}
}


static Result<void> UnmountAllApexes() {
    const char* args[] = {"/system/bin/apexd", "--unmount-all"};
    int status;
    if (logwrap_fork_execvp(arraysize(args), args, &status, false, LOG_KLOG, true, nullptr) != 0) {
        return ErrnoError() << "Failed to call '/system/bin/apexd --unmount-all'";
    }
    if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
        return {};
    }
    return Error() << "'/system/bin/apexd --unmount-all' failed : " << status;
}

static std::chrono::milliseconds GetMillisProperty(const std::string& name,
static std::chrono::milliseconds GetMillisProperty(const std::string& name,
                                                   std::chrono::milliseconds default_value) {
                                                   std::chrono::milliseconds default_value) {
    auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count()));
    auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count()));