
peter_foelsche@agilent.com wrote:
Dear All,
from what it looks like the memory mapped io classes in boost::interprocess cannot deal with readonly files.
Which memory mapped classes? Managed or not? For basic operations like obtain a file mapping: file_mapping(const char *filename, mode_t mode); And map it: template<class MemoryMappable> mapped_region(const MemoryMappable& mapping ,mode_t mode ,offset_t offset = 0 ,std::size_t size = 0 ,const void *address = 0); you can specify mode_t. For managed_mapped_file you can't use read-only, because there are mutexes built in the mapped file that have to be locked in case one process opens creates new elements. So I guess you are referring to managed classes, right? a)The problem with allowing read-only is that another process can open it for writting and you would have problems. b)The internal structure should be changed to avoid using mutexes and that can be difficult because internal structures and user-defined algorithms and indexes should avoid that (and also user-defined objects that write in some read-operations). You also say that disk-space is being allocated when growing a file. That's the idea. Otherwise, it would be the internal "offset_ptr" pointers would become useless unless we map all file portions contiguously and try to manage several mapped regions (which might be a bit tricky). Anyway, I don't see why growing a file should be slower than creating a new one. The OS looks for free disk sectors so file contents are not physically contiguous although you get a single file. Why is making the file sparse an advantage? Regards, Ion
This is a big problem.
I think opening readonly files should be possible but all write operations to the file should fail.
Of course mapping a readonly file should be done with the matching flags so that the mapping can be shared and that the matching address space is readonly.
Also another drawback is that at least on Windows disk-space is being allocated when growing a file.
This is slow and it can be avoided by making the file sparse.
On UNIXs this is the default.
Thanks
Peter
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users