aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2016-03-04 03:02:06 +0000
committerdrh <drh@noemail.net>2016-03-04 03:02:06 +0000
commita46cadc42e5cc1da7ea8a739b50a7b4c9a7d9e84 (patch)
tree60d34246554ef76efc8c47bcf8b77b38500c96e6 /src/os_unix.c
parente32a256acd23dcde4671a662426afa8a6d3a354b (diff)
downloadsqlite-a46cadc42e5cc1da7ea8a739b50a7b4c9a7d9e84.tar.gz
sqlite-a46cadc42e5cc1da7ea8a739b50a7b4c9a7d9e84.zip
Fix the build for cases when pread()/pwrite() are not available.
FossilOrigin-Name: 7d67d876b70c7a4199697c5b112d809c600e140e
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 9bcefb119..844a1c46e 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -84,7 +84,6 @@
# define USE_PWRITE64 1
#endif
-
/*
** standard include files.
*/
@@ -214,9 +213,6 @@ struct unixFile {
const char *zPath; /* Name of the file */
unixShm *pShm; /* Shared memory segment information */
int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
-#if !defined(USE_PREAD) && !defined(USE_PREAD64)
- off64_t iOfst; /* Current offset */
-#endif
#if SQLITE_MAX_MMAP_SIZE>0
int nFetchOut; /* Number of outstanding xFetch refs */
sqlite3_int64 mmapSize; /* Usable size of mapping at pMapRegion */
@@ -3114,6 +3110,9 @@ static int nfsUnlock(sqlite3_file *id, int eFileLock){
static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
int got;
int prior = 0;
+#if (!defined(USE_PREAD) && !defined(USE_PREAD64))
+ i64 newOffset;
+#endif
TIMER_START;
assert( cnt==(cnt&0x1ffff) );
assert( id->h>2 );
@@ -3125,15 +3124,13 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
got = osPread64(id->h, pBuf, cnt, offset);
SimulateIOError( got = -1 );
#else
- if( offset!=id->iOfst ){
- id->iOfst = lseek(id->h, offset, SEEK_SET);
- SimulateIOError( id->iOfst = -1 );
- if( id->iOfst<0 ){
- storeLastErrno((unixFile*)id, errno);
- return -1;
- }
- got = osRead(id->h, pBuf, cnt);
- if( got>=0 ) id->iOfst += got;
+ newOffset = lseek(id->h, offset, SEEK_SET);
+ SimulateIOError( newOffset = -1 );
+ if( newOffset<0 ){
+ storeLastErrno((unixFile*)id, errno);
+ return -1;
+ }
+ got = osRead(id->h, pBuf, cnt);
#endif
if( got==cnt ) break;
if( got<0 ){
@@ -3239,7 +3236,6 @@ static int seekAndWriteFd(
do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
#else
do{
- if( iOff!=fd
i64 iSeek = lseek(fd, iOff, SEEK_SET);
SimulateIOError( iSeek = -1 );
if( iSeek<0 ){