> From: "Jay A. Kreibich" <j...@kreibi.ch>
> Date: July 29, 2011 6:23:24 AM PDT
> Subject: Re: [sqlite] Exclusive locking mode not working as expected?
> 
>  On many OSes and most filesystems, file locking is advisory, not
>  mandatory.  File locks are essentially OS maintained atomic flags
>  about the locking state of a file.  The application must explicitly
>  check and acquire locks to understand if it is able to perform read/write
>  operations on the file.
> 
>  In short, most file locking is about applications cooperatively
>  waiting their turn, rather than being forcibly prohibited from doing
>  things.  They're "locks" in the computer science sense of that
>  word, not the front-door sense of the word.
> 
>  It also means that if an application (such as a file manager) does not
>  understand the specifics of the locking scheme used with a file, or
>  simply ignores locks, the application is usually free to manipulate
>  the file however it wants.
> 
>    http://en.wikipedia.org/wiki/File_locking

On Windows, file locks are not advisory wrt non memory-mapped IO.

> 
>> Am I missing something here or if I want to prevent this, is my only
>> option to modify our build of SQLite to open the file for exclusive access?
> 
>  You can set the file permissions.  That's a more appropriate means to
>  prevent this kind of operation.
> 

I'm not sure that would work for us -- there's no reason to prevent the user 
from copying the file when we don't have it open, and changing permissions only 
while our app is running isn't a good solution because they wouldn't get 
changed back in the case of a crash.

>   -j
> 
> -- 
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
> 
> "Intelligence is like underwear: it is important that you have it,
> but showing it to the wrong people has the tendency to make them
> feel uncomfortable." -- Angela Johnson
> 

> 
> From: Pavel Ivanov <paiva...@gmail.com>
> Date: July 29, 2011 7:54:18 AM PDT
> To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
> Subject: Re: [sqlite] Exclusive locking mode not working as expected?
> Reply-To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
> 
> 
>> Am I missing something here or if I want to prevent this, is my only option 
>> to modify our build of SQLite to open the file for exclusive access?
> 
> Yes, opening with exclusive access is the only option for you. But
> with latest SQLite version you don't have to modify SQLite sources for
> that. You can use xSetSystemCall in sqlite3_vfs to change open() call
> and add exclusiveness flag in provided function (see
> http://www.sqlite.org/c3ref/vfs.html).
> 
> 
> Pavel
> 
> 

Interesting, thanks. It may be that modifying the code is just as easy for us 
at this time since we already have a custom build for unrelated reasons, but 
I'm hoping to get rid of that custom build at some point and replacing 
individual system calls and this extension mechanism should help a lot with 
that!

- JonathanInformation (including any attachments) contained in this electronic 
transmission is a PRIVILEGED AND CONFIDENTIAL COMMUNICATION.  It is for the 
sole use of the sender and the entity named above.  If you received this 
electronic transmission in error, you are required to immediately delete it in 
its entirety without making a copy.  Further dissemination is absolutely 
prohibited. Thank you.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to