diff --git a/jni/daemon/daemon.c b/jni/daemon/daemon.c index f78481b83..c324a7cb2 100644 --- a/jni/daemon/daemon.c +++ b/jni/daemon/daemon.c @@ -140,8 +140,9 @@ void start_daemon() { xdup2(fd, STDERR_FILENO); close(fd); - if ((is_restart = check_data())) { - // Restart many stuffs + if ((is_restart = access(UNBLOCKFILE, F_OK) == 0)) { + // Restart stuffs if the daemon is restarted + exec_command_sync("logcat", "-b", "all", "-c", NULL); auto_start_magiskhide(); start_debug_log(); } @@ -174,6 +175,9 @@ void start_daemon() { // Unlock all blocks for rw unlock_blocks(); + // Notifiy init the daemon is started + close(open(UNBLOCKFILE, O_RDONLY)); + // Loop forever to listen for requests while(1) { int *client = xmalloc(sizeof(int)); diff --git a/jni/daemon/log_monitor.c b/jni/daemon/log_monitor.c index 7aff8f062..88f28152e 100644 --- a/jni/daemon/log_monitor.c +++ b/jni/daemon/log_monitor.c @@ -29,10 +29,8 @@ static void *logger_thread(void *args) { char line[4096]; while (1) { - // Clear buffer - exec_command_sync("logcat", "-b", "all", "-c", NULL); // Start logcat - log_pid = exec_command(0, &log_fd, NULL, "logcat", "-b", "events", "-b", "default", "-s", "am_proc_start", "Magisk", NULL); + log_pid = exec_command(0, &log_fd, NULL, "logcat", "-b", "all" , "-v", "threadtime", "-s", "am_proc_start", "Magisk", NULL); while (fdgets(line, sizeof(line), log_fd)) { for (int i = 0; i < (sizeof(logcat_events) / sizeof(int)); ++i) { if (logcat_events[i] > 0) { @@ -43,6 +41,8 @@ static void *logger_thread(void *args) { if (kill(log_pid, 0)) break; } + // Clear buffer if restart required + exec_command_sync("logcat", "-b", "all", "-c", NULL); } // Should never be here, but well... @@ -133,7 +133,7 @@ void start_debug_full_log() { #ifdef MAGISK_DEBUG // Log everything initially debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644); - debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", NULL); + debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "threadtime", NULL); close(debug_log_fd); #endif } diff --git a/scripts/init.magisk.rc b/scripts/init.magisk.rc index 8252b2e42..a588b0e54 100644 --- a/scripts/init.magisk.rc +++ b/scripts/init.magisk.rc @@ -3,13 +3,14 @@ on post-fs start logd start magisk_daemon - wait /dev/.magisk.unblock 1 - start magisk_pfs wait /dev/.magisk.unblock 5 + rm /dev/.magisk.unblock + start magisk_pfs + wait /dev/.magisk.unblock 10 on post-fs-data - rm /dev/.magisk.unblock load_persist_props + rm /dev/.magisk.unblock start magisk_pfsd wait /dev/.magisk.unblock 10