An improved way of generating the SQLITE_READONLY_DIRECTORY error.

The error message submitted to sqlite3_log() is still correct this way.

FossilOrigin-Name: 1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15
This commit is contained in:
drh 2017-12-13 20:35:34 +00:00
parent a803a2cd98
commit 258dfe48cf
3 changed files with 10 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C New\sresult\scode\sSQLITE_READONLY_DIRECTORY\sis\sreturned\swhen\san\sattempt\sis\nmade\sto\swrite\son\sa\sdatabase\sfile\sthat\sis\sin\sa\sread-only\sdirectory\sand\shence\nthe\sjournal\sfile\scould\snot\sbe\screated.\s\sThis\ssituation\sformerly\sreturned\nSQLITE_CANTOPEN,\swhich\sless\shelpful.
D 2017-12-13T20:02:29.496
C An\simproved\sway\sof\sgenerating\sthe\sSQLITE_READONLY_DIRECTORY\serror.\nThe\serror\smessage\ssubmitted\sto\ssqlite3_log()\sis\sstill\scorrect\sthis\sway.
D 2017-12-13T20:35:34.439
F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e5d7606238f55816da99f719969598df5b091aa2e9a6935c9412fcae8f53fc44
@ -456,7 +456,7 @@ F src/os.c 22d31db3ca5a96a408fbf1ceeaaebcaf64c87024d2ff9fe1cf2ddbec3e75c104
F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c 1ec9390926a0626494466e572eb7754545acd3e423a4871a749fe35c09e0b6ab
F src/os_unix.c 7fc2735390a7809d5d893ed735d994ff12521224b89738226fff6f1a0aa1c932
F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 07cf850241667874fcce9d7d924c814305e499b26c804322e2261247b5921903
@ -1680,7 +1680,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 65754dc3b830ef9482655d2e93c2cd4acaa7a8715a58d8309955d04378541f89
R 317d939eaca617f6f45ef08fff90ca48
P 3ec73c38f878d73d278fce99ba10c708dcc475835774f1e17769ff7315be6d7c
R 22c3a7dd6bc608a3f08477eed3bb5065
U drh
Z f0826ac4a0e91b44749cba2450c52240
Z 687b40dd4870cf20b77c228c17085d90

View File

@ -1 +1 @@
3ec73c38f878d73d278fce99ba10c708dcc475835774f1e17769ff7315be6d7c
1c0aa919ee429cd194820ec9c54084563f39e63fd399b23f859fc6703b429b15

View File

@ -5904,12 +5904,6 @@ 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 && isNewJrnl && osAccess(zName, F_OK) ){
/* Trying to create a journal file where we don't have write
** permission on the directory */
rc = unixLogError(SQLITE_READONLY_DIRECTORY, "open", zName);
goto open_finished;
}
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);
@ -5921,6 +5915,9 @@ static int unixOpen(
}
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 && osAccess(zName, F_OK) ) rc = SQLITE_READONLY_DIRECTORY;
goto open_finished;
}