Obtain segment-specific information about mapped memory segments in the process associated with the file descriptor. This call matches the corresponding mmap() calls.

#include <sys/procfs.h>

#define DCMD_PROC_MAPINFO  __DIOF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 2, procfs_mapinfo)

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process.
dev_data_ptr NULL, or an array of procfs_mapinfo structures
n_bytes 0, or the size of the array
dev_info_ptr A pointer to an integer where the number of map entries can be stored
Note: Individual page data isn't returned (i.e., the PG_* flags defined in <mman.h> aren't returned). If you need the page attributes, use DCMD_PROC_PAGEDATA instead.

Call this the first time with an argument of NULL to get the number of map entries:

devctl( fd, DCMD_PROC_MAPINFO, NULL, 0, &n);

Next, allocate a buffer that's large enough to hold a procfs_mapinfo structure for each map entry, and pass it to another devctl() call:

my_buffer = (procfs_mapinfo *)
               malloc( sizeof(procfs_mapinfo) * n );
if ( my_buffer == NULL ) {
  /* Not enough memory. */

devctl( fd, DCMD_PROC_MAPINFO, my_buffer,
        sizeof(procfs_mapinfo) * n, &dummy);

For more information, see the section on DCMD_PROC_MAPINFO and DCMD_PROC_PAGEDATA in the appendix about the /procfs filesystem in The QNX Neutrino Cookbook.