mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-22 09:48:30 +00:00
parent
8cc5f096a2
commit
476b61c4c9
@ -43,7 +43,7 @@ static void parse_device(devinfo *dev, const char *uevent) {
|
|||||||
static void collect_devices() {
|
static void collect_devices() {
|
||||||
char path[128];
|
char path[128];
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
devinfo dev;
|
devinfo dev{};
|
||||||
DIR *dir = xopendir("/sys/dev/block");
|
DIR *dir = xopendir("/sys/dev/block");
|
||||||
if (dir == nullptr)
|
if (dir == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -57,13 +57,14 @@ static void collect_devices() {
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static dev_t setup_block(char *block_dev = nullptr) {
|
static int64_t setup_block(char *block_dev = nullptr) {
|
||||||
if (dev_list.empty())
|
if (dev_list.empty())
|
||||||
collect_devices();
|
collect_devices();
|
||||||
for (;;) {
|
xmkdir("/dev", 0755);
|
||||||
|
|
||||||
|
for (int tries = 0; tries < 3; ++tries) {
|
||||||
for (auto &dev : dev_list) {
|
for (auto &dev : dev_list) {
|
||||||
if (strcasecmp(dev.partname, partname) == 0) {
|
if (strcasecmp(dev.partname, partname) == 0) {
|
||||||
xmkdir("/dev", 0755);
|
|
||||||
if (block_dev) {
|
if (block_dev) {
|
||||||
sprintf(block_dev, "/dev/block/%s", dev.devname);
|
sprintf(block_dev, "/dev/block/%s", dev.devname);
|
||||||
xmkdir("/dev/block", 0755);
|
xmkdir("/dev/block", 0755);
|
||||||
@ -79,6 +80,9 @@ static dev_t setup_block(char *block_dev = nullptr) {
|
|||||||
dev_list.clear();
|
dev_list.clear();
|
||||||
collect_devices();
|
collect_devices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The requested partname does not exist
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_lnk(const char *name) {
|
static bool is_lnk(const char *name) {
|
||||||
@ -205,7 +209,18 @@ void SARInit::early_mount() {
|
|||||||
|
|
||||||
LOGD("Early mount system_root\n");
|
LOGD("Early mount system_root\n");
|
||||||
sprintf(partname, "system%s", cmd->slot);
|
sprintf(partname, "system%s", cmd->slot);
|
||||||
system_dev = setup_block();
|
auto dev = setup_block();
|
||||||
|
if (dev < 0) {
|
||||||
|
// Try NVIDIA naming scheme
|
||||||
|
strcpy(partname, "APP");
|
||||||
|
dev = setup_block();
|
||||||
|
if (dev < 0) {
|
||||||
|
// We don't really know what to do at this point...
|
||||||
|
LOGE("Cannot find root partition, abort\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system_dev = dev;
|
||||||
xmkdir("/system_root", 0755);
|
xmkdir("/system_root", 0755);
|
||||||
if (xmount("/dev/root", "/system_root", "ext4", MS_RDONLY, nullptr))
|
if (xmount("/dev/root", "/system_root", "ext4", MS_RDONLY, nullptr))
|
||||||
xmount("/dev/root", "/system_root", "erofs", MS_RDONLY, nullptr);
|
xmount("/dev/root", "/system_root", "erofs", MS_RDONLY, nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user