diff options
author | drh <drh@noemail.net> | 2011-08-08 23:18:05 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-08-08 23:18:05 +0000 |
commit | 036ac7fa90afe12eb267e76fbfd94c239a871ac6 (patch) | |
tree | 1f9b60ba9184c974f461225415deb03b39ecd003 /src | |
parent | a5ae4c330b57fd41db7de2de5a0d18c6efa60e98 (diff) | |
download | sqlite-036ac7fa90afe12eb267e76fbfd94c239a871ac6.tar.gz sqlite-036ac7fa90afe12eb267e76fbfd94c239a871ac6.zip |
Allow the unlink() system call to be overridden in os_unix.c.
FossilOrigin-Name: 8d1b5c3ac027ac00d57a250aad45230a09645617
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 9e7b45821..eca990518 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -394,6 +394,9 @@ static struct unix_syscall { #endif #define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent) + { "unlink", (sqlite3_syscall_ptr)unlink, 0 }, +#define osUnlink ((int(*)(const char*))aSyscall[16].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -1761,7 +1764,7 @@ static int closeUnixFile(sqlite3_file *id){ #if OS_VXWORKS if( pFile->pId ){ if( pFile->isDelete ){ - unlink(pFile->pId->zCanonicalName); + osUnlink(pFile->pId->zCanonicalName); } vxworksReleaseFileId(pFile->pId); pFile->pId = 0; @@ -2010,7 +2013,7 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { /* To fully unlock the database, delete the lock file */ assert( eFileLock==NO_LOCK ); - if( unlink(zLockFile) ){ + if( osUnlink(zLockFile) ){ int rc = 0; int tErrno = errno; if( ENOENT != tErrno ){ @@ -4162,7 +4165,7 @@ static int unixShmUnmap( assert( pShmNode->nRef>0 ); pShmNode->nRef--; if( pShmNode->nRef==0 ){ - if( deleteFlag && pShmNode->h>=0 ) unlink(pShmNode->zFilename); + if( deleteFlag && pShmNode->h>=0 ) osUnlink(pShmNode->zFilename); unixShmPurge(pDbFd); } unixLeaveMutex(); @@ -4642,7 +4645,7 @@ static int fillInUnixFile( if( rc!=SQLITE_OK ){ if( h>=0 ) robust_close(pNew, h, __LINE__); h = -1; - unlink(zFilename); + osUnlink(zFilename); isDelete = 0; } pNew->isDelete = isDelete; @@ -5049,7 +5052,7 @@ static int unixOpen( #if OS_VXWORKS zPath = zName; #else - unlink(zName); + osUnlink(zName); #endif } #if SQLITE_ENABLE_LOCKING_STYLE @@ -5164,7 +5167,7 @@ static int unixDelete( int rc = SQLITE_OK; UNUSED_PARAMETER(NotUsed); SimulateIOError(return SQLITE_IOERR_DELETE); - if( unlink(zPath)==(-1) && errno!=ENOENT ){ + if( osUnlink(zPath)==(-1) && errno!=ENOENT ){ return unixLogError(SQLITE_IOERR_DELETE, "unlink", zPath); } #ifndef SQLITE_DISABLE_DIRSYNC @@ -5921,7 +5924,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){ end_breaklock: if( rc ){ if( fd>=0 ){ - unlink(tPath); + osUnlink(tPath); robust_close(pFile, fd, __LINE__); } fprintf(stderr, "failed to break stale lock on %s, %s\n", cPath, errmsg); @@ -6744,7 +6747,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==16 ); + assert( ArraySize(aSyscall)==17 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |