Minor optimizations
This commit is contained in:
parent
886286a819
commit
b436bce565
@ -581,6 +581,12 @@ initialize:
|
|||||||
close(sbin);
|
close(sbin);
|
||||||
close(root);
|
close(root);
|
||||||
|
|
||||||
|
// Create directories in tmpfs overlay
|
||||||
|
xmkdirs(MIRRDIR "/system", 0755);
|
||||||
|
xmkdir(MIRRDIR "/bin", 0755);
|
||||||
|
xmkdir(BBPATH, 0755);
|
||||||
|
xmkdir(MOUNTPOINT, 0755);
|
||||||
|
|
||||||
LOGI("* Mounting mirrors");
|
LOGI("* Mounting mirrors");
|
||||||
struct vector mounts;
|
struct vector mounts;
|
||||||
vec_init(&mounts);
|
vec_init(&mounts);
|
||||||
@ -590,16 +596,10 @@ initialize:
|
|||||||
// Check whether skip_initramfs device
|
// Check whether skip_initramfs device
|
||||||
vec_for_each(&mounts, line) {
|
vec_for_each(&mounts, line) {
|
||||||
if (strstr(line, " /system_root ")) {
|
if (strstr(line, " /system_root ")) {
|
||||||
xmkdirs(MIRRDIR "/system", 0755);
|
|
||||||
bind_mount("/system_root/system", MIRRDIR "/system");
|
bind_mount("/system_root/system", MIRRDIR "/system");
|
||||||
skip_initramfs = 1;
|
skip_initramfs = 1;
|
||||||
break;
|
} else if (!skip_initramfs && strstr(line, " /system ")) {
|
||||||
}
|
|
||||||
}
|
|
||||||
vec_for_each(&mounts, line) {
|
|
||||||
if (!skip_initramfs && strstr(line, " /system ")) {
|
|
||||||
sscanf(line, "%s", buf);
|
sscanf(line, "%s", buf);
|
||||||
xmkdirs(MIRRDIR "/system", 0755);
|
|
||||||
xmount(buf, MIRRDIR "/system", "ext4", MS_RDONLY, NULL);
|
xmount(buf, MIRRDIR "/system", "ext4", MS_RDONLY, NULL);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGI("mount: %s <- %s\n", MIRRDIR "/system", buf);
|
LOGI("mount: %s <- %s\n", MIRRDIR "/system", buf);
|
||||||
@ -609,7 +609,7 @@ initialize:
|
|||||||
} else if (strstr(line, " /vendor ")) {
|
} else if (strstr(line, " /vendor ")) {
|
||||||
seperate_vendor = 1;
|
seperate_vendor = 1;
|
||||||
sscanf(line, "%s", buf);
|
sscanf(line, "%s", buf);
|
||||||
xmkdirs(MIRRDIR "/vendor", 0755);
|
xmkdir(MIRRDIR "/vendor", 0755);
|
||||||
xmount(buf, MIRRDIR "/vendor", "ext4", MS_RDONLY, NULL);
|
xmount(buf, MIRRDIR "/vendor", "ext4", MS_RDONLY, NULL);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGI("mount: %s <- %s\n", MIRRDIR "/vendor", buf);
|
LOGI("mount: %s <- %s\n", MIRRDIR "/vendor", buf);
|
||||||
@ -628,11 +628,8 @@ initialize:
|
|||||||
LOGI("link: %s\n", MIRRDIR "/vendor");
|
LOGI("link: %s\n", MIRRDIR "/vendor");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
xmkdirs(MIRRDIR "/bin", 0755);
|
|
||||||
xmkdirs(DATABIN, 0755);
|
xmkdirs(DATABIN, 0755);
|
||||||
bind_mount(DATABIN, MIRRDIR "/bin");
|
bind_mount(DATABIN, MIRRDIR "/bin");
|
||||||
|
|
||||||
xmkdirs(BBPATH, 0755);
|
|
||||||
if (access(MIRRDIR "/bin/busybox", X_OK) == 0) {
|
if (access(MIRRDIR "/bin/busybox", X_OK) == 0) {
|
||||||
LOGI("* Setting up internal busybox");
|
LOGI("* Setting up internal busybox");
|
||||||
exec_command_sync(MIRRDIR "/bin/busybox", "--install", "-s", BBPATH, NULL);
|
exec_command_sync(MIRRDIR "/bin/busybox", "--install", "-s", BBPATH, NULL);
|
||||||
|
@ -140,15 +140,8 @@ int resize_img(const char *img, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *mount_image(const char *img, const char *target) {
|
char *mount_image(const char *img, const char *target) {
|
||||||
if (access(img, F_OK) == -1)
|
if (access(img, F_OK) == -1 || access(target, F_OK) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (access(target, F_OK) == -1) {
|
|
||||||
if (xmkdirs(target, 0755) == -1) {
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
|
|
||||||
xmkdirs(target, 0755);
|
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e2fsck(img))
|
if (e2fsck(img))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user