The problem: How to exclusively lock SQLite file on opening? I want to prevent application from being opened many times with the same file, but instead - display a warning message.
There's only internal sqlite3OsLock() but I want to override all these locks/unlocks made by 'pager'.
You'll ned to do it externally unless you really want to spend a bunch of time modifying SQLite's locking code.
If you want to exclude just your application from opening multiple copies, then you could create a .lock file or use fcntl() to lock the first byte of the file (assuming Unix) prior to ever passing control to SQLite. SQLite uses a range of bytes near the 2GB mark to perform its locking magic. If you were to lock the first byte for your own exclusivity, that should not be a problem.
If you are looking to exclude anything from opening the file-- say, sqlite command line tool-- that is a much harder problem. Probably the easiest way would be to change the file format slightly.
b.bum