mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Use real system_root mirror
This commit is contained in:
parent
82ea9db9fd
commit
befe1a83b5
@ -31,8 +31,6 @@ static vector<string> module_list;
|
||||
static bool seperate_vendor;
|
||||
static bool no_secure_dir = false;
|
||||
|
||||
char *system_block, *vendor_block, *data_block;
|
||||
|
||||
static int bind_mount(const char *from, const char *to, bool log = true);
|
||||
extern void auto_start_magiskhide();
|
||||
|
||||
@ -303,6 +301,20 @@ static int bind_mount(const char *from, const char *to, bool log) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *system_block;
|
||||
char *vendor_block;
|
||||
char *data_block;
|
||||
static char *&system_root_block = system_block;
|
||||
|
||||
#define MIRRPNT(part) MIRRDIR "/" #part
|
||||
|
||||
#define mount_mirror(part, flag) \
|
||||
sscanf(line.data(), "%s %*s %s", buf, buf2); \
|
||||
part##_block = strdup(buf); \
|
||||
xmkdir(MIRRPNT(part), 0755); \
|
||||
xmount(part##_block, MIRRPNT(part), buf2, flag, nullptr); \
|
||||
VLOGI("mount", part##_block, MIRRPNT(part))
|
||||
|
||||
static bool magisk_env() {
|
||||
LOGI("* Initializing Magisk environment\n");
|
||||
|
||||
@ -336,8 +348,7 @@ static bool magisk_env() {
|
||||
symlink(MODULEMNT, MAGISKTMP "/img");
|
||||
|
||||
// Directories in tmpfs overlay
|
||||
xmkdirs(MIRRDIR "/system", 0755);
|
||||
xmkdir(MIRRDIR "/data", 0755);
|
||||
xmkdirs(MIRRPNT(system), 0755);
|
||||
xmkdir(BBPATH, 0755);
|
||||
xmkdir(MODULEMNT, 0755);
|
||||
|
||||
@ -351,27 +362,16 @@ static bool magisk_env() {
|
||||
bool system_as_root = false;
|
||||
file_readline("/proc/mounts", [&](string_view line) -> bool {
|
||||
if (str_contains(line, " /system_root ")) {
|
||||
bind_mount("/system_root/system", MIRRDIR "/system");
|
||||
sscanf(line.data(), "%s", buf);
|
||||
system_block = strdup(buf);
|
||||
mount_mirror(system_root, MS_RDONLY);
|
||||
bind_mount(MIRRPNT(system_root) "/system", MIRRPNT(system));
|
||||
system_as_root = true;
|
||||
} else if (!system_as_root && str_contains(line, " /system ")) {
|
||||
sscanf(line.data(), "%s %*s %s", buf, buf2);
|
||||
system_block = strdup(buf);
|
||||
xmount(system_block, MIRRDIR "/system", buf2, MS_RDONLY, nullptr);
|
||||
VLOGI("mount", system_block, MIRRDIR "/system");
|
||||
mount_mirror(system, MS_RDONLY);
|
||||
} else if (str_contains(line, " /vendor ")) {
|
||||
mount_mirror(vendor, MS_RDONLY);
|
||||
seperate_vendor = true;
|
||||
sscanf(line.data(), "%s %*s %s", buf, buf2);
|
||||
vendor_block = strdup(buf);
|
||||
xmkdir(MIRRDIR "/vendor", 0755);
|
||||
xmount(vendor_block, MIRRDIR "/vendor", buf2, MS_RDONLY, nullptr);
|
||||
VLOGI("mount", vendor_block, MIRRDIR "/vendor");
|
||||
} else if (str_contains(line, " /data ")) {
|
||||
sscanf(line.data(), "%s %*s %s", buf, buf2);
|
||||
data_block = strdup(buf);
|
||||
xmount(data_block, MIRRDIR "/data", buf2, 0, nullptr);
|
||||
VLOGI("mount", data_block, MIRRDIR "/data");
|
||||
mount_mirror(data, 0);
|
||||
} else if (SDK_INT >= 24 &&
|
||||
str_contains(line, " /proc ") && !str_contains(line, "hidepid=2")) {
|
||||
// Enforce hidepid
|
||||
|
@ -28,7 +28,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern char *system_block, *vendor_block, *data_block;
|
||||
extern char *system_block;
|
||||
extern char *vendor_block;
|
||||
extern char *data_block;
|
||||
|
||||
static int inotify_fd = -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user