Get major and minor device numbers


#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

dev_t rsrcdbmgr_devno_attach( const char * name,
                              int minor_request,
                              int flags );


The name of the class of devices that you want to get the major number for. This string can be anything, but can't include any slashes. Various names are defined in in <sys/ftype.h>; see Class names,” below.
The minor device number that you want to reserve, or -1 to let the system assign the next available minor number.
Presently, there are no flags; pass zero for this argument.



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The rsrcdbmgr_devno_attach() function reserves a device number that consists of:

There's a maximum of 64 major numbers (0 through 63) on the system, and a maximum of 1024 minor numbers (0 through 1023) per major number.

Major and minor numbers are used only by resource managers and are exposed through the rdev member of the iofunc_attr_t structure, and correspondingly the st_rdev member of the stat structure. They aren't required for proper operation; on simple devices, an entry will be simulated for you.

Note: In order to successfully use the rsrcdbmgr_*() functions to modify the resource database, your process must have the PROCMGR_AID_RSRCDBMGR ability enabled. For more information, see procmgr_ability().

If the requested device number is already in use (whether by the calling process or a different process), this function returns -1 and sets errno to EINVAL.

To detach a device, call rsrcdbmgr_devno_detach(). If you don't detach a device, it's released when the process that attached it terminates.

Class names

As mentioned above, the name of the class of devices can be anything, but can't include any slashes. The following class names are defined in <sys/ftype.h>:

Constant Value Class
_MAJOR_PATHMGR "pathmgr" Used only by the path manager
_MAJOR_DEV "dev" Devices in /dev with only one instance (e.g., /dev/tty)
_MAJOR_BLK_PREFIX "blk-" All block devices (e.g., /dev/hd[0-9]* would be "blk-hd")
_MAJOR_CHAR_PREFIX "char-" All character devices (e.g., /dev/ser[0-9]* would be "char-ser")
_MAJOR_FSYS "fsys" All filesystems


A dev_t object that contains the major and minor numbers, or -1 if an error occurs (errno is set).

You can extract the major and minor number values from the dev_t object by using the major() and minor() macros defined in <sys/types.h>. For more information, see the documentation for stat().


The call was interrupted by a signal.
One of the following occurred:
  • The requested name and number are already in use.
  • An argument was invalid.
Insufficient memory to allocate internal data structures.
The calling process doesn't have the required permission; see procmgr_ability().


#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

char      *dev_name;
int       myminor_request, flags=0;
dev_t     major_minor;

major_minor = rsrcdbmgr_devno_attach
              ( dev_name, myminor_request, flags );


rsrcdbmgr_devno_detach( major_minor, flags );


QNX Neutrino

Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes