I want to use SQLite to store some metadata information within a file. This file is already mmap'd. What I want to be able to do is create a SQLite DB, passing in a char* to tell it where to make the DB, instead of having it allocate its own. Can this be done? SQLite docs for in-memory databases just say to use ":memory:", and that the DB will be destroyed at end of process, with no indication of how to use already-existing data or persist it.
If not, what workarounds are there on Linux? Is there an "inverse" mmap, so I can take an address and map it to a new file? (So /foo would be a view onto a part of /bar?)
In-memory databases are just databases whose page cache is not saved to disk.
There is no mechanism to access these pages.
Your only choice would be to implement your own VFS to redirect file accesses to the correct part of that file.