Fixes to os_unix.c to support database (and other) files larger than 2GiB on Android.
FossilOrigin-Name: ad7063aa1a0db32cdbe71815545b2edca57d3bcc
This commit is contained in:
commit
524a733d89
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\stypos\sin\scomments.\sNo\scode\schanges.
|
||||
D 2014-09-06T16:39:46.963
|
||||
C Fixes\sto\sos_unix.c\sto\ssupport\sdatabase\s(and\sother)\sfiles\slarger\sthan\s2GiB\son\sAndroid.
|
||||
D 2014-09-06T17:06:13.410
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -208,7 +208,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace
|
||||
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
||||
F src/os_unix.c 576f95b5b02397044ebbcdc1027528ba1bb2d92e
|
||||
F src/os_unix.c addd023b26c623fec4dedc110fc4370a65b4768c
|
||||
F src/os_win.c 0a4042ef35f322e86fa01f6c8884c5e645b911e7
|
||||
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
|
||||
F src/pager.c 31da9594ad4c3b5851bb6fe1a95c33835ab7ddce
|
||||
@ -1193,7 +1193,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 4d4fb197dc438a486cf5d967cf435f1132902c63
|
||||
R db0dce11ff1f08f3ef74aeb9c5ce2829
|
||||
U peter.d.reid
|
||||
Z 050bcae7bdbaf9a55cc282a84c1e1741
|
||||
P e62aab5e9290503869e1f4d5e0fefd2b4dee0a69 9dca7ce55797b3eb617859f6189c1a2ec6f66566
|
||||
R 4eacabb789e62917f709201f03eadd53
|
||||
U dan
|
||||
Z f60ed4f30cad7188918c7dd18fc1b985
|
||||
|
@ -1 +1 @@
|
||||
e62aab5e9290503869e1f4d5e0fefd2b4dee0a69
|
||||
ad7063aa1a0db32cdbe71815545b2edca57d3bcc
|
@ -299,6 +299,14 @@ static int randomnessPid = 0;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek()
|
||||
** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined.
|
||||
*/
|
||||
#ifdef __ANDROID__
|
||||
# define lseek lseek64
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Different Unix systems declare open() in different ways. Same use
|
||||
** open(const char*,int,mode_t). Others use open(const char*,int,...).
|
||||
@ -708,9 +716,22 @@ static int lockTrace(int fd, int op, struct flock *p){
|
||||
|
||||
/*
|
||||
** Retry ftruncate() calls that fail due to EINTR
|
||||
**
|
||||
** All calls to ftruncate() within this file should be made through this wrapper.
|
||||
** On the Android platform, bypassing the logic below could lead to a corrupt
|
||||
** database.
|
||||
*/
|
||||
static int robust_ftruncate(int h, sqlite3_int64 sz){
|
||||
int rc;
|
||||
#ifdef __ANDROID__
|
||||
/* On Android, ftruncate() always uses 32-bit offsets, even if
|
||||
** _FILE_OFFSET_BITS=64 is defined. This means it is unsafe to attempt to
|
||||
** truncate a file to any size larger than 2GiB. Silently ignore any
|
||||
** such attempts. */
|
||||
if( sz>(sqlite3_int64)0x7FFFFFFF ){
|
||||
rc = SQLITE_OK;
|
||||
}else
|
||||
#endif
|
||||
do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );
|
||||
return rc;
|
||||
}
|
||||
@ -3595,7 +3616,7 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
|
||||
nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
|
||||
}
|
||||
|
||||
rc = robust_ftruncate(pFile->h, (off_t)nByte);
|
||||
rc = robust_ftruncate(pFile->h, nByte);
|
||||
if( rc ){
|
||||
pFile->lastErrno = errno;
|
||||
return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user