summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-04-05 08:10:25 -0700
committerMark Salyzyn <salyzyn@google.com>2016-04-05 12:44:24 -0700
commit0fcc2ee4e4e6142c0d789a456f18caf33596ea3c (patch)
tree51d44f3f303d279a60edab4178e285c9420f154e /init/builtins.cpp
parent1ab87e7712cea615ecdf70e65d74d14d3fd8fa85 (diff)
init: watchdog restarted during shutdown fsck
(cherry pick from commit ad575e04a1d89f5a2a4e3006a58e801cad9c9805) Bug: 27506425 Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 2e7283206..30d648bba 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -21,6 +21,7 @@
#include <mntent.h>
#include <net/if.h>
#include <signal.h>
+#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -127,6 +128,16 @@ static void unmount_and_fsck(const struct mntent *entry) {
ServiceManager::GetInstance().ForEachService([] (Service* s) { s->Stop(); });
TEMP_FAILURE_RETRY(kill(-1, SIGKILL));
+ // Restart Watchdogd to allow us to complete umounting and fsck
+ Service *svc = ServiceManager::GetInstance().FindServiceByName("watchdogd");
+ if (svc) {
+ do {
+ sched_yield(); // do not be so eager, let cleanup have priority
+ ServiceManager::GetInstance().ReapAnyOutstandingChildren();
+ } while (svc->flags() & SVC_RUNNING); // Paranoid Cargo
+ svc->Start();
+ }
+
int count = 0;
while (count++ < UNMOUNT_CHECK_TIMES) {
int fd = TEMP_FAILURE_RETRY(open(entry->mnt_fsname, O_RDONLY | O_EXCL));
@@ -147,6 +158,11 @@ static void unmount_and_fsck(const struct mntent *entry) {
}
}
+ // 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 (!strcmp(entry->mnt_type, "f2fs")) {
const char *f2fs_argv[] = {