Map memory I/O function handler

Updated: October 26, 2022


int (*mmap) ( resmgr_context_t *ctp,
              io_mmap_t *msg,
              RESMGR_OCB_T *ocb )



Default handler:


(QNX Neutrino 7.1 or later) There's also an extended version of this handler, iofunc_mmap_default_ext(), that provides stat information to the memory manager, saving the memory manager from sending a separate query for it to the resource manager.

Helper functions:

iofunc_mmap(), iofunc_mmap_ext()

Client functions:

mmap(), munmap(), mmap_device_io(), mmap_device_memory()



Data structure:

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 [3];
  uint64_t              requested_len;

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_MAP 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 status via the helper macro _RESMGR_STATUS().

Referenced by:

resmgr_io_funcs_t I/O table

Permission checking:

The default implementation iofunc_mmap_default() calls the helper function iofunc_mmap(), and iofunc_mmap_default_ext() calls iofunc_mmap_ext(). 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.