Update unmounting policies

This commit is contained in:
topjohnwu 2017-07-02 23:34:28 +08:00
parent 7eed9c4a6d
commit 9e22b80714

View File

@ -89,10 +89,11 @@ int hide_daemon() {
}
}
// First unmount the mirror, dummy skeletons, cache mounts, and /sbin links
// First unmount dummy skeletons, /sbin links, cache mounts, and mirrors
vec_for_each_r(&mount_list, line) {
if (strstr(line, "tmpfs /system") || strstr(line, "tmpfs /vendor") || strstr(line, "tmpfs /sbin")
|| (strstr(line, cache_block) && strstr(line, "/system/")) || strstr(line, MIRRDIR) ) {
|| (strstr(line, cache_block) && (strstr(line, " /system") || strstr(line, " /vendor")))
|| strstr(line, MIRRDIR)) {
sscanf(line, "%*s %512s", buffer);
lazy_unmount(buffer);
}
@ -105,9 +106,25 @@ int hide_daemon() {
vec_init(&mount_list);
file_to_vector(buffer, &mount_list);
// Unmount loop mounts
// Unmount loop mounts on /system, /vendor, /magisk
vec_for_each_r(&mount_list, line) {
if (strstr(line, "/dev/block/loop") || strstr(line, DUMMDIR)) {
if (strstr(line, "/dev/block/loop")
&& (strstr(line, " /system") || strstr(line, " /vendor") || strstr(line, " /magisk"))) {
sscanf(line, "%*s %512s", buffer);
lazy_unmount(buffer);
}
free(line);
}
vec_destroy(&mount_list);
// Re-read mount infos
snprintf(buffer, sizeof(buffer), "/proc/%d/mounts", pid);
vec_init(&mount_list);
file_to_vector(buffer, &mount_list);
// Unmount remaining mounts on dummy skeletons
vec_for_each_r(&mount_list, line) {
if (strstr(line, DUMMDIR)) {
sscanf(line, "%*s %512s", buffer);
lazy_unmount(buffer);
}