mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 05:07:45 +02:00
Rewrite magiskhide
This commit is contained in:
@ -6,8 +6,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@ -15,7 +21,54 @@ FILE *xfopen(const char *pathname, const char *mode) {
|
||||
FILE *fp = fopen(pathname, mode);
|
||||
if (fp == NULL) {
|
||||
PLOGE("fopen");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
|
||||
int xopen(const char *pathname, int flags) {
|
||||
int fd = open(pathname, flags);
|
||||
if (fd < 0) {
|
||||
PLOGE("open");
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
ssize_t xwrite(int fd, const void *buf, size_t count) {
|
||||
if (count != write(fd, buf, count)) {
|
||||
PLOGE("write");
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// Read error other than EOF
|
||||
ssize_t xread(int fd, void *buf, size_t count) {
|
||||
int ret = read(fd, buf, count);
|
||||
if (ret < 0) {
|
||||
PLOGE("read");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Read exact same size as count
|
||||
ssize_t xxread(int fd, void *buf, size_t count) {
|
||||
if (count != read(fd, buf, count)) {
|
||||
PLOGE("read");
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int xpipe(int pipefd[2]) {
|
||||
if (pipe(pipefd) == -1) {
|
||||
PLOGE("pipe");
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xsetns(int fd, int nstype) {
|
||||
if (setns(fd, nstype) == -1) {
|
||||
PLOGE("setns");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user