Merge "InitFatalReboot: Panic the system if init_fatal_panic is "true""

This commit is contained in:
Woody Lin 2020-01-09 02:11:52 +00:00 committed by Gerrit Code Review
commit d377ad8b06

View file

@ -34,12 +34,16 @@ namespace android {
namespace init {
static std::string init_fatal_reboot_target = "bootloader";
static bool init_fatal_panic = false;
void SetFatalRebootTarget() {
std::string cmdline;
android::base::ReadFileToString("/proc/cmdline", &cmdline);
cmdline = android::base::Trim(cmdline);
const char kInitFatalPanicString[] = "androidboot.init_fatal_panic=true";
init_fatal_panic = cmdline.find(kInitFatalPanicString) != std::string::npos;
const char kRebootTargetString[] = "androidboot.init_fatal_reboot_target=";
auto start_pos = cmdline.find(kRebootTargetString);
if (start_pos == std::string::npos) {
@ -133,6 +137,9 @@ void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
for (size_t i = 0; i < backtrace->NumFrames(); i++) {
LOG(ERROR) << backtrace->FormatFrameData(i);
}
if (init_fatal_panic) {
_exit(signal_number);
}
RebootSystem(ANDROID_RB_RESTART2, init_fatal_reboot_target);
}