diff options
author | drh <drh@noemail.net> | 2020-11-18 23:44:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-11-18 23:44:41 +0000 |
commit | 02e4b7d7df1e8a66529d508d4cfcfbbca39953d2 (patch) | |
tree | 624254dcc490598977e23bf4546383e9f1a78438 /src/os_unix.c | |
parent | 8ea11095c9c98444b37430f2c39fc4a6d77a3c4e (diff) | |
parent | f56a4bfcd12cb7990ef171ffb89d2a27cd03ed4e (diff) | |
download | sqlite-02e4b7d7df1e8a66529d508d4cfcfbbca39953d2.tar.gz sqlite-02e4b7d7df1e8a66529d508d4cfcfbbca39953d2.zip |
If a read() or pread() indicates that the database file is unreadable due to
filesystem damage, then it returns SQLITE_IOERR_CORRUPTFS which is then
converted into SQLITE_CORRUPT before being returned to the application.
FossilOrigin-Name: 849e4e14fd06eda512381f5f8aa65f75ad0a955e835da7c63526a53cf5e8f4dc
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 6badcbd39..18f2b5461 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3375,7 +3375,24 @@ static int unixRead( if( got==amt ){ return SQLITE_OK; }else if( got<0 ){ - /* lastErrno set by seekAndRead */ + /* pFile->lastErrno has been set by seekAndRead(). + ** Usually we return SQLITE_IOERR_READ here, though for some + ** kinds of errors we return SQLITE_IOERR_CORRUPTFS. The + ** SQLITE_IOERR_CORRUPTFS will be converted into SQLITE_CORRUPT + ** prior to returning to the application by the sqlite3ApiExit() + ** routine. + */ + switch( pFile->lastErrno ){ + case ERANGE: + case EIO: +#ifdef ENXIO + case ENXIO: +#endif +#ifdef EDEVERR + case EDEVERR: +#endif + return SQLITE_IOERR_CORRUPTFS; + } return SQLITE_IOERR_READ; }else{ storeLastErrno(pFile, 0); /* not a system error */ |