summaryrefslogtreecommitdiff
path: root/mkdir.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-11-20 10:39:43 -0500
committerJakob Kaivo <jkk@ung.org>2019-11-20 10:39:43 -0500
commit2d81df24bdce10bb848738e0cd848162f34513cb (patch)
treee0a4c2405f36e6f6bdb7b9060436591446c53566 /mkdir.c
parent5e5371907e949285a80fb0ba538cdf59e98a667b (diff)
do not error for existing final directory when -p is specifiedHEADmaster
Diffstat (limited to 'mkdir.c')
-rw-r--r--mkdir.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mkdir.c b/mkdir.c
index 853980e..43e8958 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -65,6 +65,12 @@ static int mk_dir(char *path, mode_t mode, int flags)
}
if (mkdir(path, mode) != 0) {
+ if ((flags & PARENTS) && (errno == EEXIST)) {
+ struct stat st;
+ if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
+ return 0;
+ }
+ }
fprintf(stderr, "mkdir: %s: %s\n", path, strerror(errno));
return 1;
}