Merge "init: umount dynamic partitions during shutdown" into main
diff --git a/init/reboot.cpp b/init/reboot.cpp
index 8b10974..d7ad861 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -394,7 +394,8 @@
}
}
-static void UmountDynamicPartitions(const std::vector<std::string>& dynamic_partitions) {
+static bool UmountDynamicPartitions(const std::vector<std::string>& dynamic_partitions) {
+ bool ret = true;
for (auto device : dynamic_partitions) {
// Cannot unmount /system
if (device == "/system") {
@@ -405,8 +406,10 @@
LOG(INFO) << "Umounted success: " << device;
} else {
PLOG(WARNING) << "Cannot umount: " << device;
+ ret = false;
}
}
+ return ret;
}
/* Try umounting all emulated file systems R/W block device cfile systems.
@@ -454,7 +457,17 @@
// still not doing fsck when all processes are killed.
//
if (ota_update_in_progress) {
- UmountDynamicPartitions(dynamic_partitions);
+ bool umount_dynamic_partitions = UmountDynamicPartitions(dynamic_partitions);
+ LOG(INFO) << "Sending SIGTERM to all process";
+ // Send SIGTERM to all processes except init
+ WriteStringToFile("e", PROC_SYSRQ);
+ // Wait for processes to terminate
+ std::this_thread::sleep_for(1s);
+ // Try one more attempt to umount other partitions which failed
+ // earlier
+ if (!umount_dynamic_partitions) {
+ UmountDynamicPartitions(dynamic_partitions);
+ }
return stat;
}
KillAllProcesses();