projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.
[gnulib.git]
/
lib
/
makepath.c
diff --git
a/lib/makepath.c
b/lib/makepath.c
index
4c19630
..
4d647b5
100644
(file)
--- a/
lib/makepath.c
+++ b/
lib/makepath.c
@@
-18,6
+18,17
@@
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and
Jim Meyering <meyering@cs.utexas.edu>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and
Jim Meyering <meyering@cs.utexas.edu>. */
+#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
+
#ifdef __GNUC__
#define alloca __builtin_alloca
#else
#ifdef __GNUC__
#define alloca __builtin_alloca
#else
@@
-38,14
+49,26
@@
char *alloca ();
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+
+#ifdef STAT_MACROS_BROKEN
+#ifdef S_ISDIR
+#undef S_ISDIR
+#endif
+#endif /* STAT_MACROS_BROKEN. */
+
#if !defined(S_ISDIR) && defined(S_IFDIR)
#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define
S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#ifdef STDC_HEADERS
#endif
#ifdef STDC_HEADERS
-#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
-#else
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifndef STDC_HEADERS
extern int errno;
#endif
extern int errno;
#endif
@@
-147,7
+170,7
@@
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
if (owner != (uid_t) -1 && group != (gid_t) -1
&& chown (dirpath, owner, group)
if (owner != (uid_t) -1 && group != (gid_t) -1
&& chown (dirpath, owner, group)
-#if
def AFS
+#if
defined(AFS) && defined (EPERM)
&& errno != EPERM
#endif
)
&& errno != EPERM
#endif
)
@@
-183,7
+206,10
@@
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
/* We're done making leading directories.
Make the final component of the path. */
/* We're done making leading directories.
Make the final component of the path. */
- if (mkdir (dirpath, mode))
+ /* The path could end in "/." or contain "/..", so test
+ if we really have to create the directory. */
+
+ if (stat (dirpath, &stats) && mkdir (dirpath, mode))
{
error (0, errno, "cannot make directory `%s'", dirpath);
umask (oldmask);
{
error (0, errno, "cannot make directory `%s'", dirpath);
umask (oldmask);