From a1d3a7aee63a2a6cbeedeea9ff578844a160f122 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 30 Jul 1994 13:12:40 +0000 Subject: . --- lib/mkdir.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'lib/mkdir.c') diff --git a/lib/mkdir.c b/lib/mkdir.c index e68ccb17c..b00199d3f 100644 --- a/lib/mkdir.c +++ b/lib/mkdir.c @@ -1,4 +1,4 @@ -/* mkrmdir.c -- BSD compatible directory functions for System V +/* mkdir.c -- BSD compatible directory functions for System V Copyright (C) 1988, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -15,6 +15,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else +#include "config.h" +#endif +#endif + #include #include #include @@ -22,6 +33,18 @@ extern int errno; #endif +#ifdef STAT_MACROS_BROKEN +#ifdef S_ISDIR +#undef S_ISDIR +#endif +#endif /* STAT_MACROS_BROKEN. */ + +#if !defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +#include "safe-stat.h" + /* mkdir and rmdir adapted from GNU tar. */ /* Make directory DPATH, with permission mode DMODE. @@ -43,7 +66,7 @@ mkdir (dpath, dmode) int cpid, status; struct stat statbuf; - if (stat (dpath, &statbuf) == 0) + if (SAFE_STAT (dpath, &statbuf) == 0) { errno = EEXIST; /* stat worked, so it already exists. */ return -1; @@ -92,10 +115,10 @@ rmdir (dpath) int cpid, status; struct stat statbuf; - if (stat (dpath, &statbuf) != 0) + if (SAFE_STAT (dpath, &statbuf) != 0) return -1; /* stat set errno. */ - if ((statbuf.st_mode & S_IFMT) != S_IFDIR) + if (!S_ISDIR (statbuf.st_mode)) { errno = ENOTDIR; return -1; -- cgit v1.2.3-54-g00ecf