mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Skip loading Magisk when detecting DSU
Fix #4402 Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
@ -93,7 +93,7 @@ static int64_t setup_block(bool write_block) {
|
||||
}
|
||||
|
||||
static bool is_lnk(const char *name) {
|
||||
struct stat st;
|
||||
struct stat st{};
|
||||
if (lstat(name, &st))
|
||||
return false;
|
||||
return S_ISLNK(st.st_mode);
|
||||
@ -196,6 +196,27 @@ static void switch_root(const string &path) {
|
||||
frm_rf(root);
|
||||
}
|
||||
|
||||
bool is_dsu() {
|
||||
strcpy(blk_info.partname, "metadata");
|
||||
xmkdir("/metadata", 0755);
|
||||
if (setup_block(true) < 0 ||
|
||||
xmount(blk_info.block_dev, "/metadata", "ext4", MS_RDONLY, nullptr)) {
|
||||
PLOGE("Failed to mount /metadata");
|
||||
return false;
|
||||
} else {
|
||||
run_finally f([]{ xumount2("/metadata", MNT_DETACH); });
|
||||
constexpr auto dsu_status = "/metadata/gsi/dsu/install_status";
|
||||
if (xaccess(dsu_status, F_OK) == 0) {
|
||||
char status[PATH_MAX] = {0};
|
||||
auto fp = xopen_file(dsu_status, "r");
|
||||
fgets(status, sizeof(status), fp.get());
|
||||
if (status == "ok"sv || status == "0"sv)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MagiskInit::mount_rules_dir(const char *dev_base, const char *mnt_base) {
|
||||
char path[128];
|
||||
xrealpath(dev_base, blk_info.block_dev);
|
||||
|
Reference in New Issue
Block a user