From: drh Date: Thu, 12 Jun 2008 12:38:10 +0000 (+0000) Subject: Copy the latest VFS changes into the OS/2 implementation. This is a blind X-Git-Tag: version-3.6.10~967 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a8f176e8d314db820d7dacf47571e9253baae4c;p=thirdparty%2Fsqlite.git Copy the latest VFS changes into the OS/2 implementation. This is a blind edit - I have no way to compile or test OS/2. (CVS 5210) FossilOrigin-Name: b60508ccbc3159e994bc988512d9dbec3932deb6 --- diff --git a/manifest b/manifest index f49950fc3c..a4ede3b7e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\sadditional\stestcases\sfor\sjulianday\scalculations\swith\smidnight\sboundary\sfor\sUTC\stime.\s(CVS\s5209) -D 2008-06-12T05:16:15 +C Copy\sthe\slatest\sVFS\schanges\sinto\sthe\sOS/2\simplementation.\s\sThis\sis\sa\sblind\nedit\s-\sI\shave\sno\sway\sto\scompile\sor\stest\sOS/2.\s(CVS\s5210) +D 2008-06-12T12:38:10 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -130,7 +130,7 @@ F src/mutex_w32.c 133698096a2c4e81cd11ea6f4de7891c66f7b9f7 F src/os.c 284abcb97ffdaf5f0b08fa4c5fe1fe93dd86b416 F src/os.h c9a7f94e80193fd4cf27f5c5698eb56753f1b05a F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 -F src/os_os2.c ae37c5971e8b0cfc77e6bf685aa9dd43414208d8 +F src/os_os2.c 6cc3ff5e934eecfa078b5b7bf1d0bdc7ac3f5a2e F src/os_unix.c 47936aee8265e482faa626141d97d896aa981ef4 F src/os_win.c 0d975b131b2b104d6d69d9f16bdf3c8cec28e81d F src/pager.c be98ceeb55bbcda9251c1a846d28c3d323885708 @@ -593,7 +593,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 0729f5c3d01200190897488f14aec413a5ea17f9 -R 13b984f0768ebaa40b5c7e286a6869c0 -U shane -Z 48e7b28e9864381656e53aa34872ff8b +P edd2cb00ae606858d8ae138c69eee7821b8cd6ea +R 5a214bbf9c201a500d01a02d59ac7033 +U drh +Z bad3ab7e73e6a175cb3c0e9aefbda043 diff --git a/manifest.uuid b/manifest.uuid index dc50650bb2..88aab1f9ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -edd2cb00ae606858d8ae138c69eee7821b8cd6ea \ No newline at end of file +b60508ccbc3159e994bc988512d9dbec3932deb6 \ No newline at end of file diff --git a/src/os_os2.c b/src/os_os2.c index dd0e82ed76..a20de20901 100644 --- a/src/os_os2.c +++ b/src/os_os2.c @@ -12,7 +12,7 @@ ** ** This file contains code that is specific to OS/2. ** -** $Id: os_os2.c,v 1.41 2008/06/12 02:16:45 shane Exp $ +** $Id: os_os2.c,v 1.42 2008/06/12 12:38:10 drh Exp $ */ #include "sqliteInt.h" @@ -414,7 +414,7 @@ int os2Lock( sqlite3_file *id, int locktype ){ ** file by this or any other process. If such a lock is held, return ** non-zero, otherwise zero. */ -int os2CheckReservedLock( sqlite3_file *id ){ +int os2CheckReservedLock( sqlite3_file *id, int *pOut ){ int r = 0; os2File *pFile = (os2File*)id; assert( pFile!=0 ); @@ -445,7 +445,8 @@ int os2CheckReservedLock( sqlite3_file *id ){ r = !(rc == NO_ERROR); OSTRACE3( "TEST WR-LOCK %d %d (remote)\n", pFile->h, r ); } - return r; + *pOut = r; + return SQLITE_OK; } /* @@ -632,6 +633,50 @@ static const sqlite3_io_methods os2IoMethod = { ** The next block of code implements the VFS methods. ****************************************************************************/ +/* +** Create a temporary file name in zBuf. zBuf must be big enough to +** hold at pVfs->mxPathname characters. +*/ +static int getTempname(int nBuf, char *zBuf ){ + static const unsigned char zChars[] = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"; + int i, j; + char zTempPathBuf[3]; + PSZ zTempPath = (PSZ)&zTempPathBuf; + char *zTempPathUTF; + if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){ + if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){ + if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){ + ULONG ulDriveNum = 0, ulDriveMap = 0; + DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ); + sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) ); + } + } + } + /* strip off a trailing slashes or backslashes, otherwise we would get * + * multiple (back)slashes which causes DosOpen() to fail */ + j = strlen(zTempPath); + while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' ) ){ + j--; + } + zTempPath[j] = '\0'; + zTempPathUTF = convertCpPathToUtf8( zTempPath ); + sqlite3_snprintf( nBuf-30, zBuf, + "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPathUTF ); + free( zTempPathUTF ); + j = strlen( zBuf ); + sqlite3_randomness( 20, &zBuf[j] ); + for( i = 0; i < 20; i++, j++ ){ + zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; + } + zBuf[j] = 0; + OSTRACE2( "TEMP FILENAME: %s\n", zBuf ); + return SQLITE_OK; +} + + /* ** Open a file. */ @@ -650,6 +695,19 @@ static int os2Open( APIRET rc = NO_ERROR; ULONG ulAction; char *zNameCp; + char zTmpname[MAX_PATH+1]; /* Buffer to hold name of temp file */ + + /* If the second argument to this function is NULL, generate a + ** temporary file name to use + */ + if( !zName ){ + int rc = getTempname(MAX_PATH+1, zTmpname); + if( rc!=SQLITE_OK ){ + return rc; + } + zName = zTmpname; + } + memset( pFile, 0, sizeof(*pFile) ); @@ -760,7 +818,8 @@ int os2Delete( static int os2Access( sqlite3_vfs *pVfs, /* Not used on os2 */ const char *zFilename, /* Name of file to check */ - int flags /* Type of test to make on this file */ + int flags, /* Type of test to make on this file */ + int *pOut /* Write results here */ ){ FILESTATUS3 fsts3ConfigInfo; APIRET rc = NO_ERROR; @@ -785,54 +844,12 @@ static int os2Access( default: assert( !"Invalid flags argument" ); } - return rc; -} - - -/* -** Create a temporary file name in zBuf. zBuf must be big enough to -** hold at pVfs->mxPathname characters. -*/ -static int os2GetTempname( sqlite3_vfs *pVfs, int nBuf, char *zBuf ){ - static const unsigned char zChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - int i, j; - char zTempPathBuf[3]; - PSZ zTempPath = (PSZ)&zTempPathBuf; - char *zTempPathUTF; - if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){ - if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){ - if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){ - ULONG ulDriveNum = 0, ulDriveMap = 0; - DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ); - sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) ); - } - } - } - /* strip off a trailing slashes or backslashes, otherwise we would get * - * multiple (back)slashes which causes DosOpen() to fail */ - j = strlen(zTempPath); - while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' ) ){ - j--; - } - zTempPath[j] = '\0'; - zTempPathUTF = convertCpPathToUtf8( zTempPath ); - sqlite3_snprintf( nBuf-30, zBuf, - "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPathUTF ); - free( zTempPathUTF ); - j = strlen( zBuf ); - sqlite3_randomness( 20, &zBuf[j] ); - for( i = 0; i < 20; i++, j++ ){ - zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - } - zBuf[j] = 0; - OSTRACE2( "TEMP FILENAME: %s\n", zBuf ); + *pOut = rc; return SQLITE_OK; } + /* ** Turn a relative pathname into a full pathname. Write the full ** pathname into zFull[]. zFull[] will be at least pVfs->mxPathname @@ -1042,7 +1059,6 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){ os2Open, /* xOpen */ os2Delete, /* xDelete */ os2Access, /* xAccess */ - os2GetTempname, /* xGetTempname */ os2FullPathname, /* xFullPathname */ os2DlOpen, /* xDlOpen */ os2DlError, /* xDlError */ @@ -1051,6 +1067,7 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime /* xCurrentTime */ + os2GetLastError /* xGetLastError */ }; return &os2Vfs;