diff --git a/jni/daemon/bootstages.c b/jni/daemon/bootstages.c index 4bd830500..38bf5b66b 100644 --- a/jni/daemon/bootstages.c +++ b/jni/daemon/bootstages.c @@ -74,8 +74,8 @@ static int merge_img(const char *source, const char *target) { if (n_total != t_total) resize_img(target, n_total); - mkdir(SOURCE_TMP, 0755); - mkdir(TARGET_TMP, 0755); + xmkdir(SOURCE_TMP, 0755); + xmkdir(TARGET_TMP, 0755); char *s_loop, *t_loop; s_loop = mount_image(source, SOURCE_TMP); if (s_loop == NULL) return 1; @@ -332,7 +332,7 @@ static void clone_skeleton(struct node_entry *node) { // Create the dummy file/directory if (IS_DIR(child)) - mkdir(buf, 0755); + xmkdir(buf, 0755); else if (IS_REG(child)) close(open_new(buf)); // Links will be handled later @@ -540,10 +540,10 @@ void post_fs_data(int client) { goto unblock; if (new_img) { - mkdir(COREDIR, 0755); - mkdir(COREDIR "/post-fs-data.d", 0755); - mkdir(COREDIR "/service.d", 0755); - mkdir(COREDIR "/props", 0755); + xmkdir(COREDIR, 0755); + xmkdir(COREDIR "/post-fs-data.d", 0755); + xmkdir(COREDIR "/service.d", 0755); + xmkdir(COREDIR "/props", 0755); } // Run common scripts diff --git a/jni/daemon/daemon.c b/jni/daemon/daemon.c index 50deb4c62..49f60a924 100644 --- a/jni/daemon/daemon.c +++ b/jni/daemon/daemon.c @@ -171,7 +171,7 @@ void start_daemon(int client) { xmount(NULL, "/", NULL, MS_REMOUNT, NULL); create_links(NULL, "/sbin"); xchmod("/sbin", 0755); - mkdir("/magisk", 0755); + xmkdir("/magisk", 0755); xchmod("/magisk", 0755); xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL); diff --git a/jni/utils/xwrap.c b/jni/utils/xwrap.c index 5cd1bb794..2764c89d8 100644 --- a/jni/utils/xwrap.c +++ b/jni/utils/xwrap.c @@ -307,7 +307,7 @@ int xrename(const char *oldpath, const char *newpath) { int xmkdir(const char *pathname, mode_t mode) { int ret = mkdir(pathname, mode); - if (ret == -1) { + if (ret == -1 && errno != EEXIST) { PLOGE("mkdir %s %u", pathname, mode); } return ret;