mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-03 04:41:53 +00:00
Micro optimizations
This commit is contained in:
@@ -94,7 +94,6 @@ int is_num(const char *s);
|
||||
int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]);
|
||||
int exec_command(int err, int *fd, void (*cb)(void), const char *argv0, ...);
|
||||
int exec_command_sync(const char *argv0, ...);
|
||||
int switch_mnt_ns(int pid);
|
||||
int fork_dont_care();
|
||||
void gen_rand_str(char *buf, int len);
|
||||
int strend(const char *s1, const char *s2);
|
||||
|
||||
@@ -67,20 +67,6 @@ ssize_t fdgets(char *buf, const size_t size, int fd) {
|
||||
return len;
|
||||
}
|
||||
|
||||
int switch_mnt_ns(int pid) {
|
||||
char mnt[32];
|
||||
snprintf(mnt, sizeof(mnt), "/proc/%d/ns/mnt", pid);
|
||||
if(access(mnt, R_OK) == -1) return 1; // Maybe process died..
|
||||
|
||||
int fd, ret;
|
||||
fd = xopen(mnt, O_RDONLY);
|
||||
if (fd < 0) return 1;
|
||||
// Switch to its namespace
|
||||
ret = xsetns(fd, 0);
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fork_dont_care() {
|
||||
int pid = xfork();
|
||||
if (pid) {
|
||||
|
||||
Reference in New Issue
Block a user