diff options
author | Jim Meyering <jim@meyering.net> | 1994-07-30 13:12:40 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-07-30 13:12:40 +0000 |
commit | a1d3a7aee63a2a6cbeedeea9ff578844a160f122 (patch) | |
tree | e94e5d8ba7e742ebfd6fcc65d839cf79e7e44c42 /lib | |
parent | f1f85daaed8685b8a15c243c95bb7341e0fb5fe1 (diff) | |
download | coreutils-a1d3a7aee63a2a6cbeedeea9ff578844a160f122.tar.xz |
.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mkdir.c | 31 |
1 files changed, 27 insertions, 4 deletions
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 <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 @@ 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; |