mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-18 12:54:15 +00:00
Micro optimizations
This commit is contained in:
@@ -506,21 +506,21 @@ static bool magisk_env() {
|
||||
strcmp(entry->d_name, ".core") == 0 ||
|
||||
strcmp(entry->d_name, "lost+found") == 0)
|
||||
continue;
|
||||
snprintf(buf, PATH_MAX, "%s/%s/remove", MOUNTPOINT, entry->d_name);
|
||||
if (access(buf, F_OK) == 0) {
|
||||
snprintf(buf, PATH_MAX, "%s/%s", MOUNTPOINT, entry->d_name);
|
||||
snprintf(buf, PATH_MAX, "%s/%s", MOUNTPOINT, entry->d_name);
|
||||
chdir(buf);
|
||||
if (access("remove", F_OK) == 0) {
|
||||
chdir("..");
|
||||
rm_rf(buf);
|
||||
continue;
|
||||
}
|
||||
snprintf(buf, PATH_MAX, "%s/%s/update", MOUNTPOINT, entry->d_name);
|
||||
unlink(buf);
|
||||
snprintf(buf, PATH_MAX, "%s/%s/disable", MOUNTPOINT, entry->d_name);
|
||||
if (access(buf, F_OK) == 0)
|
||||
unlink("update");
|
||||
if (access("disable", F_OK) == 0)
|
||||
continue;
|
||||
module_list.push_back(entry->d_name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
chdir("/");
|
||||
|
||||
return trim_img(MAINIMG, MOUNTPOINT, magiskloop) == 0;
|
||||
}
|
||||
|
@@ -132,6 +132,20 @@ static void main_daemon() {
|
||||
}
|
||||
}
|
||||
|
||||
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 connect_daemon() {
|
||||
struct sockaddr_un sun;
|
||||
socklen_t len = setup_sockaddr(&sun, MAIN_SOCKET);
|
||||
|
Reference in New Issue
Block a user