mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 11:20:25 +00:00
Maintain a list of pre-init mounts
Keep track of everything to unmount
This commit is contained in:
@@ -225,13 +225,14 @@ static void sbin_overlay(const raw_data &self, const raw_data &config) {
|
||||
xsymlink("./magiskinit", "/sbin/supolicy");
|
||||
}
|
||||
|
||||
#define ROOTOVL MAGISKTMP "/rootdir"
|
||||
#define ROOTMIR MIRRDIR "/system_root"
|
||||
#define ROOTBLK BLOCKDIR "/system_root"
|
||||
#define MONOPOLICY "/sepolicy"
|
||||
#define PATCHPOLICY "/sbin/.se"
|
||||
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
|
||||
|
||||
static string mount_list;
|
||||
|
||||
static void magic_mount(int dirfd, const string &path) {
|
||||
DIR *dir = xfdopendir(dirfd);
|
||||
for (dirent *entry; (entry = readdir(dir));) {
|
||||
@@ -248,6 +249,8 @@ static void magic_mount(int dirfd, const string &path) {
|
||||
string src = ROOTOVL + dest;
|
||||
LOGD("Mount [%s] -> [%s]\n", src.data(), dest.data());
|
||||
xmount(src.data(), dest.data(), nullptr, MS_BIND, nullptr);
|
||||
mount_list += dest;
|
||||
mount_list += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,6 +379,9 @@ void SARCommon::patch_rootdir() {
|
||||
src = xopen(ROOTOVL, O_RDONLY | O_CLOEXEC);
|
||||
magic_mount(src, "");
|
||||
close(src);
|
||||
dest = xopen(ROOTMNT, O_WRONLY | O_CREAT | O_CLOEXEC);
|
||||
write(dest, mount_list.data(), mount_list.length());
|
||||
close(dest);
|
||||
}
|
||||
|
||||
#define FSR "/first_stage_ramdisk"
|
||||
|
Reference in New Issue
Block a user