Commit a6f81c66 authored by topjohnwu's avatar topjohnwu

Bypass stdio

parent 1ff45ac5
...@@ -310,7 +310,7 @@ static void logfile_writer(int sockfd) { ...@@ -310,7 +310,7 @@ static void logfile_writer(int sockfd) {
char *log_buf; char *log_buf;
size_t buf_len; size_t buf_len;
sFILE log_fp = make_stream_fp<byte_stream>(log_buf, buf_len); stream *log_strm = new byte_stream(log_buf, buf_len);
msghdr msg{}; msghdr msg{};
iovec iov{}; iovec iov{};
...@@ -342,12 +342,9 @@ static void logfile_writer(int sockfd) { ...@@ -342,12 +342,9 @@ static void logfile_writer(int sockfd) {
return; return;
if (log_buf) if (log_buf)
write(fd, log_buf, buf_len); write(fd, log_buf, buf_len);
if (FILE *fp = fdopen(fd, "a")) {
setbuf(fp, nullptr); delete log_strm;
log_fp = make_file(fp); log_strm = new fd_stream(fd);
} else {
return;
}
continue; continue;
} }
...@@ -382,12 +379,12 @@ static void logfile_writer(int sockfd) { ...@@ -382,12 +379,12 @@ static void logfile_writer(int sockfd) {
iov.iov_len = meta.len; iov.iov_len = meta.len;
if (recvmsg(sockfd, &msg, 0) <= 0) if (recvmsg(sockfd, &msg, 0) <= 0)
return; return;
fwrite(buf, off + meta.len, 1, log_fp.get()); log_strm->write(buf, off + meta.len);
} }
} }
static int magisk_log(int prio, const char *fmt, va_list ap) { static int magisk_log(int prio, const char *fmt, va_list ap) {
char buf[4096]; char buf[4000];
int len = vsnprintf(buf, sizeof(buf), fmt, ap) + 1; int len = vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
if (log_sockfd >= 0) { if (log_sockfd >= 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment