int (*mmap) ( resmgr_context_t *ctp, io_mmap_t *msg, RESMGR_OCB_T *ocb )
struct _io_mmap { uint16_t type; uint16_t combine_len; uint32_t prot; uint64_t offset; struct _msg_info32 info; uint32_t required_prot; uint32_t zero [5]; }; struct _io_mmap_reply { uint32_t zero; uint32_t allowed_prot; uint64_t offset; int32_t coid; int32_t fd; }; typedef union { struct _io_mmap i; struct _io_mmap_reply o; } io_mmap_t;
Allows the memory manager to map files from your resource manager into memory. Generally, you should not code this function yourself (use the defaults provided by iofunc_func_init()—the default handler), unless you specifically wish to disable the functionality (for example, a serial port driver could choose to return ENOSYS, because it doesn't make sense to support this operation).
When a client calls mmap(), the function sends a _MEM_MMAP message to the memory manager, which then sends an _IO_MMAP message to the appropriate resource manager. The resource manager replies to the memory manager, which in turn replies to the client.
Note that a side effect of calling this function is that an OCB will be created (i.e., iofunc_ocb_calloc() or your replacement for it will be called), but this should have no consequences to a properly implemented resource manager.
The default implementation iofunc_mmap_default() calls the helper function iofunc_mmap(). The helper function checks that the requested mapping permissions do not conflict with the open mode for the file descriptor and that the mountpoint is not read only. The helper also checks that the file is executable before setting PROT_EXEC in allowed_prot. The helper obtains an exclusive write lock on the file if it is being mapped with execute permissions.