mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-03-28 03:22:15 +00:00
parent
1a16004b20
commit
b4ae3493a6
@ -116,13 +116,17 @@ static void mount_mirrors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string find_preinit_device() {
|
string find_preinit_device() {
|
||||||
enum {
|
enum part_t {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
PERSIST,
|
PERSIST,
|
||||||
METADATA,
|
METADATA,
|
||||||
CACHE,
|
CACHE,
|
||||||
DATA,
|
DATA,
|
||||||
} matched = UNKNOWN;
|
};
|
||||||
|
|
||||||
|
part_t ext4_type = UNKNOWN;
|
||||||
|
part_t f2fs_type = UNKNOWN;
|
||||||
|
|
||||||
bool encrypted = getprop("ro.crypto.state") == "encrypted";
|
bool encrypted = getprop("ro.crypto.state") == "encrypted";
|
||||||
bool mount = getuid() == 0 && getenv("MAGISKTMP");
|
bool mount = getuid() == 0 && getenv("MAGISKTMP");
|
||||||
bool make_dev = mount && getenv("MAKEDEV");
|
bool make_dev = mount && getenv("MAKEDEV");
|
||||||
@ -136,6 +140,9 @@ string find_preinit_device() {
|
|||||||
return basename(info.source.data());
|
return basename(info.source.data());
|
||||||
if (info.root != "/" || info.source[0] != '/' || info.source.find("/dm-") != string::npos)
|
if (info.root != "/" || info.source[0] != '/' || info.source.find("/dm-") != string::npos)
|
||||||
continue;
|
continue;
|
||||||
|
// Skip all non ext4 partitions once we found a matching ext4 partition
|
||||||
|
if (ext4_type != UNKNOWN && info.type != "ext4")
|
||||||
|
continue;
|
||||||
if (info.type != "ext4" && info.type != "f2fs")
|
if (info.type != "ext4" && info.type != "f2fs")
|
||||||
continue;
|
continue;
|
||||||
auto flags = split_view(info.fs_option, ",");
|
auto flags = split_view(info.fs_option, ",");
|
||||||
@ -148,6 +155,7 @@ string find_preinit_device() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
part_t &matched = (info.type == "f2fs") ? f2fs_type : ext4_type;
|
||||||
switch (matched) {
|
switch (matched) {
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
if (info.target == "/persist" || info.target == "/mnt/vendor/persist") {
|
if (info.target == "/persist" || info.target == "/mnt/vendor/persist") {
|
||||||
@ -175,7 +183,7 @@ string find_preinit_device() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case DATA:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +192,15 @@ string find_preinit_device() {
|
|||||||
preinit_dev = info.device;
|
preinit_dev = info.device;
|
||||||
}
|
}
|
||||||
preinit_source = info.source;
|
preinit_source = info.source;
|
||||||
|
|
||||||
|
// Cannot find any better partition, stop finding
|
||||||
|
if (ext4_type == DATA)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preinit_source.empty())
|
||||||
|
return "";
|
||||||
|
|
||||||
if (!preinit_dir.empty()) {
|
if (!preinit_dir.empty()) {
|
||||||
auto mirror_dir = string(getenv("MAGISKTMP")) + "/" PREINITMIRR;
|
auto mirror_dir = string(getenv("MAGISKTMP")) + "/" PREINITMIRR;
|
||||||
mkdirs(preinit_dir.data(), 0700);
|
mkdirs(preinit_dir.data(), 0700);
|
||||||
@ -196,7 +211,7 @@ string find_preinit_device() {
|
|||||||
xmknod(dev_path.data(), S_IFBLK | 0600, preinit_dev);
|
xmknod(dev_path.data(), S_IFBLK | 0600, preinit_dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return preinit_source.empty() ? "" : basename(preinit_source.data());
|
return basename(preinit_source.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool magisk_env() {
|
static bool magisk_env() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user