aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2018-01-10 11:56:03 +0000
committerdan <dan@noemail.net>2018-01-10 11:56:03 +0000
commita688ca5ea91e7046e1b88397a6fe0b88fb5b420e (patch)
treecfc48d5cf870d9dc613d041001bfccdbcd2f35d6 /src/os_unix.c
parent5af06983564e35005dcb550981d8ebceb1b491d6 (diff)
downloadsqlite-a688ca5ea91e7046e1b88397a6fe0b88fb5b420e.tar.gz
sqlite-a688ca5ea91e7046e1b88397a6fe0b88fb5b420e.zip
Fix a problem in os_unix.c causing it to return SQLITE_CANTOPEN instead of
SQLITE_READONLY_RECOVERY. FossilOrigin-Name: 6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 3b2b2e2a5..d368cb34e 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5904,22 +5904,24 @@ static int unixOpen(
fd = robust_open(zName, openFlags, openMode);
OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags));
assert( !isExclusive || (openFlags & O_CREAT)!=0 );
- if( fd<0 && errno!=EISDIR && isReadWrite ){
- /* Failed to open the file for read/write access. Try read-only. */
- flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
- openFlags &= ~(O_RDWR|O_CREAT);
- flags |= SQLITE_OPEN_READONLY;
- openFlags |= O_RDONLY;
- isReadonly = 1;
- fd = robust_open(zName, openFlags, openMode);
- }
if( fd<0 ){
- rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
- /* If unable to create a journal, change the error code to
- ** indicate that the directory permissions are wrong. */
if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){
+ /* If unable to create a journal because the directory is not
+ ** writable, change the error code to indicate that. */
rc = SQLITE_READONLY_DIRECTORY;
+ }else if( errno!=EISDIR && isReadWrite ){
+ /* Failed to open the file for read/write access. Try read-only. */
+ flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
+ openFlags &= ~(O_RDWR|O_CREAT);
+ flags |= SQLITE_OPEN_READONLY;
+ openFlags |= O_RDONLY;
+ isReadonly = 1;
+ fd = robust_open(zName, openFlags, openMode);
}
+ }
+ if( fd<0 ){
+ int rc2 = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
+ if( rc==SQLITE_OK ) rc = rc2;
goto open_finished;
}