mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-08 03:11:34 -08:00
More Rust
This commit is contained in:
@@ -79,38 +79,6 @@ int xpipe2(int pipefd[2], int flags) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xsetns(int fd, int nstype) {
|
||||
int ret = setns(fd, nstype);
|
||||
if (ret < 0) {
|
||||
PLOGE("setns");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xunshare(int flags) {
|
||||
int ret = unshare(flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("unshare");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
DIR *xopendir(const char *name) {
|
||||
DIR *d = opendir(name);
|
||||
if (d == nullptr) {
|
||||
PLOGE("opendir: %s", name);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
DIR *xfdopendir(int fd) {
|
||||
DIR *d = fdopendir(fd);
|
||||
if (d == nullptr) {
|
||||
PLOGE("fdopendir");
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
struct dirent *xreaddir(DIR *dirp) {
|
||||
errno = 0;
|
||||
for (dirent *e;;) {
|
||||
@@ -127,62 +95,6 @@ struct dirent *xreaddir(DIR *dirp) {
|
||||
}
|
||||
}
|
||||
|
||||
pid_t xsetsid() {
|
||||
pid_t pid = setsid();
|
||||
if (pid < 0) {
|
||||
PLOGE("setsid");
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
int xsocket(int domain, int type, int protocol) {
|
||||
int fd = socket(domain, type, protocol);
|
||||
if (fd < 0) {
|
||||
PLOGE("socket");
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int xbind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
|
||||
int ret = bind(sockfd, addr, addrlen);
|
||||
if (ret < 0) {
|
||||
PLOGE("bind");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xlisten(int sockfd, int backlog) {
|
||||
int ret = listen(sockfd, backlog);
|
||||
if (ret < 0) {
|
||||
PLOGE("listen");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xaccept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
|
||||
int fd = accept4(sockfd, addr, addrlen, flags);
|
||||
if (fd < 0) {
|
||||
PLOGE("accept4");
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
ssize_t xsendmsg(int sockfd, const struct msghdr *msg, int flags) {
|
||||
int sent = sendmsg(sockfd, msg, flags);
|
||||
if (sent < 0) {
|
||||
PLOGE("sendmsg");
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
|
||||
ssize_t xrecvmsg(int sockfd, struct msghdr *msg, int flags) {
|
||||
int rec = recvmsg(sockfd, msg, flags);
|
||||
if (rec < 0) {
|
||||
PLOGE("recvmsg");
|
||||
}
|
||||
return rec;
|
||||
}
|
||||
|
||||
int xpthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg) {
|
||||
errno = pthread_create(thread, attr, start_routine, arg);
|
||||
@@ -192,70 +104,6 @@ int xpthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return errno;
|
||||
}
|
||||
|
||||
int xaccess(const char *path, int mode) {
|
||||
int ret = access(path, mode);
|
||||
if (ret < 0) {
|
||||
PLOGE("access %s", path);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xstat(const char *pathname, struct stat *buf) {
|
||||
int ret = stat(pathname, buf);
|
||||
if (ret < 0) {
|
||||
PLOGE("stat %s", pathname);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xlstat(const char *pathname, struct stat *buf) {
|
||||
int ret = lstat(pathname, buf);
|
||||
if (ret < 0) {
|
||||
PLOGE("lstat %s", pathname);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xfstat(int fd, struct stat *buf) {
|
||||
int ret = fstat(fd, buf);
|
||||
if (ret < 0) {
|
||||
PLOGE("fstat %d", fd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xfstatat(int dirfd, const char *pathname, struct stat *buf, int flags) {
|
||||
int ret = fstatat(dirfd, pathname, buf, flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("fstatat %s", pathname);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xdup(int fd) {
|
||||
int ret = dup(fd);
|
||||
if (ret < 0) {
|
||||
PLOGE("dup");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xdup2(int oldfd, int newfd) {
|
||||
int ret = dup2(oldfd, newfd);
|
||||
if (ret < 0) {
|
||||
PLOGE("dup2");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xdup3(int oldfd, int newfd, int flags) {
|
||||
int ret = dup3(oldfd, newfd, flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("dup3");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t xreadlink(const char *pathname, char *buf, size_t bufsiz) {
|
||||
ssize_t ret = readlink(pathname, buf, bufsiz);
|
||||
if (ret < 0) {
|
||||
@@ -301,72 +149,6 @@ int xfaccessat(int dirfd, const char *pathname) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xsymlink(const char *target, const char *linkpath) {
|
||||
int ret = symlink(target, linkpath);
|
||||
if (ret < 0) {
|
||||
PLOGE("symlink %s->%s", target, linkpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xsymlinkat(const char *target, int newdirfd, const char *linkpath) {
|
||||
int ret = symlinkat(target, newdirfd, linkpath);
|
||||
if (ret < 0) {
|
||||
PLOGE("symlinkat %s->%s", target, linkpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xlinkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) {
|
||||
int ret = linkat(olddirfd, oldpath, newdirfd, newpath, flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("linkat %s->%s", oldpath, newpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data) {
|
||||
int ret = mount(source, target, filesystemtype, mountflags, data);
|
||||
if (ret < 0) {
|
||||
PLOGE("mount %s->%s", source, target);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xumount(const char *target) {
|
||||
int ret = umount(target);
|
||||
if (ret < 0) {
|
||||
PLOGE("umount %s", target);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xumount2(const char *target, int flags) {
|
||||
int ret = umount2(target, flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("umount2 %s", target);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xrename(const char *oldpath, const char *newpath) {
|
||||
int ret = rename(oldpath, newpath);
|
||||
if (ret < 0) {
|
||||
PLOGE("rename %s->%s", oldpath, newpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmkdir(const char *pathname, mode_t mode) {
|
||||
int ret = mkdir(pathname, mode);
|
||||
if (ret < 0 && errno != EEXIST) {
|
||||
PLOGE("mkdir %s %u", pathname, mode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmkdirs(const char *pathname, mode_t mode) {
|
||||
int ret = mkdirs(pathname, mode);
|
||||
if (ret < 0) {
|
||||
@@ -375,14 +157,6 @@ int xmkdirs(const char *pathname, mode_t mode) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmkdirat(int dirfd, const char *pathname, mode_t mode) {
|
||||
int ret = mkdirat(dirfd, pathname, mode);
|
||||
if (ret < 0 && errno != EEXIST) {
|
||||
PLOGE("mkdirat %s %u", pathname, mode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *xmmap(void *addr, size_t length, int prot, int flags,
|
||||
int fd, off_t offset) {
|
||||
void *ret = mmap(addr, length, prot, flags, fd, offset);
|
||||
@@ -401,14 +175,6 @@ ssize_t xsendfile(int out_fd, int in_fd, off_t *offset, size_t count) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
pid_t xfork() {
|
||||
int ret = fork();
|
||||
if (ret < 0) {
|
||||
PLOGE("fork");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xpoll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
||||
int ret = poll(fds, nfds, timeout);
|
||||
if (ret < 0) {
|
||||
@@ -417,14 +183,6 @@ int xpoll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xinotify_init1(int flags) {
|
||||
int ret = inotify_init1(flags);
|
||||
if (ret < 0) {
|
||||
PLOGE("inotify_init1");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *xrealpath(const char *path, char *resolved_path) {
|
||||
char buf[PATH_MAX];
|
||||
char *ret = realpath(path, buf);
|
||||
@@ -435,11 +193,3 @@ char *xrealpath(const char *path, char *resolved_path) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmknod(const char *pathname, mode_t mode, dev_t dev) {
|
||||
int ret = mknod(pathname, mode, dev);
|
||||
if (ret < 0) {
|
||||
PLOGE("mknod");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user