generic: avoid unnecessary mkdir()

This commit is contained in:
Thomas Schoebel-Theuer 2022-10-04 15:30:25 +02:00
parent 93e829f94e
commit 07acef8d1d
1 changed files with 5 additions and 0 deletions

View File

@ -1097,6 +1097,7 @@ int ordered_symlink(const char *oldpath,
/* Automatically create any missing path dirs */
while (unlikely(status < 0 && status != -EEXIST)) {
struct kstat test = {};
int old_len;
int check;
@ -1117,6 +1118,10 @@ int ordered_symlink(const char *oldpath,
dir_len--;
if (dir_len <= 0 || dir_len >= old_len)
break;
/* do not try to tackle existing dir_path */
check = mars_stat(dir_path, &test, true);
if (check >= 0 && S_ISDIR(test.mode))
break;
/* create the interim dir */
check = mars_mkdir(dir_path);
if (check >= 0) {