aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2015-01-06 21:31:47 +0000
committerdan <dan@noemail.net>2015-01-06 21:31:47 +0000
commitef3d66cb0133dcd1b07548d771fd48d4607d32cf (patch)
treef48ae89426c920749b910c1344634a993ce42085 /src/os_unix.c
parent6fab3d469adcebf213dd561c621d18d01f9a0413 (diff)
downloadsqlite-ef3d66cb0133dcd1b07548d771fd48d4607d32cf.tar.gz
sqlite-ef3d66cb0133dcd1b07548d771fd48d4607d32cf.zip
Fix a problem in the unix implementation of FCNTL_SIZE_HINT on systems that do not support posix_fallocate().
FossilOrigin-Name: af20eae1e6f608e4e61a07c3d14cf88c12751353
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index f802d9cd1..3fcb0cff2 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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