From a95cd44675061863d776c0b405c6cffa4721f915 Mon Sep 17 00:00:00 2001 From: Niklas Hallqvist Date: Sun, 25 Jan 1998 21:54:50 +0000 Subject: Fix a race where a dir might have been created after a stat call, but before our mkdir --- bin/mkdir/mkdir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bin') 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); } -- cgit v1.2.3