From b443b11df94f9e4248691267a5b29f8ad82adcb1 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:17:52 +0800 Subject: [PATCH] kernel: Refactoring the mount point unloading logic --- kernel/core_hook.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 0f5e27ed..a7013e26 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -1052,14 +1052,6 @@ void susfs_try_umount_all(uid_t uid) { ksu_try_umount("/data/adb/kpm", false, MNT_DETACH, uid); /* For both Legacy KSU and Magic Mount KSU */ ksu_try_umount("/debug_ramdisk", true, MNT_DETACH, uid); - ksu_try_umount("/sbin", false, MNT_DETACH, uid); - - // try umount hosts file - ksu_try_umount("/system/etc/hosts", false, MNT_DETACH, uid); - - // try umount lsposed dex2oat bins - ksu_try_umount("/apex/com.android.art/bin/dex2oat64", false, MNT_DETACH, uid); - ksu_try_umount("/apex/com.android.art/bin/dex2oat32", false, MNT_DETACH, uid); } #endif @@ -1140,18 +1132,24 @@ out_ksu_try_umount: // susfs come first, and lastly umount by ksu, make sure umount in reversed order susfs_try_umount_all(new_uid.val); #else - // fixme: use `collect_mounts` and `iterate_mount` to iterate all mountpoint and // filter the mountpoint whose target is `/data/adb` - ksu_try_umount("/system", true, 0); - ksu_try_umount("/system_ext", true, 0); - ksu_try_umount("/vendor", true, 0); - ksu_try_umount("/product", true, 0); - ksu_try_umount("/data/adb/modules", false, MNT_DETACH); - ksu_try_umount("/data/adb/kpm", false, MNT_DETACH); + try_umount("/system", true, 0); + try_umount("/vendor", true, 0); + try_umount("/product", true, 0); + try_umount("/system_ext", true, 0); + + // try umount modules path + try_umount("/data/adb/modules", false, MNT_DETACH); + + // try umount kpm path + try_umount("/data/adb/kpm", false, MNT_DETACH); // try umount ksu temp path - ksu_try_umount("/debug_ramdisk", false, MNT_DETACH); + try_umount("/debug_ramdisk", false, MNT_DETACH); + + // try umount ksu su path + try_umount("/sbin", false, MNT_DETACH); // try umount hosts file ksu_try_umount("/system/etc/hosts", false, MNT_DETACH);