(OS/2) Armor OS/2 against accidental deletion of files, too (patch by Daniel Kruse, verified by me) (CVS 3293)
FossilOrigin-Name: f357efb373b8631dbe4455530d060020b070bea2
This commit is contained in:
parent
65fd59f731
commit
04bd0c15ac
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C A\sfew\smore\stest\scases\sto\simprove\scoverage\sof\svirtual\stable\smodule\srelated\scode.\s(CVS\s3292)
|
||||
D 2006-06-24T11:51:33
|
||||
C (OS/2)\sArmor\sOS/2\sagainst\saccidental\sdeletion\sof\sfiles,\stoo\s(patch\sby\sDaniel\sKruse,\sverified\sby\sme)\s(CVS\s3293)
|
||||
D 2006-06-24T12:39:00
|
||||
F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -52,9 +52,9 @@ F src/loadext.c b08c5f5a57b78afd8cd0dd1677e98519e18db56f
|
||||
F src/main.c b71877c9c3cd491417fc7d4bbc785ddab411034c
|
||||
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
||||
F src/os.c 59f05de8c5777c34876607114a2fbe55ae578235
|
||||
F src/os.h ac2ccb4f48902c1611a7e1f171eb81d17e3b8eb2
|
||||
F src/os.h 3fd6a022bafd620fdfd779a51dccb42f31c97f75
|
||||
F src/os_common.h 108cd719c96a2b714b64e02aeabbd40684274e6a
|
||||
F src/os_os2.c 123cb394c069bc8c6a305830ffa2bc5f72e5b83a
|
||||
F src/os_os2.c 1cf00781716ae8f9ae1d886e819c55731249b3a8
|
||||
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
||||
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
||||
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
||||
@ -373,7 +373,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P 0c5f4ee39cb76747cf01398867fed2c7ae3edc84
|
||||
R 2d3154b85b2d1db6b9e65d6433ce4721
|
||||
U danielk1977
|
||||
Z c6c7a990fc60a21156c29c57e99dddc4
|
||||
P 255aa9121a2ef4fec7fa5523e52969acc96f4b40
|
||||
R 2b758788fcbcea37bf1aacb95194485d
|
||||
U pweilbacher
|
||||
Z dba44f16a572c90023dd1e7bf0447866
|
||||
|
@ -1 +1 @@
|
||||
255aa9121a2ef4fec7fa5523e52969acc96f4b40
|
||||
f357efb373b8631dbe4455530d060020b070bea2
|
4
src/os.h
4
src/os.h
@ -28,7 +28,7 @@
|
||||
# define OS_WIN 1
|
||||
# define OS_UNIX 0
|
||||
# define OS_OS2 0
|
||||
# elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(OS_OS2) || defined(__OS2__)
|
||||
# elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__)
|
||||
# define OS_WIN 0
|
||||
# define OS_UNIX 0
|
||||
# define OS_OS2 1
|
||||
@ -157,6 +157,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** If using an alternative OS interface, then we must have an "os_other.h"
|
||||
** header file available for that interface. Presumably the "os_other.h"
|
||||
|
37
src/os_os2.c
37
src/os_os2.c
@ -53,9 +53,11 @@ struct os2File {
|
||||
** Delete the named file
|
||||
*/
|
||||
int sqlite3Os2Delete( const char *zFilename ){
|
||||
DosDelete( (PSZ)zFilename );
|
||||
APIRET rc = NO_ERROR;
|
||||
|
||||
rc = DosDelete( (PSZ)zFilename );
|
||||
TRACE2( "DELETE \"%s\"\n", zFilename );
|
||||
return SQLITE_OK;
|
||||
return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -92,7 +94,7 @@ int sqlite3Os2OpenReadWrite(
|
||||
os2File f;
|
||||
HFILE hf;
|
||||
ULONG ulAction;
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
|
||||
assert( *pld == 0 );
|
||||
rc = DosOpen( (PSZ)zFilename, &hf, &ulAction, 0L,
|
||||
@ -142,7 +144,7 @@ int sqlite3Os2OpenExclusive( const char *zFilename, OsFile **pld, int delFlag ){
|
||||
os2File f;
|
||||
HFILE hf;
|
||||
ULONG ulAction;
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
|
||||
assert( *pld == 0 );
|
||||
rc = DosOpen( (PSZ)zFilename, &hf, &ulAction, 0L, FILE_NORMAL,
|
||||
@ -174,7 +176,7 @@ int sqlite3Os2OpenReadOnly( const char *zFilename, OsFile **pld ){
|
||||
os2File f;
|
||||
HFILE hf;
|
||||
ULONG ulAction;
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
|
||||
assert( *pld == 0 );
|
||||
rc = DosOpen( (PSZ)zFilename, &hf, &ulAction, 0L,
|
||||
@ -262,18 +264,19 @@ int sqlite3Os2TempFileName( char *zBuf ){
|
||||
*/
|
||||
int os2Close( OsFile **pld ){
|
||||
os2File *pFile;
|
||||
if( pld && (pFile = (os2File*)*pld)!=0 ){
|
||||
APIRET rc = NO_ERROR;
|
||||
if( pld && (pFile = (os2File*)*pld) != 0 ){
|
||||
TRACE2( "CLOSE %d\n", pFile->h );
|
||||
DosClose( pFile->h );
|
||||
rc = DosClose( pFile->h );
|
||||
pFile->locktype = NO_LOCK;
|
||||
if( pFile->delOnClose != 0 ){
|
||||
DosForceDelete( pFile->pathToDel );
|
||||
rc = DosForceDelete( pFile->pathToDel );
|
||||
}
|
||||
*pld = 0;
|
||||
OpenCounter( -1 );
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -295,7 +298,7 @@ int os2Read( OsFile *id, void *pBuf, int amt ){
|
||||
** or some other error code on failure.
|
||||
*/
|
||||
int os2Write( OsFile *id, const void *pBuf, int amt ){
|
||||
APIRET rc=NO_ERROR;
|
||||
APIRET rc = NO_ERROR;
|
||||
ULONG wrote;
|
||||
assert( id!=0 );
|
||||
SimulateIOError( SQLITE_IOERR );
|
||||
@ -314,7 +317,7 @@ int os2Write( OsFile *id, const void *pBuf, int amt ){
|
||||
** Move the read/write pointer in a file.
|
||||
*/
|
||||
int os2Seek( OsFile *id, i64 offset ){
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
ULONG filePointer = 0L;
|
||||
assert( id!=0 );
|
||||
rc = DosSetFilePtr( ((os2File*)id)->h, offset, FILE_BEGIN, &filePointer );
|
||||
@ -328,7 +331,7 @@ int os2Seek( OsFile *id, i64 offset ){
|
||||
int os2Sync( OsFile *id, int dataOnly ){
|
||||
assert( id!=0 );
|
||||
TRACE3( "SYNC %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
|
||||
return DosResetBuffer( ((os2File*)id)->h ) ? SQLITE_IOERR : SQLITE_OK;
|
||||
return DosResetBuffer( ((os2File*)id)->h ) == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -344,7 +347,7 @@ int sqlite3Os2SyncDirectory( const char *zDirname ){
|
||||
** Truncate an open file to a specified size
|
||||
*/
|
||||
int os2Truncate( OsFile *id, i64 nByte ){
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
ULONG upperBits = nByte>>32;
|
||||
assert( id!=0 );
|
||||
TRACE3( "TRUNCATE %d %lld\n", ((os2File*)id)->h, nByte );
|
||||
@ -361,7 +364,7 @@ int os2Truncate( OsFile *id, i64 nByte ){
|
||||
** Determine the current size of a file in bytes
|
||||
*/
|
||||
int os2FileSize( OsFile *id, i64 *pSize ){
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
FILESTATUS3 fsts3FileInfo;
|
||||
memset(&fsts3FileInfo, 0, sizeof(fsts3FileInfo));
|
||||
assert( id!=0 );
|
||||
@ -453,7 +456,7 @@ int sqlite3Os2IsDirWritable( char *zDirname ){
|
||||
*/
|
||||
int os2Lock( OsFile *id, int locktype ){
|
||||
APIRET rc = SQLITE_OK; /* Return code from subroutines */
|
||||
APIRET res = 1; /* Result of a windows lock call */
|
||||
APIRET res = NO_ERROR; /* Result of an OS/2 lock call */
|
||||
int newLocktype; /* Set id->locktype to this value before exiting */
|
||||
int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
|
||||
FILELOCK LockArea,
|
||||
@ -583,7 +586,7 @@ int os2Lock( OsFile *id, int locktype ){
|
||||
** non-zero, otherwise zero.
|
||||
*/
|
||||
int os2CheckReservedLock( OsFile *id ){
|
||||
APIRET rc;
|
||||
APIRET rc = NO_ERROR;
|
||||
os2File *pFile = (os2File*)id;
|
||||
assert( pFile!=0 );
|
||||
if( pFile->locktype>=RESERVED_LOCK ){
|
||||
@ -780,7 +783,7 @@ int sqlite3Os2RandomSeed( char *zBuf ){
|
||||
** in the random seed.
|
||||
**
|
||||
** When testing, initializing zBuf[] to zero is all we do. That means
|
||||
** that we always use the same random number sequence.* This makes the
|
||||
** that we always use the same random number sequence. This makes the
|
||||
** tests repeatable.
|
||||
*/
|
||||
memset( zBuf, 0, 256 );
|
||||
|
Loading…
Reference in New Issue
Block a user