diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index c1e9d1f6a..67fb5e9d2 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -636,6 +636,22 @@ void unlock_blocks() { close(dev); } +static bool log_dump = false; +static void dump_logs() { + if (log_dump) + return; + int test = exec_command_sync("/system/bin/logcat", "-d", "-f", "/dev/null"); + chmod("/dev/null", 0666); + if (test != 0) + return; + rename(LOGFILE, LOGFILE ".bak"); + int fd = xopen(LOGFILE, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644); + exec_t exec { .fd = fd }; + exec_command(exec, "/system/bin/logcat", "-s", "Magisk"); + log_dump = true; + close(fd); +} + /**************** * Entry points * ****************/ @@ -658,6 +674,8 @@ void post_fs_data(int client) { if (!check_data()) unblock_boot_process(); + dump_logs(); + LOGI("** post-fs-data mode running\n"); // Unlock all blocks for rw @@ -781,6 +799,8 @@ void late_start(int client) { write_int(client, 0); close(client); + dump_logs(); + if (access(SECURE_DIR, F_OK) != 0) { // It's safe to create the folder at this point if the system didn't create it xmkdir(SECURE_DIR, 0700);