Simplify hiding conditions
This commit is contained in:
parent
4d5841332a
commit
838f3cc01e
@ -63,7 +63,6 @@ static void lazy_unmount(const char* mountpoint) {
|
|||||||
|
|
||||||
static void hide_daemon(int pid) {
|
static void hide_daemon(int pid) {
|
||||||
LOGD("hide_daemon: start unmount for pid=[%d]\n", pid);
|
LOGD("hide_daemon: start unmount for pid=[%d]\n", pid);
|
||||||
strcpy(argv0, "hide_daemon");
|
|
||||||
|
|
||||||
char *line, buffer[PATH_MAX];
|
char *line, buffer[PATH_MAX];
|
||||||
struct vector mount_list;
|
struct vector mount_list;
|
||||||
@ -90,19 +89,9 @@ static void hide_daemon(int pid) {
|
|||||||
has_cache = 0;
|
has_cache = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmout cache mounts
|
// Unmount dummy skeletons and /sbin links
|
||||||
if (has_cache) {
|
|
||||||
vec_for_each(&mount_list, line) {
|
|
||||||
if (strstr(line, cache_block) && (strstr(line, " /system/") || strstr(line, " /vendor/"))) {
|
|
||||||
sscanf(line, "%*s %4096s", buffer);
|
|
||||||
lazy_unmount(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmount dummy skeletons, /sbin links
|
|
||||||
vec_for_each(&mount_list, line) {
|
vec_for_each(&mount_list, line) {
|
||||||
if (strstr(line, "tmpfs /system") || strstr(line, "tmpfs /vendor") || strstr(line, "tmpfs /sbin")) {
|
if (strstr(line, "tmpfs /system/") || strstr(line, "tmpfs /vendor/") || strstr(line, "tmpfs /sbin")) {
|
||||||
sscanf(line, "%*s %4096s", buffer);
|
sscanf(line, "%*s %4096s", buffer);
|
||||||
lazy_unmount(buffer);
|
lazy_unmount(buffer);
|
||||||
}
|
}
|
||||||
@ -115,20 +104,19 @@ static void hide_daemon(int pid) {
|
|||||||
vec_init(&mount_list);
|
vec_init(&mount_list);
|
||||||
file_to_vector(buffer, &mount_list);
|
file_to_vector(buffer, &mount_list);
|
||||||
|
|
||||||
// Unmount any loop mounts
|
// Unmount everything under /system, /vendor, and loop mounts
|
||||||
vec_for_each(&mount_list, line) {
|
vec_for_each(&mount_list, line) {
|
||||||
if (strstr(line, "/dev/block/loop")) {
|
if (strstr(line, "/dev/block/loop") || strstr(line, " /system/") || strstr(line, " /vendor/")) {
|
||||||
sscanf(line, "%*s %4096s", buffer);
|
sscanf(line, "%*s %4096s", buffer);
|
||||||
lazy_unmount(buffer);
|
lazy_unmount(buffer);
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
vec_destroy(&mount_list);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// Send resume signal
|
// Send resume signal
|
||||||
kill(pid, SIGCONT);
|
kill(pid, SIGCONT);
|
||||||
// Free up memory
|
|
||||||
vec_destroy(&mount_list);
|
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@ int check_data() {
|
|||||||
|
|
||||||
/* All the string should be freed manually!! */
|
/* All the string should be freed manually!! */
|
||||||
int file_to_vector(const char* filename, struct vector *v) {
|
int file_to_vector(const char* filename, struct vector *v) {
|
||||||
|
if (access(filename, R_OK) != 0)
|
||||||
|
return 1;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user