Fix kmsg logging in magiskinit

This commit is contained in:
topjohnwu
2019-11-18 17:18:56 -05:00
parent da159e4655
commit d3b7b41927
3 changed files with 33 additions and 39 deletions
-18
View File
@@ -8,7 +8,6 @@
#include <utils.h>
#include "init.h"
#include "flags.h"
#include "magiskrc.h"
#ifdef USE_64BIT
@@ -466,23 +465,6 @@ void AFirstStageInit::prepare() {
rename("/.backup/init", "/init");
}
#ifdef MAGISK_DEBUG
static FILE *kmsg;
static int vprintk(const char *fmt, va_list ap) {
fprintf(kmsg, "magiskinit: ");
return vfprintf(kmsg, fmt, ap);
}
static void setup_klog() {
int fd = xopen("/proc/kmsg", O_WRONLY | O_CLOEXEC);
kmsg = fdopen(fd, "w");
setbuf(kmsg, nullptr);
log_cb.d = log_cb.i = log_cb.w = log_cb.e = vprintk;
log_cb.ex = nop_ex;
}
#else
#define setup_klog(...)
#endif
int magisk_proxy_main(int argc, char *argv[]) {
setup_klog();