summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2001-09-04 18:06:34 (GMT)
committervincentdarley <vincentdarley>2001-09-04 18:06:34 (GMT)
commit6fca271a5115b8b8e94f10dce8efb41fcedb53a9 (patch)
treefe242e0e386c2472085adf41540fa813c334a000 /unix
parentbaf84f971d4274324372aab6f0fd968c63d7dcd4 (diff)
downloadtcl-6fca271a5115b8b8e94f10dce8efb41fcedb53a9.zip
tcl-6fca271a5115b8b8e94f10dce8efb41fcedb53a9.tar.gz
tcl-6fca271a5115b8b8e94f10dce8efb41fcedb53a9.tar.bz2
minor fs, vfs fixes
Diffstat (limited to 'unix')
-rw-r--r--unix/tclLoadAout.c11
-rw-r--r--unix/tclLoadDl.c13
-rw-r--r--unix/tclLoadDld.c12
-rw-r--r--unix/tclLoadDyld.c14
-rw-r--r--unix/tclLoadNext.c14
-rw-r--r--unix/tclLoadOSF.c12
-rw-r--r--unix/tclLoadShl.c12
-rw-r--r--unix/tclUnixFCmd.c34
-rw-r--r--unix/tclUnixPipe.c24
9 files changed, 112 insertions, 34 deletions
diff --git a/unix/tclLoadAout.c b/unix/tclLoadAout.c
index 51e38b3..ddc5316 100644
--- a/unix/tclLoadAout.c
+++ b/unix/tclLoadAout.c
@@ -14,7 +14,7 @@
* and Design Engineering (MADE) Initiative through ARPA contract
* F33615-94-C-4400.
*
- * RCS: @(#) $Id: tclLoadAout.c,v 1.5 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadAout.c,v 1.6 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -136,7 +136,8 @@ static void UnlinkSymbolTable _ANSI_ARGS_((void));
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code (UTF-8). */
@@ -147,7 +148,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
char * inputSymbolTable; /* Name of the file containing the
* symbol table from the last link. */
diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c
index bfe52e9..1d20521 100644
--- a/unix/tclLoadDl.c
+++ b/unix/tclLoadDl.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: tclLoadDl.c,v 1.4 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadDl.c,v 1.5 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -57,7 +57,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -68,7 +69,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
VOID *handle;
Tcl_DString newName, ds;
@@ -86,6 +91,8 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
return TCL_ERROR;
}
+ *unloadProcPtr = &TclpUnloadFile;
+
/*
* Some platforms still add an underscore to the beginning of symbol
* names. If we can't find a name without an underscore, try again
diff --git a/unix/tclLoadDld.c b/unix/tclLoadDld.c
index 2b15148..ecf5b12 100644
--- a/unix/tclLoadDld.c
+++ b/unix/tclLoadDld.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDld.c,v 1.4 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadDld.c,v 1.5 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -49,7 +49,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -60,7 +61,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
static int firstTime = 1;
int returnCode;
@@ -98,6 +103,7 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
*proc2Ptr = (Tcl_PackageInitProc *) dld_get_func(sym2);
*clientDataPtr = strcpy(
(char *) ckalloc((unsigned) (strlen(fileName) + 1)), fileName);
+ *unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 58eb5a5..aed76ff 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDyld.c,v 1.3 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadDyld.c,v 1.4 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -40,7 +40,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -51,7 +52,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
NSObjectFileImageReturnCode err;
NSObjectFileImage image;
@@ -108,7 +113,8 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
*proc2Ptr = NSAddressOfSymbol(symbol);
*clientDataPtr = module;
-
+ *unloadProcPtr = &TclpUnloadFile;
+
return TCL_OK;
}
diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c
index f460524..17f124b 100644
--- a/unix/tclLoadNext.c
+++ b/unix/tclLoadNext.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: tclLoadNext.c,v 1.4 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadNext.c,v 1.5 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -39,7 +39,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -50,7 +51,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
struct mach_header *header;
char *data;
@@ -81,7 +86,8 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
rld_lookup(NULL,sym,(unsigned long *)proc2Ptr);
}
*clientDataPtr = NULL;
-
+ *unloadProcPtr = &TclpUnloadFile;
+
return TCL_OK;
}
diff --git a/unix/tclLoadOSF.c b/unix/tclLoadOSF.c
index cd6a393..cdaf92c 100644
--- a/unix/tclLoadOSF.c
+++ b/unix/tclLoadOSF.c
@@ -31,7 +31,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadOSF.c,v 1.4 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadOSF.c,v 1.5 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -60,7 +60,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -71,7 +72,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
ldr_module_t lm;
char *pkg;
@@ -100,6 +105,7 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
pkg++;
*proc1Ptr = ldr_lookup_package(pkg, sym1);
*proc2Ptr = ldr_lookup_package(pkg, sym2);
+ *unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
diff --git a/unix/tclLoadShl.c b/unix/tclLoadShl.c
index 0d7c648..5feb489 100644
--- a/unix/tclLoadShl.c
+++ b/unix/tclLoadShl.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: tclLoadShl.c,v 1.5 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadShl.c,v 1.6 2001/09/04 18:06:34 vincentdarley Exp $
*/
#include <dl.h>
@@ -47,7 +47,8 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
+TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
+ clientDataPtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -58,7 +59,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
* to sym1 and sym2. */
ClientData *clientDataPtr; /* Filled with token for dynamically loaded
* file which will be passed back to
- * TclpUnloadFile() to unload the file. */
+ * (*unloadProcPtr)() to unload the file. */
+ Tcl_FSUnloadFileProc **unloadProcPtr;
+ /* Filled with address of Tcl_FSUnloadFileProc
+ * function which should be used for
+ * this file. */
{
shl_t handle;
Tcl_DString newName;
@@ -112,6 +117,7 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
}
Tcl_DStringFree(&newName);
}
+ *unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 264a7a6..98d5224 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.11 2001/08/30 08:53:15 vincentdarley Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.12 2001/09/04 18:06:34 vincentdarley Exp $
*
* Portions of this code were derived from NetBSD source code which has
* the following copyright notice:
@@ -685,19 +685,37 @@ DoRemoveDirectory(pathPtr, recursive, errorPtr)
* causing error. */
{
CONST char *path;
-
+ mode_t oldPerm = 0;
+ int result;
+
path = Tcl_DStringValue(pathPtr);
+
+ if (recursive != 0) {
+ /* We should try to change permissions so this can be deleted */
+ struct stat statBuf;
+ int newPerm;
+
+ if (stat(path, &statBuf) == 0) {
+ oldPerm = (mode_t) (statBuf.st_mode & 0x00007FFF);
+ }
+
+ newPerm = oldPerm | (64+128+256);
+ chmod(path, (mode_t) newPerm);
+ }
+
if (rmdir(path) == 0) { /* INTL: Native. */
return TCL_OK;
}
if (errno == ENOTEMPTY) {
errno = EEXIST;
}
+
+ result = TCL_OK;
if ((errno != EEXIST) || (recursive == 0)) {
if (errorPtr != NULL) {
Tcl_ExternalToUtfDString(NULL, path, -1, errorPtr);
}
- return TCL_ERROR;
+ result = TCL_ERROR;
}
/*
@@ -705,7 +723,15 @@ DoRemoveDirectory(pathPtr, recursive, errorPtr)
* specified, so we recursively remove all the files in the directory.
*/
- return TraverseUnixTree(TraversalDelete, pathPtr, NULL, errorPtr);
+ if (result == TCL_OK) {
+ result = TraverseUnixTree(TraversalDelete, pathPtr, NULL, errorPtr);
+ }
+
+ if ((result != TCL_OK) && (recursive != 0)) {
+ /* Try to restore permissions */
+ chmod(path, oldPerm);
+ }
+ return result;
}
/*
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index 964b3b1..85316c0 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.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: tclUnixPipe.c,v 1.14 2001/08/07 00:42:45 hobbs Exp $
+ * RCS: @(#) $Id: tclUnixPipe.c,v 1.15 2001/09/04 18:06:35 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -238,19 +238,29 @@ TclpCreateTempFile(contents)
Tcl_Obj*
TclpTempFileName()
{
- char fileName[L_tmpnam];
+ char fileName[L_tmpnam + 9];
+ Tcl_Obj *result = NULL;
+ int fd;
/*
- * tmpnam should not be used (see [Patch: #442636]), but mkstemp
- * doesn't provide just the filename. The use of this will have
- * to reconcile that conflict.
+ * We should also check against making more then TMP_MAX of these.
*/
- if (tmpnam(fileName) == NULL) { /* INTL: Native. */
+ strcpy(fileName, P_tmpdir); /* INTL: Native. */
+ if (fileName[strlen(fileName) - 1] != '/') {
+ strcat(fileName, "/"); /* INTL: Native. */
+ }
+ strcat(fileName, "tclXXXXXX");
+ fd = mkstemp(fileName); /* INTL: Native. */
+ if (fd == -1) {
return NULL;
}
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+ unlink(fileName); /* INTL: Native. */
- return TclpNativeToNormalized((ClientData) fileName);
+ result = TclpNativeToNormalized((ClientData) fileName);
+ close (fd);
+ return result;
}
/*