Reduce unnecessary stack memory allocation
This commit is contained in:
parent
2dd4cf040e
commit
c7e777255a
@ -401,7 +401,6 @@ static void daemon_init() {
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
int root, sbin;
|
int root, sbin;
|
||||||
char target[PATH_MAX], linkpath[PATH_MAX];
|
|
||||||
// Setup links under /sbin
|
// Setup links under /sbin
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
|
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
|
||||||
xmkdir("/root", 0755);
|
xmkdir("/root", 0755);
|
||||||
@ -423,13 +422,13 @@ static void daemon_init() {
|
|||||||
dir = xfdopendir(root);
|
dir = xfdopendir(root);
|
||||||
while((entry = xreaddir(dir))) {
|
while((entry = xreaddir(dir))) {
|
||||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
|
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
|
||||||
snprintf(target, sizeof(target), "/root/%s", entry->d_name);
|
snprintf(buf, PATH_MAX, "/root/%s", entry->d_name);
|
||||||
snprintf(linkpath, sizeof(linkpath), "/sbin/%s", entry->d_name);
|
snprintf(buf2, PATH_MAX, "/sbin/%s", entry->d_name);
|
||||||
xsymlink(target, linkpath);
|
xsymlink(buf, buf2);
|
||||||
}
|
}
|
||||||
for (int i = 0; applet[i]; ++i) {
|
for (int i = 0; applet[i]; ++i) {
|
||||||
snprintf(linkpath, sizeof(linkpath), "/sbin/%s", applet[i]);
|
snprintf(buf2, PATH_MAX, "/sbin/%s", applet[i]);
|
||||||
xsymlink("/root/magisk", linkpath);
|
xsymlink("/root/magisk", buf2);
|
||||||
}
|
}
|
||||||
xmkdir("/magisk", 0755);
|
xmkdir("/magisk", 0755);
|
||||||
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
|
||||||
@ -459,9 +458,7 @@ static void daemon_init() {
|
|||||||
#else
|
#else
|
||||||
LOGI("mount: %s\n", MIRRDIR "/system");
|
LOGI("mount: %s\n", MIRRDIR "/system");
|
||||||
#endif
|
#endif
|
||||||
continue;
|
} else if (strstr(line, " /vendor ")) {
|
||||||
}
|
|
||||||
if (strstr(line, " /vendor ")) {
|
|
||||||
seperate_vendor = 1;
|
seperate_vendor = 1;
|
||||||
sscanf(line, "%s", buf);
|
sscanf(line, "%s", buf);
|
||||||
xmkdir_p(MIRRDIR "/vendor", 0755);
|
xmkdir_p(MIRRDIR "/vendor", 0755);
|
||||||
@ -471,10 +468,10 @@ static void daemon_init() {
|
|||||||
#else
|
#else
|
||||||
LOGI("mount: %s\n", MIRRDIR "/vendor");
|
LOGI("mount: %s\n", MIRRDIR "/vendor");
|
||||||
#endif
|
#endif
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
free(line);
|
||||||
}
|
}
|
||||||
vec_deep_destroy(&mounts);
|
vec_destroy(&mounts);
|
||||||
if (!seperate_vendor) {
|
if (!seperate_vendor) {
|
||||||
xsymlink(MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
xsymlink(MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
@ -495,7 +492,7 @@ static void daemon_init() {
|
|||||||
static int prepare_img() {
|
static int prepare_img() {
|
||||||
// First merge images
|
// First merge images
|
||||||
if (merge_img("/data/magisk_merge.img", MAINIMG)) {
|
if (merge_img("/data/magisk_merge.img", MAINIMG)) {
|
||||||
LOGE("Image merge %s -> %s failed!\n", "/data/magisk_merge.img", MAINIMG);
|
LOGE("Image merge /data/magisk_merge.img -> " MAINIMG " failed!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +547,7 @@ static int prepare_img() {
|
|||||||
magiskloop = mount_image(MAINIMG, MOUNTPOINT);
|
magiskloop = mount_image(MAINIMG, MOUNTPOINT);
|
||||||
free(magiskloop);
|
free(magiskloop);
|
||||||
|
|
||||||
// Fix file seliux contexts
|
// Fix file selinux contexts
|
||||||
fix_filecon();
|
fix_filecon();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user