mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 13:20:16 +00:00
Add new util function
This commit is contained in:
@@ -44,6 +44,9 @@ void hide_daemon(int pid) {
|
||||
hide_unmount(pid);
|
||||
}
|
||||
|
||||
#define TMPFS_MNT(dir) (mentry->mnt_type == "tmpfs"sv && \
|
||||
strncmp(mentry->mnt_dir, "/" #dir, sizeof("/" #dir) - 1) == 0)
|
||||
|
||||
void hide_unmount(int pid) {
|
||||
if (switch_mnt_ns(pid))
|
||||
return;
|
||||
@@ -60,7 +63,7 @@ void hide_unmount(int pid) {
|
||||
chmod(SELINUX_POLICY, 0440);
|
||||
}
|
||||
|
||||
getprop([](const char *name, auto, auto) -> void {
|
||||
getprop([](const char *name, auto, auto) {
|
||||
if (strstr(name, "magisk"))
|
||||
deleteprop(name);
|
||||
}, nullptr, false);
|
||||
@@ -68,14 +71,9 @@ void hide_unmount(int pid) {
|
||||
vector<string> targets;
|
||||
|
||||
// Unmount dummy skeletons and /sbin links
|
||||
file_readline("/proc/self/mounts", [&](string_view s) -> bool {
|
||||
if (str_contains(s, "tmpfs /system/") || str_contains(s, "tmpfs /vendor/") ||
|
||||
str_contains(s, "tmpfs /sbin")) {
|
||||
char *path = (char *) s.data();
|
||||
// Skip first token
|
||||
strtok_r(nullptr, " ", &path);
|
||||
targets.emplace_back(strtok_r(nullptr, " ", &path));
|
||||
}
|
||||
parse_mnt("/proc/self/mounts", [&](mntent *mentry) {
|
||||
if (TMPFS_MNT(system) || TMPFS_MNT(vendor) || TMPFS_MNT(sbin))
|
||||
targets.emplace_back(mentry->mnt_dir);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -84,13 +82,9 @@ void hide_unmount(int pid) {
|
||||
targets.clear();
|
||||
|
||||
// Unmount all Magisk created mounts
|
||||
file_readline("/proc/self/mounts", [&](string_view s) -> bool {
|
||||
if (str_contains(s, BLOCKDIR)) {
|
||||
char *path = (char *) s.data();
|
||||
// Skip first token
|
||||
strtok_r(nullptr, " ", &path);
|
||||
targets.emplace_back(strtok_r(nullptr, " ", &path));
|
||||
}
|
||||
parse_mnt("/proc/self/mounts", [&](mntent *mentry) {
|
||||
if (strstr(mentry->mnt_fsname, BLOCKDIR))
|
||||
targets.emplace_back(mentry->mnt_dir);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user