mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Restructure the native module
Consolidate all code into the src folder
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <magisk.hpp>
|
||||
#include <base.hpp>
|
||||
|
||||
#include "deny.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void lazy_unmount(const char* mountpoint) {
|
||||
if (umount2(mountpoint, MNT_DETACH) != -1)
|
||||
LOGD("denylist: Unmounted (%s)\n", mountpoint);
|
||||
}
|
||||
|
||||
#define TMPFS_MNT(dir) (mentry->mnt_type == "tmpfs"sv && str_starts(mentry->mnt_dir, "/" #dir))
|
||||
|
||||
void revert_unmount() {
|
||||
vector<string> targets;
|
||||
|
||||
// Unmount dummy skeletons and MAGISKTMP
|
||||
targets.push_back(MAGISKTMP);
|
||||
parse_mnt("/proc/self/mounts", [&](mntent *mentry) {
|
||||
if (TMPFS_MNT(system) || TMPFS_MNT(vendor) || TMPFS_MNT(product) || TMPFS_MNT(system_ext))
|
||||
targets.emplace_back(mentry->mnt_dir);
|
||||
return true;
|
||||
});
|
||||
|
||||
for (auto &s : reversed(targets))
|
||||
lazy_unmount(s.data());
|
||||
targets.clear();
|
||||
|
||||
// Unmount all Magisk created mounts
|
||||
parse_mnt("/proc/self/mounts", [&](mntent *mentry) {
|
||||
if (str_contains(mentry->mnt_fsname, BLOCKDIR))
|
||||
targets.emplace_back(mentry->mnt_dir);
|
||||
return true;
|
||||
});
|
||||
|
||||
for (auto &s : reversed(targets))
|
||||
lazy_unmount(s.data());
|
||||
}
|
||||
Reference in New Issue
Block a user