Maintain a list of pre-init mounts
Keep track of everything to unmount
This commit is contained in:
parent
aa47966347
commit
736729f5ef
@ -109,10 +109,12 @@ static void main_daemon() {
|
|||||||
restore_rootcon();
|
restore_rootcon();
|
||||||
|
|
||||||
// Unmount pre-init patches
|
// Unmount pre-init patches
|
||||||
umount2("/init", MNT_DETACH);
|
if (access(ROOTMNT, F_OK) == 0) {
|
||||||
umount2("/init.rc", MNT_DETACH);
|
file_readline(ROOTMNT, [](auto line) -> bool {
|
||||||
umount2("/system/lib/libselinux.so", MNT_DETACH);
|
umount2(line.data(), MNT_DETACH);
|
||||||
umount2("/system/lib64/libselinux.so", MNT_DETACH);
|
return true;
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
int fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
|
int fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
|
||||||
xdup2(fd, STDOUT_FILENO);
|
xdup2(fd, STDOUT_FILENO);
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#define BLOCKDIR MAGISKTMP "/block"
|
#define BLOCKDIR MAGISKTMP "/block"
|
||||||
#define BBPATH MAGISKTMP "/busybox"
|
#define BBPATH MAGISKTMP "/busybox"
|
||||||
#define MODULEMNT MAGISKTMP "/modules"
|
#define MODULEMNT MAGISKTMP "/modules"
|
||||||
|
#define ROOTOVL MAGISKTMP "/rootdir"
|
||||||
|
#define ROOTMNT ROOTOVL "/.mount_list"
|
||||||
#define SECURE_DIR "/data/adb"
|
#define SECURE_DIR "/data/adb"
|
||||||
#define MODULEROOT SECURE_DIR "/modules"
|
#define MODULEROOT SECURE_DIR "/modules"
|
||||||
#define MODULEUPGRADE SECURE_DIR "/modules_update"
|
#define MODULEUPGRADE SECURE_DIR "/modules_update"
|
||||||
|
@ -225,13 +225,14 @@ static void sbin_overlay(const raw_data &self, const raw_data &config) {
|
|||||||
xsymlink("./magiskinit", "/sbin/supolicy");
|
xsymlink("./magiskinit", "/sbin/supolicy");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROOTOVL MAGISKTMP "/rootdir"
|
|
||||||
#define ROOTMIR MIRRDIR "/system_root"
|
#define ROOTMIR MIRRDIR "/system_root"
|
||||||
#define ROOTBLK BLOCKDIR "/system_root"
|
#define ROOTBLK BLOCKDIR "/system_root"
|
||||||
#define MONOPOLICY "/sepolicy"
|
#define MONOPOLICY "/sepolicy"
|
||||||
#define PATCHPOLICY "/sbin/.se"
|
#define PATCHPOLICY "/sbin/.se"
|
||||||
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
|
#define LIBSELINUX "/system/" LIBNAME "/libselinux.so"
|
||||||
|
|
||||||
|
static string mount_list;
|
||||||
|
|
||||||
static void magic_mount(int dirfd, const string &path) {
|
static void magic_mount(int dirfd, const string &path) {
|
||||||
DIR *dir = xfdopendir(dirfd);
|
DIR *dir = xfdopendir(dirfd);
|
||||||
for (dirent *entry; (entry = readdir(dir));) {
|
for (dirent *entry; (entry = readdir(dir));) {
|
||||||
@ -248,6 +249,8 @@ static void magic_mount(int dirfd, const string &path) {
|
|||||||
string src = ROOTOVL + dest;
|
string src = ROOTOVL + dest;
|
||||||
LOGD("Mount [%s] -> [%s]\n", src.data(), dest.data());
|
LOGD("Mount [%s] -> [%s]\n", src.data(), dest.data());
|
||||||
xmount(src.data(), dest.data(), nullptr, MS_BIND, nullptr);
|
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);
|
src = xopen(ROOTOVL, O_RDONLY | O_CLOEXEC);
|
||||||
magic_mount(src, "");
|
magic_mount(src, "");
|
||||||
close(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"
|
#define FSR "/first_stage_ramdisk"
|
||||||
|
Loading…
Reference in New Issue
Block a user