I am about to implement a custom VFS (virtual file system) for a Netburner embedded device (non windows) using FOpen, FRead, FWrite, FSeek, and FClose. I was surprised that i could not find a FOpen* version of the VFS available. It would make it a lot more portable to embedded devices.
I found some information on creating the VFS for SQLite here
http://sqlite.org/c3ref/vfs.html
but the information is very detailed and I have lots of other questions about the implementation.
I have some example VFS in the SQLite source code for Win, OS2, Linux but they don’t have a lot of comments, only source code.
I could use the information provided in the link above and the examples to create my custom VFS but i’m sure that I would miss something if I did it that way.
My questions are:
- Is there any more documentation about the SQLite VFS that I am missing? Maybe an implementation guide?
- Is there an Fopen version of the SQLite VFS that is available?
- Is there a unit testing code available to test my custom SQLite VFS once I have created it?
- Suggestions, comments, experiences with implementing SQLite VFS that you would like to share.
Did you notice that there is an additional source of documentation in the header file
sqlite3.h? Also, Google code search is your friend.Don’t worry too much about missing things, this is what the test suite is for. Take a guess at the purpose of every method from their name, the documentation and the example implementations; go for a first-draft implementation; run the tests on your target platform; iterate until the bar is green. From a cursory reading of the interface doc that you quoted, here are some educated guesses:
Those are your run-off-the-mill file management functions. You’ll notice that
xOpen()in turn returns a structuresqlite3_file, that has pointer methods of its own for reading and writing.Those are for shared libraries (see the
dlopen()man page on Linux). In an embedded environment, you probably can leave these unimplemented (try setting these to NULL).You might have to implement a random number generator, if your OS’ standard library doesn’t provide one already. I suggest a linear feedback register, which is small yet good.
These are the time management functions, to hook up with your OS.
You can get away by always returning 0 here 🙂 See unixGetLastError in os_unix.c (thanks Google Code Search!)
Good luck!