Merge "poll umount completion from /proc/mounts"
am: 625a098573
Change-Id: Ie6fc3a126124a61c09c6aababb1da7893bb7eff7
This commit is contained in:
commit
cb4dadfb08
2 changed files with 124 additions and 145 deletions
|
|
@ -9,13 +9,15 @@ init_options += \
|
||||||
-DALLOW_LOCAL_PROP_OVERRIDE=1 \
|
-DALLOW_LOCAL_PROP_OVERRIDE=1 \
|
||||||
-DALLOW_PERMISSIVE_SELINUX=1 \
|
-DALLOW_PERMISSIVE_SELINUX=1 \
|
||||||
-DREBOOT_BOOTLOADER_ON_PANIC=1 \
|
-DREBOOT_BOOTLOADER_ON_PANIC=1 \
|
||||||
-DWORLD_WRITABLE_KMSG=1
|
-DWORLD_WRITABLE_KMSG=1 \
|
||||||
|
-DDUMP_ON_UMOUNT_FAILURE=1
|
||||||
else
|
else
|
||||||
init_options += \
|
init_options += \
|
||||||
-DALLOW_LOCAL_PROP_OVERRIDE=0 \
|
-DALLOW_LOCAL_PROP_OVERRIDE=0 \
|
||||||
-DALLOW_PERMISSIVE_SELINUX=0 \
|
-DALLOW_PERMISSIVE_SELINUX=0 \
|
||||||
-DREBOOT_BOOTLOADER_ON_PANIC=0 \
|
-DREBOOT_BOOTLOADER_ON_PANIC=0 \
|
||||||
-DWORLD_WRITABLE_KMSG=0
|
-DWORLD_WRITABLE_KMSG=0 \
|
||||||
|
-DDUMP_ON_UMOUNT_FAILURE=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT)))
|
ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT)))
|
||||||
|
|
|
||||||
263
init/reboot.cpp
263
init/reboot.cpp
|
|
@ -18,10 +18,12 @@
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#include <selinux/selinux.h>
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/quota.h>
|
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
|
@ -39,6 +41,7 @@
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
|
#include <android-base/unique_fd.h>
|
||||||
#include <bootloader_message/bootloader_message.h>
|
#include <bootloader_message/bootloader_message.h>
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
|
|
@ -67,39 +70,58 @@ enum UmountStat {
|
||||||
// Utility for struct mntent
|
// Utility for struct mntent
|
||||||
class MountEntry {
|
class MountEntry {
|
||||||
public:
|
public:
|
||||||
explicit MountEntry(const mntent& entry, bool isMounted = true)
|
explicit MountEntry(const mntent& entry)
|
||||||
: mnt_fsname_(entry.mnt_fsname),
|
: mnt_fsname_(entry.mnt_fsname),
|
||||||
mnt_dir_(entry.mnt_dir),
|
mnt_dir_(entry.mnt_dir),
|
||||||
mnt_type_(entry.mnt_type),
|
mnt_type_(entry.mnt_type),
|
||||||
is_mounted_(isMounted) {}
|
mnt_opts_(entry.mnt_opts) {}
|
||||||
|
|
||||||
bool IsF2Fs() const { return mnt_type_ == "f2fs"; }
|
bool Umount() {
|
||||||
|
int r = umount2(mnt_dir_.c_str(), 0);
|
||||||
|
if (r == 0) {
|
||||||
|
LOG(INFO) << "umounted " << mnt_fsname_ << ":" << mnt_dir_ << " opts " << mnt_opts_;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
PLOG(WARNING) << "cannot umount " << mnt_fsname_ << ":" << mnt_dir_ << " opts "
|
||||||
|
<< mnt_opts_;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsExt4() const { return mnt_type_ == "ext4"; }
|
void DoFsck() {
|
||||||
|
int st;
|
||||||
bool is_mounted() const { return is_mounted_; }
|
if (IsF2Fs()) {
|
||||||
|
const char* f2fs_argv[] = {
|
||||||
void set_is_mounted() { is_mounted_ = false; }
|
"/system/bin/fsck.f2fs", "-f", mnt_fsname_.c_str(),
|
||||||
|
};
|
||||||
const std::string& mnt_fsname() const { return mnt_fsname_; }
|
android_fork_execvp_ext(arraysize(f2fs_argv), (char**)f2fs_argv, &st, true, LOG_KLOG,
|
||||||
|
true, nullptr, nullptr, 0);
|
||||||
const std::string& mnt_dir() const { return mnt_dir_; }
|
} else if (IsExt4()) {
|
||||||
|
const char* ext4_argv[] = {
|
||||||
|
"/system/bin/e2fsck", "-f", "-y", mnt_fsname_.c_str(),
|
||||||
|
};
|
||||||
|
android_fork_execvp_ext(arraysize(ext4_argv), (char**)ext4_argv, &st, true, LOG_KLOG,
|
||||||
|
true, nullptr, nullptr, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool IsBlockDevice(const struct mntent& mntent) {
|
static bool IsBlockDevice(const struct mntent& mntent) {
|
||||||
return android::base::StartsWith(mntent.mnt_fsname, "/dev/block");
|
return android::base::StartsWith(mntent.mnt_fsname, "/dev/block");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsEmulatedDevice(const struct mntent& mntent) {
|
static bool IsEmulatedDevice(const struct mntent& mntent) {
|
||||||
static const std::string SDCARDFS_NAME = "sdcardfs";
|
return android::base::StartsWith(mntent.mnt_fsname, "/data/");
|
||||||
return android::base::StartsWith(mntent.mnt_fsname, "/data/") &&
|
|
||||||
SDCARDFS_NAME == mntent.mnt_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool IsF2Fs() const { return mnt_type_ == "f2fs"; }
|
||||||
|
|
||||||
|
bool IsExt4() const { return mnt_type_ == "ext4"; }
|
||||||
|
|
||||||
std::string mnt_fsname_;
|
std::string mnt_fsname_;
|
||||||
std::string mnt_dir_;
|
std::string mnt_dir_;
|
||||||
std::string mnt_type_;
|
std::string mnt_type_;
|
||||||
bool is_mounted_;
|
std::string mnt_opts_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Turn off backlight while we are performing power down cleanup activities.
|
// Turn off backlight while we are performing power down cleanup activities.
|
||||||
|
|
@ -125,50 +147,6 @@ static void TurnOffBacklight() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoFsck(const MountEntry& entry) {
|
|
||||||
static constexpr int UNMOUNT_CHECK_TIMES = 10;
|
|
||||||
|
|
||||||
if (!entry.IsF2Fs() && !entry.IsExt4()) return;
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
while (count++ < UNMOUNT_CHECK_TIMES) {
|
|
||||||
int fd = TEMP_FAILURE_RETRY(open(entry.mnt_fsname().c_str(), O_RDONLY | O_EXCL));
|
|
||||||
if (fd >= 0) {
|
|
||||||
/* |entry->mnt_dir| has sucessfully been unmounted. */
|
|
||||||
close(fd);
|
|
||||||
break;
|
|
||||||
} else if (errno == EBUSY) {
|
|
||||||
// Some processes using |entry->mnt_dir| are still alive. Wait for a
|
|
||||||
// while then retry.
|
|
||||||
std::this_thread::sleep_for(5000ms / UNMOUNT_CHECK_TIMES);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
/* Cannot open the device. Give up. */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NB: With watchdog still running, there is no cap on the time it takes
|
|
||||||
// to complete the fsck, from the users perspective the device graphics
|
|
||||||
// and responses are locked-up and they may choose to hold the power
|
|
||||||
// button in frustration if it drags out.
|
|
||||||
|
|
||||||
int st;
|
|
||||||
if (entry.IsF2Fs()) {
|
|
||||||
const char* f2fs_argv[] = {
|
|
||||||
"/system/bin/fsck.f2fs", "-f", entry.mnt_fsname().c_str(),
|
|
||||||
};
|
|
||||||
android_fork_execvp_ext(arraysize(f2fs_argv), (char**)f2fs_argv, &st, true, LOG_KLOG, true,
|
|
||||||
nullptr, nullptr, 0);
|
|
||||||
} else if (entry.IsExt4()) {
|
|
||||||
const char* ext4_argv[] = {
|
|
||||||
"/system/bin/e2fsck", "-f", "-y", entry.mnt_fsname().c_str(),
|
|
||||||
};
|
|
||||||
android_fork_execvp_ext(arraysize(ext4_argv), (char**)ext4_argv, &st, true, LOG_KLOG, true,
|
|
||||||
nullptr, nullptr, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ShutdownVold() {
|
static void ShutdownVold() {
|
||||||
const char* vdc_argv[] = {"/system/bin/vdc", "volume", "shutdown"};
|
const char* vdc_argv[] = {"/system/bin/vdc", "volume", "shutdown"};
|
||||||
int status;
|
int status;
|
||||||
|
|
@ -202,21 +180,11 @@ RebootSystem(unsigned int cmd, const std::string& rebootTarget) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoSync() {
|
|
||||||
// quota sync is not done by sync call, so should be done separately.
|
|
||||||
// quota sync is in VFS level, so do it before sync, which goes down to fs level.
|
|
||||||
int r = quotactl(QCMD(Q_SYNC, 0), nullptr, 0 /* do not care */, 0 /* do not care */);
|
|
||||||
if (r < 0) {
|
|
||||||
PLOG(ERROR) << "quotactl failed";
|
|
||||||
}
|
|
||||||
sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find all read+write block devices and emulated devices in /proc/mounts
|
/* Find all read+write block devices and emulated devices in /proc/mounts
|
||||||
* and add them to correpsponding list.
|
* and add them to correpsponding list.
|
||||||
*/
|
*/
|
||||||
static bool FindPartitionsToUmount(std::vector<MountEntry>* blockDevPartitions,
|
static bool FindPartitionsToUmount(std::vector<MountEntry>* blockDevPartitions,
|
||||||
std::vector<MountEntry>* emulatedPartitions) {
|
std::vector<MountEntry>* emulatedPartitions, bool dump) {
|
||||||
std::unique_ptr<std::FILE, int (*)(std::FILE*)> fp(setmntent("/proc/mounts", "r"), endmntent);
|
std::unique_ptr<std::FILE, int (*)(std::FILE*)> fp(setmntent("/proc/mounts", "r"), endmntent);
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
PLOG(ERROR) << "Failed to open /proc/mounts";
|
PLOG(ERROR) << "Failed to open /proc/mounts";
|
||||||
|
|
@ -224,44 +192,63 @@ static bool FindPartitionsToUmount(std::vector<MountEntry>* blockDevPartitions,
|
||||||
}
|
}
|
||||||
mntent* mentry;
|
mntent* mentry;
|
||||||
while ((mentry = getmntent(fp.get())) != nullptr) {
|
while ((mentry = getmntent(fp.get())) != nullptr) {
|
||||||
if (MountEntry::IsBlockDevice(*mentry) && hasmntopt(mentry, "rw")) {
|
if (dump) {
|
||||||
blockDevPartitions->emplace_back(*mentry);
|
LOG(INFO) << "mount entry " << mentry->mnt_fsname << ":" << mentry->mnt_dir << " opts "
|
||||||
|
<< mentry->mnt_opts << " type " << mentry->mnt_type;
|
||||||
|
} else if (MountEntry::IsBlockDevice(*mentry) && hasmntopt(mentry, "rw")) {
|
||||||
|
blockDevPartitions->emplace(blockDevPartitions->begin(), *mentry);
|
||||||
} else if (MountEntry::IsEmulatedDevice(*mentry)) {
|
} else if (MountEntry::IsEmulatedDevice(*mentry)) {
|
||||||
emulatedPartitions->emplace_back(*mentry);
|
emulatedPartitions->emplace(emulatedPartitions->begin(), *mentry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool UmountPartitions(std::vector<MountEntry>* partitions, int maxRetry, int flags) {
|
static void DumpUmountDebuggingInfo() {
|
||||||
static constexpr int SLEEP_AFTER_RETRY_US = 100000;
|
int status;
|
||||||
|
if (!security_getenforce()) {
|
||||||
bool umountDone;
|
LOG(INFO) << "Run lsof";
|
||||||
int retryCounter = 0;
|
const char* lsof_argv[] = {"/system/bin/lsof"};
|
||||||
|
android_fork_execvp_ext(arraysize(lsof_argv), (char**)lsof_argv, &status, true, LOG_KLOG,
|
||||||
while (true) {
|
true, nullptr, nullptr, 0);
|
||||||
umountDone = true;
|
|
||||||
for (auto& entry : *partitions) {
|
|
||||||
if (entry.is_mounted()) {
|
|
||||||
int r = umount2(entry.mnt_dir().c_str(), flags);
|
|
||||||
if (r == 0) {
|
|
||||||
entry.set_is_mounted();
|
|
||||||
LOG(INFO) << StringPrintf("umounted %s, flags:0x%x", entry.mnt_fsname().c_str(),
|
|
||||||
flags);
|
|
||||||
} else {
|
|
||||||
umountDone = false;
|
|
||||||
PLOG(WARNING) << StringPrintf("cannot umount %s, mnt_dir %s, flags:0x%x",
|
|
||||||
entry.mnt_fsname().c_str(),
|
|
||||||
entry.mnt_dir().c_str(), flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (umountDone) break;
|
|
||||||
retryCounter++;
|
|
||||||
if (retryCounter >= maxRetry) break;
|
|
||||||
usleep(SLEEP_AFTER_RETRY_US);
|
|
||||||
}
|
}
|
||||||
return umountDone;
|
FindPartitionsToUmount(nullptr, nullptr, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static UmountStat UmountPartitions(int timeoutMs) {
|
||||||
|
Timer t;
|
||||||
|
UmountStat stat = UMOUNT_STAT_TIMEOUT;
|
||||||
|
int retry = 0;
|
||||||
|
/* data partition needs all pending writes to be completed and all emulated partitions
|
||||||
|
* umounted.If the current waiting is not good enough, give
|
||||||
|
* up and leave it to e2fsck after reboot to fix it.
|
||||||
|
*/
|
||||||
|
while (true) {
|
||||||
|
std::vector<MountEntry> block_devices;
|
||||||
|
std::vector<MountEntry> emulated_devices;
|
||||||
|
if (!FindPartitionsToUmount(&block_devices, &emulated_devices, false)) {
|
||||||
|
return UMOUNT_STAT_ERROR;
|
||||||
|
}
|
||||||
|
if (block_devices.size() == 0) {
|
||||||
|
stat = UMOUNT_STAT_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((timeoutMs < t.duration_ms()) && retry > 0) { // try umount at least once
|
||||||
|
stat = UMOUNT_STAT_TIMEOUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (emulated_devices.size() > 0 &&
|
||||||
|
std::all_of(emulated_devices.begin(), emulated_devices.end(),
|
||||||
|
[](auto& entry) { return entry.Umount(); })) {
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
for (auto& entry : block_devices) {
|
||||||
|
entry.Umount();
|
||||||
|
}
|
||||||
|
retry++;
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
}
|
||||||
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void KillAllProcesses() { android::base::WriteStringToFile("i", "/proc/sysrq-trigger"); }
|
static void KillAllProcesses() { android::base::WriteStringToFile("i", "/proc/sysrq-trigger"); }
|
||||||
|
|
@ -277,56 +264,38 @@ static void KillAllProcesses() { android::base::WriteStringToFile("i", "/proc/sy
|
||||||
*/
|
*/
|
||||||
static UmountStat TryUmountAndFsck(bool runFsck, int timeoutMs) {
|
static UmountStat TryUmountAndFsck(bool runFsck, int timeoutMs) {
|
||||||
Timer t;
|
Timer t;
|
||||||
std::vector<MountEntry> emulatedPartitions;
|
std::vector<MountEntry> block_devices;
|
||||||
std::vector<MountEntry> blockDevRwPartitions;
|
std::vector<MountEntry> emulated_devices;
|
||||||
|
|
||||||
TurnOffBacklight(); // this part can take time. save power.
|
TurnOffBacklight(); // this part can take time. save power.
|
||||||
|
|
||||||
if (!FindPartitionsToUmount(&blockDevRwPartitions, &emulatedPartitions)) {
|
if (runFsck && !FindPartitionsToUmount(&block_devices, &emulated_devices, false)) {
|
||||||
return UMOUNT_STAT_ERROR;
|
return UMOUNT_STAT_ERROR;
|
||||||
}
|
}
|
||||||
if (emulatedPartitions.size() > 0) {
|
|
||||||
LOG(WARNING) << "emulated partitions still exist, will umount";
|
UmountStat stat = UmountPartitions(timeoutMs - t.duration_ms());
|
||||||
/* Pending writes in emulated partitions can fail umount. After a few trials, detach
|
if (stat != UMOUNT_STAT_SUCCESS) {
|
||||||
* it so that it can be umounted when all writes are done.
|
LOG(INFO) << "umount timeout, last resort, kill all and try";
|
||||||
*/
|
if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo();
|
||||||
if (!UmountPartitions(&emulatedPartitions, 1, 0)) {
|
|
||||||
UmountPartitions(&emulatedPartitions, 1, MNT_DETACH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DoSync(); // emulated partition change can lead to update
|
|
||||||
UmountStat stat = UMOUNT_STAT_SUCCESS;
|
|
||||||
/* data partition needs all pending writes to be completed and all emulated partitions
|
|
||||||
* umounted. If umount failed in the above step, it DETACH is requested, so umount can
|
|
||||||
* still happen while waiting for /data. If the current waiting is not good enough, give
|
|
||||||
* up and leave it to e2fsck after reboot to fix it.
|
|
||||||
*/
|
|
||||||
int remainingTimeMs = timeoutMs - t.duration_ms();
|
|
||||||
// each retry takes 100ms, and run at least once.
|
|
||||||
int retry = std::max(remainingTimeMs / 100, 1);
|
|
||||||
if (!UmountPartitions(&blockDevRwPartitions, retry, 0)) {
|
|
||||||
/* Last resort, kill all and try again */
|
|
||||||
LOG(WARNING) << "umount still failing, trying kill all";
|
|
||||||
KillAllProcesses();
|
KillAllProcesses();
|
||||||
DoSync();
|
// even if it succeeds, still it is timeout and do not run fsck with all processes killed
|
||||||
if (!UmountPartitions(&blockDevRwPartitions, 1, 0)) {
|
UmountPartitions(0);
|
||||||
stat = UMOUNT_STAT_TIMEOUT;
|
if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo();
|
||||||
}
|
|
||||||
}
|
|
||||||
// fsck part is excluded from timeout check. It only runs for user initiated shutdown
|
|
||||||
// and should not affect reboot time.
|
|
||||||
if (stat == UMOUNT_STAT_SUCCESS && runFsck) {
|
|
||||||
for (auto& entry : blockDevRwPartitions) {
|
|
||||||
DoFsck(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stat == UMOUNT_STAT_SUCCESS && runFsck) {
|
||||||
|
// fsck part is excluded from timeout check. It only runs for user initiated shutdown
|
||||||
|
// and should not affect reboot time.
|
||||||
|
for (auto& entry : block_devices) {
|
||||||
|
entry.DoFsck();
|
||||||
|
}
|
||||||
|
}
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((noreturn)) DoThermalOff() {
|
static void __attribute__((noreturn)) DoThermalOff() {
|
||||||
LOG(WARNING) << "Thermal system shutdown";
|
LOG(WARNING) << "Thermal system shutdown";
|
||||||
DoSync();
|
sync();
|
||||||
RebootSystem(ANDROID_RB_THERMOFF, "");
|
RebootSystem(ANDROID_RB_THERMOFF, "");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
@ -426,8 +395,8 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
|
||||||
|
|
||||||
// minimum safety steps before restarting
|
// minimum safety steps before restarting
|
||||||
// 2. kill all services except ones that are necessary for the shutdown sequence.
|
// 2. kill all services except ones that are necessary for the shutdown sequence.
|
||||||
ServiceManager::GetInstance().ForEachService([&kill_after_apps](Service* s) {
|
ServiceManager::GetInstance().ForEachService([](Service* s) {
|
||||||
if (!s->IsShutdownCritical() || kill_after_apps.count(s->name())) s->Stop();
|
if (!s->IsShutdownCritical()) s->Stop();
|
||||||
});
|
});
|
||||||
ServiceManager::GetInstance().ReapAnyOutstandingChildren();
|
ServiceManager::GetInstance().ReapAnyOutstandingChildren();
|
||||||
|
|
||||||
|
|
@ -435,12 +404,20 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
|
||||||
Service* voldService = ServiceManager::GetInstance().FindServiceByName("vold");
|
Service* voldService = ServiceManager::GetInstance().FindServiceByName("vold");
|
||||||
if (voldService != nullptr && voldService->IsRunning()) {
|
if (voldService != nullptr && voldService->IsRunning()) {
|
||||||
ShutdownVold();
|
ShutdownVold();
|
||||||
|
voldService->Stop();
|
||||||
} else {
|
} else {
|
||||||
LOG(INFO) << "vold not running, skipping vold shutdown";
|
LOG(INFO) << "vold not running, skipping vold shutdown";
|
||||||
}
|
}
|
||||||
|
// logcat stopped here
|
||||||
|
ServiceManager::GetInstance().ForEachService([&kill_after_apps](Service* s) {
|
||||||
|
if (kill_after_apps.count(s->name())) s->Stop();
|
||||||
|
});
|
||||||
// 4. sync, try umount, and optionally run fsck for user shutdown
|
// 4. sync, try umount, and optionally run fsck for user shutdown
|
||||||
DoSync();
|
sync();
|
||||||
UmountStat stat = TryUmountAndFsck(runFsck, shutdownTimeout * 1000 - t.duration_ms());
|
UmountStat stat = TryUmountAndFsck(runFsck, shutdownTimeout * 1000 - t.duration_ms());
|
||||||
|
// Follow what linux shutdown is doing: one more sync with little bit delay
|
||||||
|
sync();
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
LogShutdownTime(stat, &t);
|
LogShutdownTime(stat, &t);
|
||||||
// Reboot regardless of umount status. If umount fails, fsck after reboot will fix it.
|
// Reboot regardless of umount status. If umount fails, fsck after reboot will fix it.
|
||||||
RebootSystem(cmd, rebootTarget);
|
RebootSystem(cmd, rebootTarget);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue