aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-11-18 12:48:48 +0000
committerdrh <drh@noemail.net>2020-11-18 12:48:48 +0000
commit5a07d10fd15408218a6324bea6ff9ec080a73218 (patch)
treeef769b8969919a8b3674aa0a001dfc3da0f83059 /src/os_unix.c
parentaff1a57f4d19786ea07544d79eb82124d1122c49 (diff)
downloadsqlite-5a07d10fd15408218a6324bea6ff9ec080a73218.tar.gz
sqlite-5a07d10fd15408218a6324bea6ff9ec080a73218.zip
On unix, for certain error codes of read()/pread() return
SQLITE_IOERR_CORRUPTFS instead of SQLITE_IOERR_READ. And then convert this error into SQLITE_CORRUPT prior to returning back to the application. FossilOrigin-Name: 9538ea8447e7b07c05197d6ff2208d3e97b45798736c85b63e8f0c7a3a98c1f3
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 6badcbd39..b1e017376 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3375,7 +3375,25 @@ 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 ENOENT:
+ 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 */