summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFCmd.c
diff options
context:
space:
mode:
authordas <das>2007-04-23 20:35:55 (GMT)
committerdas <das>2007-04-23 20:35:55 (GMT)
commitc93886c791c9d180c4e5fe39020495c2220bc3e6 (patch)
tree2f952ac8a6f3a4fa8111ba107482dc69f22c830a /unix/tclUnixFCmd.c
parentb2d416baafa945b216378335885f99238f38966e (diff)
downloadtcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.zip
tcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.tar.gz
tcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.tar.bz2
* unix/tclUnixFCmd.c: add workaround for crashing bug in fts_open()
* unix/tclUnixInit.c: without FTS_NOSTAT on 64bit Darwin 8 or earlier.
Diffstat (limited to 'unix/tclUnixFCmd.c')
-rw-r--r--unix/tclUnixFCmd.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 13a2a6e..aef6b5b 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFCmd.c,v 1.60 2006/11/15 20:08:45 dgp Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.61 2007/04/23 20:35:55 das Exp $
*
* Portions of this code were derived from NetBSD source code which has the
* following copyright notice:
@@ -234,6 +234,26 @@ MODULE_SCOPE long tclMacOSXDarwinRelease;
#define haveRealpath 1
#endif
#endif /* NO_REALPATH */
+
+#ifdef HAVE_FTS
+#ifdef HAVE_STRUCT_STAT64
+/* fts doesn't do stat64 */
+#define noFtsStat 1
+#elif defined(__APPLE__) && defined(__LP64__) && \
+ defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+/*
+ * prior to Darwin 9, 64bit fts_open() without FTS_NOSTAT may crash (due to a
+ * 64bit-unsafe ALIGN macro); if we could be running on pre-10.5 OSX, check
+ * Darwin release at runtime and do a separate stat() if necessary.
+ */
+MODULE_SCOPE long tclMacOSXDarwinRelease;
+#define noFtsStat (tclMacOSXDarwinRelease < 9)
+#else
+#define noFtsStat 0
+#endif
+#endif /* HAVE_FTS */
+
/*
*---------------------------------------------------------------------------
@@ -1020,13 +1040,8 @@ TraverseUnixTree(
}
#else /* HAVE_FTS */
paths[0] = source;
- fts = fts_open((char**)paths, FTS_PHYSICAL|FTS_NOCHDIR|
-#ifdef HAVE_STRUCT_STAT64
- FTS_NOSTAT, /* fts doesn't do stat64 */
-#else
- (doRewind ? FTS_NOSTAT : 0), /* no need to stat for delete */
-#endif
- NULL);
+ fts = fts_open((char**)paths, FTS_PHYSICAL | FTS_NOCHDIR |
+ (noFtsStat || doRewind ? FTS_NOSTAT : 0), NULL);
if (fts == NULL) {
errfile = source;
goto end;
@@ -1064,15 +1079,15 @@ TraverseUnixTree(
break;
}
if (!doRewind) { /* no need to stat for delete */
-#ifdef HAVE_STRUCT_STAT64
- statBufPtr = &statBuf;
- if (TclOSlstat(ent->fts_path, statBufPtr) != 0) {
- errfile = ent->fts_path;
- break;
+ if (noFtsStat) {
+ statBufPtr = &statBuf;
+ if (TclOSlstat(ent->fts_path, statBufPtr) != 0) {
+ errfile = ent->fts_path;
+ break;
+ }
+ } else {
+ statBufPtr = ent->fts_statp;
}
-#else
- statBufPtr = ent->fts_statp;
-#endif
}
result = (*traverseProc)(sourcePtr, targetPtr, statBufPtr, type,
errorPtr);