1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Fix a problem in the unix implementation of FCNTL_SIZE_HINT on systems that do not support posix_fallocate().

FossilOrigin-Name: af20eae1e6f608e4e61a07c3d14cf88c12751353
This commit is contained in:
dan
2015-01-06 21:31:47 +00:00
parent 6fab3d469a
commit ef3d66cb01
3 changed files with 12 additions and 11 deletions

View File

@@ -3717,6 +3717,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
** that do not have a real fallocate() call.
*/
int nBlk = buf.st_blksize; /* File-system block size */
int nWrite = 0; /* Number of bytes written by seekAndWrite */
i64 iWrite; /* Next offset to write to */
iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
@@ -3724,11 +3725,11 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) );
assert( ((iWrite+1)%nBlk)==0 );
for(/*no-op*/; iWrite<nSize; iWrite+=nBlk ){
int nWrite = seekAndWrite(pFile, iWrite, "", 1);
nWrite = seekAndWrite(pFile, iWrite, "", 1);
if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
}
if( nSize%nBlk ){
int nWrite = seekAndWrite(pFile, nSize-1, "", 1);
if( nWrite==0 || (nSize%nBlk) ){
nWrite = seekAndWrite(pFile, nSize-1, "", 1);
if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
}
#endif