diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -177,9 +177,11 @@ int mkpathat(int atfd, char *dir, mode_t lastmode, int flags) // not-a-directory along the way, but the last one we must explicitly // test for. Might as well do it up front. - if (!fstatat(atfd, dir, &buf, 0) && !S_ISDIR(buf.st_mode)) { - errno = EEXIST; - return 1; + if (!fstatat(atfd, dir, &buf, 0)) { + if ((flags&MKPATHAT_MKLAST) && !S_ISDIR(buf.st_mode)) { + errno = EEXIST; + return 1; + } else return 0; } for (s = dir; ;s++) { |