changeset 286:00a1d1747d02

.
author Jim Meyering <jim@meyering.net>
date Sat, 30 Jul 1994 13:12:40 +0000
parents a79ed29a69f8
children 349cc607da80
files lib/mkdir.c
diffstat 1 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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 <config.h> 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 <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
@@ -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 @@
   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 @@
   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;