mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 14:27:39 +00:00
Skip loading Magisk when detecting DSU
Fix #4402 Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
parent
3d88dd3123
commit
62ef8ade8f
@ -38,6 +38,7 @@ extern std::vector<std::string> mount_list;
|
|||||||
|
|
||||||
bool unxz(int fd, const uint8_t *buf, size_t size);
|
bool unxz(int fd, const uint8_t *buf, size_t size);
|
||||||
void load_kernel_info(BootConfig *config);
|
void load_kernel_info(BootConfig *config);
|
||||||
|
bool is_dsu();
|
||||||
bool check_two_stage();
|
bool check_two_stage();
|
||||||
void setup_klog();
|
void setup_klog();
|
||||||
const char *backup_init();
|
const char *backup_init();
|
||||||
|
@ -93,7 +93,7 @@ static int64_t setup_block(bool write_block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool is_lnk(const char *name) {
|
static bool is_lnk(const char *name) {
|
||||||
struct stat st;
|
struct stat st{};
|
||||||
if (lstat(name, &st))
|
if (lstat(name, &st))
|
||||||
return false;
|
return false;
|
||||||
return S_ISLNK(st.st_mode);
|
return S_ISLNK(st.st_mode);
|
||||||
@ -196,6 +196,27 @@ static void switch_root(const string &path) {
|
|||||||
frm_rf(root);
|
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) {
|
void MagiskInit::mount_rules_dir(const char *dev_base, const char *mnt_base) {
|
||||||
char path[128];
|
char path[128];
|
||||||
xrealpath(dev_base, blk_info.block_dev);
|
xrealpath(dev_base, blk_info.block_dev);
|
||||||
|
@ -63,6 +63,12 @@ static bool read_fstab_file(const char *fstab_file, vector<fstab_entry> &fstab)
|
|||||||
extern uint32_t patch_verity(void *buf, uint32_t size);
|
extern uint32_t patch_verity(void *buf, uint32_t size);
|
||||||
|
|
||||||
void FirstStageInit::prepare() {
|
void FirstStageInit::prepare() {
|
||||||
|
if (is_dsu()) {
|
||||||
|
rename(backup_init(), "/init");
|
||||||
|
LOGI("Skip loading Magisk because of DSU\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
run_finally finally([]{ chdir("/"); });
|
run_finally finally([]{ chdir("/"); });
|
||||||
if (config->force_normal_boot) {
|
if (config->force_normal_boot) {
|
||||||
xmkdirs(FSR "/system/bin", 0755);
|
xmkdirs(FSR "/system/bin", 0755);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user