summaryrefslogtreecommitdiff
path: root/bin/mkdir/mkdir.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1998-01-25 21:54:50 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1998-01-25 21:54:50 +0000
commita95cd44675061863d776c0b405c6cffa4721f915 (patch)
treebdc72a7bf7dda2337247a87654895255eb54b932 /bin/mkdir/mkdir.c
parent8b87d75d3db3b5a103bdaaf4101b7f8742361694 (diff)
Fix a race where a dir might have been created after a stat call, but before
our mkdir
Diffstat (limited to 'bin/mkdir/mkdir.c')
-rw-r--r--bin/mkdir/mkdir.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index a4c7c04ada8..55a63380441 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkdir.c,v 1.6 1997/09/01 18:29:39 deraadt Exp $ */
+/* $OpenBSD: mkdir.c,v 1.7 1998/01/25 21:54:49 niklas Exp $ */
/* $NetBSD: mkdir.c,v 1.14 1995/06/25 21:59:21 mycroft Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94";
#else
-static char rcsid[] = "$OpenBSD: mkdir.c,v 1.6 1997/09/01 18:29:39 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mkdir.c,v 1.7 1998/01/25 21:54:49 niklas Exp $";
#endif
#endif /* not lint */
@@ -149,7 +149,9 @@ mkpath(path, mode, dir_mode)
*slash = '\0';
if (stat(path, &sb)) {
- if (errno != ENOENT || mkdir(path, done ? mode : dir_mode)) {
+ if (errno != ENOENT ||
+ (mkdir(path, done ? mode : dir_mode) &&
+ errno != EEXIST)) {
warn("%s", path);
return (-1);
}