1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- Unlink is now reentrant, or at least thread-safe.

- You can now make unlink() stop after a failed deletion attempt which
  failed because the object to be deleted was reported as being "in use".
  The libunix.a variant defaults to report the deletion to have succeeded
  under these circumstances and later tries to delete the files marked
  for deletion. See <dos.h> for a brief documentation of how to change
  the behaviour.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15155 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-09-27 09:40:06 +00:00
parent 0b833b8680
commit 9984a37cb4
9 changed files with 110 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: unistd_unlink.c,v 1.10 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_unlink.c,v 1.11 2006-09-27 09:40:06 obarthel Exp $
*
* :ts=4
*
@@ -53,7 +53,6 @@
/****************************************************************************/
/* ZZZ unlink() must be reentrant according to POSIX.1 */
int
unlink(const char * path_name)
{
@@ -120,13 +119,13 @@ unlink(const char * path_name)
{
#if defined(UNIX_PATH_SEMANTICS)
{
struct UnlinkNode * uln = NULL;
struct UnlinkNode * node;
struct UnlinkNode * uln;
BOOL found = FALSE;
assert( UtilityBase != NULL );
if(IoErr() != ERROR_OBJECT_IN_USE)
if(NOT __unlink_retries || IoErr() != ERROR_OBJECT_IN_USE)
{
__set_errno(__translate_access_io_error_to_errno(IoErr()));
goto out;
@@ -149,6 +148,8 @@ unlink(const char * path_name)
PROFILE_OFF();
ObtainSemaphore(&__unlink_semaphore);
assert( __unlink_list.mlh_Head != NULL );
for(node = (struct UnlinkNode *)__unlink_list.mlh_Head ;
@@ -167,16 +168,24 @@ unlink(const char * path_name)
if(NOT found)
{
uln = malloc(sizeof(*uln) + strlen(path_name) + 1);
if(uln == NULL)
goto out;
if(uln != NULL)
{
uln->uln_Lock = current_dir;
uln->uln_Name = (char *)(uln + 1);
uln->uln_Lock = current_dir;
uln->uln_Name = (char *)(uln + 1);
strcpy(uln->uln_Name,path_name);
AddTail((struct List *)&__unlink_list,(struct Node *)uln);
strcpy(uln->uln_Name,path_name);
AddTail((struct List *)&__unlink_list,(struct Node *)uln);
current_dir = ZERO;
}
}
current_dir = ZERO;
ReleaseSemaphore(&__unlink_semaphore);
if(NOT found && uln == NULL)
{
__set_errno(ENOMEM);
goto out;
}
}
#else