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 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 function rsrcdbmgr_devno_attach() reserves a device number that consists of:

  • a major number that corresponds to the given device class. If there isn't already a major number associated with the class, a new major number is assigned to it.
  • a minor number that's based on minor_request. If minor_request is -1, the function returns the first free minor number in the specified class.

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.

Class names

As mentioned above, the name of the class of devices can be anything. 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() .


Invalid argument.


#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


If your application calls this function, it must run as root.

Last modified: 2013-12-23

comments powered by Disqus